Moodle 4.1 > 4.5 upgrade. Getting "Editor: Error, unable to load libraries" when creating new activities

Hi all

[First post]

We've upgraded our Moodle 4.1.19 to 4.5.5. PHP 8.1.

Now when we create a new H5P (mod_hvp) activity, the form displays "Editor: Error, unable to load libraries" and if we try to move forward it diaplays "Editor: You must select a content type".

This is the access log.

x.x.x.x - - [08/Aug/2025:11:36:42 +0200] "GET /admin/tool/mobile/mobile.webmanifest.php HTTP/1.1" 200 1015 "https://example.com/course/modedit.php?add=hvp&type&course=791&section=0..."
x.x.x.x - - [08/Aug/2025:11:36:42 +0200] "POST /lib/ajax/service.php?sesskey=bBekMwV0UR&info=tiny_autosave_resume_session HTTP/1.1" 200 383 "https://example.com/course/modedit.php?add=hvp&type&course=791&section=0...
x.x.x.x - - [08/Aug/2025:11:36:42 +0200] "POST /lib/ajax/service-nologin.php?info=12-method-calls&cachekey=1754644845 HTTP/1.1" 200 31113 "https://example.com/course/modedit.php?add=hvp&type&course=791&section=0...

The error log is:

x.x.x.x:35158] PHP Warning:  Undefined property: stdClass::$patch_version_in_folder_name in ./mod/hvp/editor/h5peditor.class.php on line 633, referer: https://example.com/course/modedit.php
[Fri Aug 08 11:44:15.410535 2025] [php:warn] [pid 3765843:tid 3765843] [client x.x.x.x:35158] PHP Warning:  Undefined property: stdClass::$patch_version_in_folder_name in ./mod/hvp/editor/h5peditor.class.php on line 633, referer: https://example.com/course/modedit.php
[Fri Aug 08 11:44:15.410549 2025] [php:warn] [pid 3765843:tid 3765843] [client x.x.x.x:35158] PHP Warning:  Undefined property: stdClass::$patch_version_in_folder_name in ./mod/hvp/editor/h5peditor.class.php on line 633, referer: https://example.com/course/modedit.php
[Fri Aug 08 11:44:15.411039 2025] [php:warn] [pid 3765843:tid 3765843] [client x.x.x.x:35158] PHP Warning:  Cannot modify header information - headers already sent by (output started at ./moodle/mod/hvp/editor/h5peditor.class.php:633) in ./mod/hvp/library/h5p.classes.php on line 3295, referer: https://example.com/course/modedit.php
[Fri Aug 08 11:44:15.411061 2025] [php:warn] [pid 3765843:tid 3765843] [client x.x.x.x:35158] PHP Warning:  Cannot modify header information - headers already sent by (output started at /./mod/hvp/editor/h5peditor.class.php:633) in ./mod/hvp/library/h5p.classes.php on line 3296, referer: https://example.com/course/modedit.php

Old H5P activities open without a problem.

Before upgrading the production site we upgraded a clone in a staging server. After testing for everything swapped the upgraded moodle directory of the prod. server with the upgraded code from the staging server. The prod. upgrade went according to our notes from the test upgrade.

Anybody knows the problem? Or, how can I debug further?

P.S. I have posted this in moodle.org https://moodle.org/mod/forum/discuss.php?d=469158, got no responses.

 

otacke's picture

