PHP include() error for files in moodledata

PHP include() error for files in moodledata

by Vid Vrh -
Number of replies: 3
Hi all,

I am trying to download a moodle plugin from the store, extract the zip file to moodledata folder and check the plugin requirements in the version.php file. I tested my code on Moodle 4.1.5+ release with PHP version 7.4 installed and it works perfectly fine, but when I move the plugin to a test site with Moodle 4.2.2+ and PHP version 8.2 i get the following error:

Exception - Failed opening required '../version.php' (include_path='[dirroot]/lib/pear:.:/usr/share/php') .

I have traced the error down to the include() statement where I try to access the downloaded plugin's version.php file, but I can't figure why it doesn't work. I found the forum post https://moodle.org/mod/forum/discuss.php?d=442644 where the suggested reason for similar error is that the PHP 8.1 isn't fully supported in Moodle, but when I tried with different sites with Moodle 4.2.2+ and PHP versions 8.0, 8.1 and 8.2, still only the 7.4 one  worked. If it helps, I was testing on Ubuntu 20.04 OS and Postgresql 12(15) database.

Thank you for help,
Vid
Average of ratings: -
In reply to Vid Vrh

Re: PHP include() error for files in moodledata

by Matevž Zebec -

When updating from 4.3 to 4.4, the category_class.php file is missing at dirroot]/question/category_class.php'.

You copy it from version 4.3 and it works

In reply to Vid Vrh

Re: PHP include() error for files in moodledata

by Marcelo M. Júnior -

The download_as_dataformat() function is obsolete.
Use:
/lib/classes/dataformat.php