Drupal 11 compatibility fixes

Created on 26 September 2024, 3 months ago

Problem/Motivation

Issue to help make this module compatible with Drupal 11.

Steps to reproduce

Incompatibilities detected by upgrade_status module.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇺🇦Ukraine yuriy.korzhov

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

Merge Requests

Comments & Activities

  • Issue created by @yuriy.korzhov
  • 🇮🇳India sarwan_verma

    Hi,

    I tried applying Patch #2, but it was not successful. However, I have resolved the "Drupal 11 compatibility" issue and created a new patch, which I have attached.

    Please review and verify.

    Thanks!

  • First commit to issue fork.
  • Merge request !23Resolve #3476979 "Drupal 11 compatibility" → (Open) created by el7cosmos
  • 🇪🇸Spain fjgarlin

    Hi @ukor, based on your recent activity on the issue queue https://www.drupal.org/user/3477971/track , it seems like you're targeting the same low-effort contribution issues.

    First of all, there is already an automatic bot that checks modules for Drupal 11 compatibility and provides MRs for it. This tool is developed and curated by the community and there is no need to go to multiple modules and duplicate the effort of maintainers (and even yourself in this case).

    Also, if an issue can be created for many modules, then it's worth collaborating with the community or the Drupal association to build a tool or bot to mass-update modules, otherwise it can be perceived as wanted to accumulate low-effort credits for you or your company.

    I have blocked your user for now, and if you would like your user to be unblocked, we would like you to go through some training materials to improve the way that you help the community (and your company and yourself). You can find a good list of resources in this page: https://www.drupal.org/community/contributor-guide

    It'd be great if you can read the "credit policy" and "issue etiquette" links and watch the two training videos. Spending a couple of hours on this will go a long way on your contribution journey. I also recommend that after you do it, you share this information with other users that might need it.

    If you want your user to be unblocked, please email us at help@drupal.org and explain us what you would do differently going forwards.
    Thanks so much for your understanding.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • 🇮🇳India abhinavk

    I have added some fixes for issues I encountered on Drupal 11 in MR!23.

    Category for Field type does not work with @Translation. Fixed it.
    Change log: https://www.drupal.org/node/3375748

  • 🇮🇳India abhinavk

    Asset optimizer is deprecated. I have added fix based on below change log.
    Change log: https://www.drupal.org/node/2888767

    MR!23 Makes module Drupal 11 compatible.

    For me using Xampp on windows, some h5p content types like true/false and fill in the blanks does not work (display) on node page after above fix. (Without this fix page breaks on Drupal 11).
    If I disable Aggregate JS & CSS, then everything works fine.

    Please suggest a solution for this or a better fix if anybody find it.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work about 7 hours ago
  • 🇪🇪Estonia pjotr.savitski

    @abhinavk Using legacy/deprecated aggregator class was a quick and rather low effort solution to library code not working with the new aggregator class. I don't remember the inner details as I last looked at it more or less a year or so ago, but the methods aggregatedAssets and createCachedPublicFiles are the ones that are causing the issues.

    H5P is not using libraries as Drupal generally does, but content type libraries specify static assets that are determined at runtime. Getting that to work with new cache system could boil down to a simple change, but I vaguely remember that it does make a new request to an endpoint and that one does no have the files that have to be optimized.

    Here is an example of how it works taken from the field formatter:

    • It determines H5P internal dependencies for the content
    • Runs the alter hooks to allow modifying the resulting list
    • Then aggregates the core assets and additional scripts and styles

    Aggregates are overwritten on each save or content view and removed on each cache rebuild (probably not rebuilt until the content is accessed or updated). If I remember it correctly, new aggregation system works based on libraries and those are specified as a query string. That means that most of the files are not present as those have no libraries and thus are not added to the aggregator.

    Maybe there is a way to define a library for each content type with some kind of hook allowing that library to be filled with assets using content type identifier as a basis. This means that the code determining the assets would be removed from the formatter and moved to that hook (most probably hook alter) that would deal with determining the assets and creating the resulting aggregates. One example would be h5p-content-123 where 123 is the unique identifier of the entity.

    I have not dived deep into aggregate handler inner workings and know how deprecated one maps to the currently active solution. Thus I'm making several guesses and drawn conclusions could be totally wrong. One thing is certain - not using aggregation would mean that a lot of files are loaded at once as H5P uses internal dependency system that allows higher level content libraries to use lower level ones as building blocks. Content types like Course Presentation would probably be loading tens of scripts and several styles. Core also consists of several static asset files.

Production build 0.71.5 2024