Mixed version dependency conflict

Forums: 

I ran ino a strange bug in the Moodle mobile app. In the app, but not the web, we are getting the error in the attached screenshot  with the attached h5p.

This H5P was generated on h5p.com and had been working, but then stopped at some point.

When I checked the dependencies on the file we uploaded to moodle (attached broken.h5p) and the export file that Moodle sent to the mobile app, I noticed this change in dependencies:

broken.h5p dependencies

  • H5PEditor.CoursePresentation v1.22.0 depends on H5PEditor.ColorSelector v1.2.0
  • H5PEditor.CoursePresentation v1.22.0 depends on H5P.Shape 1.0.0
  • H5P.Shape depends on H5PEditor.ColorSelector v1.2.0

Server export

  • H5PEditor.CoursePresentation v1.22.0 depends on H5PEditor.ColorSelector v1.2
  • H5PEditor.CoursePresentation v1.22.0 depends on H5P.Shape 1.0
  • H5P.Shape v1.0.4 depends on H5PEditor.ColorSelector v1.3

It appears that updating the Shape library from 1.0.0 to 1.0.4 changed it's dependency for the ColorSelector.

Here is where things get a little strange:
- the H5P works in the web view of the site
- it sometimes works in the mobile app

As best as I can tell, in the web view for Moodle, it's loading color selector v1.2 and v1.3. I think that Moodle is caching all of the libraries in the browser, so despite the dependency not being in the export, it is still present on the page. In the mobile app, if you first view an h5p with the missing dependency, and then go back and view the broken one it starts working. This implies to me that the missing dependency is being cached somehow in the mobile app.

When I went digging into the code that generates the h5p, I noticed that list of dependencies that gets built for the export only keys off of the machine name, not the version. This means if your h5p somehow has mixed dependencies (such as ours), it will load the first one it comes accross (in our case v1.2) and adds it to the list. When it comes across the dependency on 1.3, it checks it's list of dependencies, sees that ColorSelector is already included and skips it. Is there a reason that it keys only off of the machine name and not the version numbers as well? Made this change on our servers:

https://github.com/h5p/h5p-php-library/pull/138

And forced our export files to regenerate, and that caused the error to go away for us. 

 

H5P file: 
Summary: 
Allow different versions for the same library to be included in one export
Content types: 
otacke's picture

Hi!

H5P core is not able to handle multiple versions of the same library at once. That's why the release maintainer needs to make sure that all the dependencies do not contain machine name duplicates with different versions which seems to have failed here. One would need to investigate why it worked in some cases, but that's rather a coincidence and not the way it should be.

The solution would not be to allow multiple versions of a library to be exported, but to upgrade libraries and contents to Course Presentation 1.24 which should fix the issue.

Cheers,
Oliver

Okay then, is there a way to easily script updating those? We have ~500 impacted h5ps. 

otacke's picture

Hey Peter!

Sure. Something every H5P admin should know how to do.

You should see an "Update available" message in the H5P Hub on Course Presentation panel. Click on "Details" and then on "Update". That will install the latest version of Course Presentation.

On the H5P library screen of your plugin, you may then see a green arrow behind any library that content exists for and could be updated to the latest version. Click on that arrow, choose the version that you want to upgrade to and do so.

If you're running moodle's custom version of an H5P integration (the one with the blue H5P icon and the content bank), you should re-trigger the task to update H5P libraries. That will do step 1 at least. I do not know, however, how existing content will be updated to a later version on that custom integration. Maybe that's done automatically when upgrading libraries, maybe there is some other way. That's something that the moodle team would need to answer.

Cheers,
Oliver