Drupal 10 support

Created on 15 March 2023, over 1 year ago
Updated 26 October 2023, about 1 year ago

I'm testing h5p with php 8 and drupal 10 for a new site. To get it working, I applied the drupal_rector patch, adjusted the info.yml files and had to remove .once in a javascript file -> with these changes my first tests were successful.

I'll add my patch here - perhaps more changes are needed and the patch could be a starting point for drupal 10 setups.

πŸ’¬ Support request
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria anschinsan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @anschinsan
  • πŸ‡ΊπŸ‡ΈUnited States andrewjaykirkpatrick Oregon

    Thanks for the .once code change.
    I can confirm this works for me in Drupal 10.0.3 with PHP8.
    I cannot edit new H5P interactive items due to a reliance on CKEditor3 as defined in /vendor/h5p/h5p-editor/h5peditor.class.php

    'ckeditor/ckeditor.js'.

    I also noted a small issue with json decoded values being null rather than empty (single quotes) in /src/Entity/H5PContent.php
    - 'authors' => json_decode($this->get('authors')->value),
    + 'authors' => json_decode($this->get('authors')->value ?: ''),

    - 'changes' => json_decode($this->get('changes')->value),
    + 'changes' => json_decode($this->get('changes')->value ?: ''),

  • First commit to issue fork.
  • @omar_emailat opened merge request.
  • πŸ‡ͺπŸ‡ͺEstonia pjotr.savitski

    It might be better to use the

    use Drupal\Component\EventDispatcher\Event;
    

    for FinishedEvent class as that would work with both Drupal 9 and 10.

  • πŸ‡ͺπŸ‡ͺEstonia pjotr.savitski

    I'm not yet 100% sure, but inability to use interactive items might have everything to do with removal of the calls to jquery.once and not replacing those with the new custom once that is available in both versions 9 and 10.

    H5P is not using the default CKEditor added by Drupal, but a custom one that is shipped with the h5p-editor dependency. This is why ckeditor/ckeditor.js is a false positive and irrelevant to the upgrade process.

    I've currently refactored the code in application.js file to use the new logic and the detachment code looks like this (I'm not including the longer one from attachment function):

    detach: function (context, settings, trigger) {
          if (trigger === 'serialize') {
            once('H5PEditor', '.h5p-editor-iframe', context).forEach(function(element) {
              for (var i = 0; i < submitHandlers.length; i++) {
                if (submitHandlers[i].element === element) {
                  // Trigger submit handler
                  submitHandlers[i].handler();
                }
              }
            });
          }
        }
    
  • πŸ‡©πŸ‡ͺGermany ammaletu Bonn, Germany

    There seem to be two Merge Requests trying to make H5P ready for Drupal 10. This one, and the one in https://www.drupal.org/project/h5p/issues/3329297 πŸ“Œ Automated Drupal 10 compatibility fixes Needs review . Would it make sense to combine the two? Or better to simply get one of them ready and then see about cleaning up the other one? The other MR has at least one patch which is missing here (see comment #14 in the other ticket).

    Is there anything I can do to move this along? We want to upgrade to Drupal 10 in a few days, and now I see that we can't without heavily patching this module. End-of-life for Drupal 9 is in 8 days! Please let me know what the next step would be. Incorporating Pjotr's comments into the MR?

  • Status changed to Closed: duplicate about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Closing this as duplicate of πŸ“Œ Automated Drupal 10 compatibility fixes Needs review , please focus any efforts over there.

Production build 0.71.5 2024