Looks related to something that I created a pull request for in 2022. It has still not been handled, like so many other pull requests :-(

Two further observations:

1. As reported in https://moodle.org/mod/forum/discuss.php?d=469158#p1883649, an early task log (can't remember the date, on or before 1 Aug) contained lines like this:

Deprecated: Creation of dynamic property moodle_phpmailer::$Version is deprecated in moodle/lib/phpmailer/moodle_phpmailer.php on line 50

Deprecated: Creation of dynamic property core_h5p\core::$url is deprecated in ./h5p/h5plib/v124/joubel/core/h5p.classes.php on line 2137 

Why v124, when we are in v127? The 4.1 we upgraded was in 4.1. Could it be a stale cache? I did Purge all caches a couple of times though. Can't repeat that Warning now.

Where do the content types get downloaded, to check file permissions? Unlikely, since it is the same physical moodledata/ under 4.1 now taken over by 4.5.

2. The same logs ended:

Scheduled task failed: H5P-Inhaltstypen von h5p.org herunterladen (core\task\h5p_get_content_types_task),array_key_exists(): Argument #2 ($array) must be of type array, null given

Backtrace: * line 282 of /h5p/classes/core.php: call to array_key_exists() * line 215 of /h5p/classes/core.php: call to core_h5p\core->fetch_content_type() * line 69 of /lib/classes/task/h5p_get_content_types_task.php: call to core_h5p\core->fetch_latest_content_types() * line 263 of /lib/cronlib.php: call to core\task\h5p_get_content_types_task->execute() * line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task() * line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks() * line 178 of /admin/cli/cron.php: call to cron_run()

Can't reproduce it now. Still that error may point to something deeper.

otacke's picture

  1. Can't tell why Moodle's own H5P integration does use a different H5P core library wrapper than you selected (have you?). Could be caching, yes. It always can :-)
    I don't know where Moodle's own H5P integration downloads content to, but I'd assume that it would use Moodle File API - so you cannot simply tell a path.
  2. That's really not something I have time to dive into, in particular without a platform at hand where I can cleanly reproduce the issue.

Hi otacke

I did the patch on ./h5p/h5plib/v127/joubel/editor/h5peditor.class.php

$ diff h5peditor.class.php.bak h5peditor.class.php
628a629,632
> $patch_version_in_folder_name = (isset($local_lib->patch_version_in_folder_name)) ?
>         $local_lib->patch_version_in_folder_name :
>         null;

637c641
<           'patchVersionInFolderName' => $local_lib->patch_version_in_folder_name
---
>    'patchVersionInFolderName' => $patch_version_in_folder_name

But the log is the same:

PHP Warning:  Undefined property: stdClass::$patch_version_in_folder_name in ./mod/hvp/editor/h5peditor.class.php on line 633, referer: https://example.com/course/modedit.php?add=hvp&type&course=791&section=0...

Executed the task manually:

# sudo -u www-data -g www-data php admin/cli/scheduled_task.php --execute=core\\task\\h5p_get_content_types_task
Execute scheduled task: H5P-Inhaltstypen von h5p.org herunterladen (core\task\h5p_get_content_types_task)
... started 21:37:40. Current memory use 13.9 MB.
0 new content types installed
... used 159 dbqueries
... used 0.43445801734924 seconds
Scheduled task complete: H5P-Inhaltstypen von h5p.org herunterladen (core\task\h5p_get_content_types_task)

The task logs https://example.com/admin/tasklogs.php \core\task\h5p_get_content_types_task all have similar logs, "0 new content types installed".

 

otacke's picture

You have applied the patch to Moodle's own H5P integration, but the error that you are receiving originates in the H5P plugin for Moodle.

Plus: The automated library update using the cron job that you triggered does not belong to the H5P plugin for Moodle.

Hi otacke

Thanks for coming back. Due to the moderation delay we see the Saturdays comments only now, Monday a'noon. Lot happened in between:

- I noticed the wrong path to v127/ and did the patch on the right one. It tackled the "PHP Warning:  Undefined property: stdClass::$patch_version_in_folder_name" but "unable to load libraries" remained.

- Went to apply the Moodle release yesterday and noticed a sluggishness. Tracing the cause of that noticed that there was an old block of sessions in the moodledata/sessions each of size 0. Deleted them and the problem was SOLVED!

otacke's picture

Since more and more people are impacted by this problem and the pull request reportedly fixes the issue, I now created https://h5ptechnology.atlassian.net/browse/HFP-4291 which hopefully helps to bring this onto H5P Group's radar (issues on github and mentions to developers do not seem to suffice).

Hello otacke

That was incredibly helpful. I hope the H5P team will find the time. It is not only me struggling with Moodle versions and H5P, the whole moodle.org H5P forum is helpless: https://moodle.org/mod/forum/discuss.php?d=469158.