Automated Drupal 11 compatibility fixes for layout_builder_st

Created on 18 March 2024, 10 months ago

Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 11.

Changes will periodically be added to this issue that remove deprecated API uses. To stop further changes from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD11" tag from the issue to stop the bot from posting updates.

The changes will be posted by the Project Update Bot β†’ official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated changes until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD11" tag is left on this issue, new changes will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the changes posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot changes. The bot will still post new changes then if there is a change in the new generated patch compared to the changes that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated changes.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated changes, remove the "ProjectUpdateBotD11" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated changes again, add back the "ProjectUpdateBotD11" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated changes will be posted here.

    If the issue is reopened, then new automated changes will be posted.

    If you are using another issue(s) to work on Drupal 11 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot β†’ or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Using the merge request

  1. Review the merge request and test it.
  2. Thoroughly test the changes. These changes are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the merge request, create a new branch and merge request and work from there.

Warning: The 'project-update-bot-only' branch will always be overwritten. Do not work in that branch!

Providing feedback

If there are problems with one of the changes posted by the Project Update Bot β†’ , such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue β†’ . For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue β†’ .

πŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

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

Merge Requests

Comments & Activities

  • Issue created by @project update bot
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 10 months ago
    40 pass
  • This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module β†’ , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.1, cannot fix all Drupal 11 compatibility problems.

    Therefore these changes did not update the info.yml file for Drupal 11 compatibility.

    Leaving this issue open, even after committing the current patch, will allow the Project Update Bot β†’ to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug info

    Bot run #11-121090

    This patch was created using these packages:

    1. drupal/upgrade_status: 4.1.0
    2. mglaman/phpstan-drupal: 1.2.7
    3. palantirnet/drupal-rector: 0.20.1
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 10 months ago
    40 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    40 pass
  • This comment was forced and has ignored the check if a change was already posted. This is only done when we want to update the issue without waiting for changes to happen.

    This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module β†’ , even with these changes, this module is not yet compatible with Drupal 11.

    Currently Drupal Rector, version 0.20.1, cannot fix all Drupal 11 compatibility problems.

    Therefore, these changes did not update the info.yml file for Drupal 11 compatibility.

    The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.

    Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot β†’ to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug information

    Bot run #11-137198

    These packages were used to generate the fixes:

    1. drupal/upgrade_status: 4.1.0
    2. mglaman/phpstan-drupal: 1.2.10
    3. palantirnet/drupal-rector: 0.20.1
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    40 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 7 months ago
    40 pass
  • This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.

    It is important that any automated tests available are run and that you manually test the changes.

    Drupal 11 Compatibility

    According to the Upgrade Status module β†’ these changes make this module compatible with Drupal 11! πŸŽ‰
    Therefore these changes update the info.yml file for Drupal 11 compatibility.

    Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot β†’ to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.

    Debug information

    Bot run #11-188815

    These packages were used to generate the fixes:

    1. drupal/upgrade_status: 4.3.2
    2. mglaman/phpstan-drupal: 1.2.11
    3. palantirnet/drupal-rector: 0.20.2
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 7 months ago
    40 pass
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Now that Drupal 11 is out, any maintainer plans here?

  • Status changed to Needs work about 2 months ago
  • πŸ‡©πŸ‡ͺGermany Grevil

    There are quite a few issues to solve first, before this is D11 ready:

    And other issues, that are not listed in the issues tab. I'll take a look, if we can simply fix the combined.

  • πŸ‡©πŸ‡ͺGermany Grevil

    grevil β†’ changed the visibility of the branch 3431600-automated-drupal-11 to hidden.

  • πŸ‡©πŸ‡ͺGermany Grevil

    grevil β†’ changed the visibility of the branch 3431600-automated-drupal-11 to active.

  • πŸ‡©πŸ‡ͺGermany Grevil

    grevil β†’ changed the visibility of the branch project-update-bot-only to hidden.

  • πŸ‡©πŸ‡ͺGermany Grevil

    Ok, this seems to do the trick! If merged, we can also close the child issues!

    Make sure to credit @justcaldwell and @almador, which helped me to fix / point out the issues!

  • πŸ‡©πŸ‡ͺGermany Grevil

    Unsure about existing installations, since the dependencies changed. Some people (not using drush and or composer) might have problems with the update.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Re #13 maybe create a new 2.x branch then?

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    We're changing the services.yml - don't we need to clear the container cache @grevil?

  • πŸ‡©πŸ‡ͺGermany Grevil

    We're changing the services.yml - don't we need to clear the container cache @grevil?

    Last time I checked this, clearing the container cache did not make a difference, but yea, I can add that.

  • πŸ‡©πŸ‡ͺGermany Grevil

    Done.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    This seems reasonable enough but I'm not entirely sold on the "override container services" approach, rather than decorating them, assuming they have interfaces (which they do). Also, there seems to be an out-of-scope change from another issue and I'd rather not commit that here.

  • πŸ‡©πŸ‡ͺGermany Grevil

    Yea no idea. I haven't decorated a symfony service before, so I am unsure what I am doing wrong here.... https://symfony.com/doc/current/service_container/service_decoration.html is not very helpful to be honest.

    The current implementation should be correct, as we autowire the class_resolver as the constructor argument, but I still get the following error:

    [error] ArgumentCountError: Too few arguments to function Drupal\layout_builder_st\DependencyInjection\DecoratedClassResolver::__construct(), 0 passed in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 1

    Even if I do it the non autowire way, like described in the docs, I get the exact same error.

    If I add: class_resolver: ~ I get an error, that the decorated class couldn't get found (which makes sense, as we delete it, but its in the docs for some reason).

    @phenaproxima do you have experience with decorating symfony services? Could you help me finish this?

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    want to set up a meeting to look at this together @Grevil?

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Step #1:

    Resolve this issue:
    πŸ› Error: Call to a member function getConfig() OverridesSectionStorage.php Active

    Step #2, continue working on the rest.

  • πŸ‡¬πŸ‡ͺGeorgia almador

    Applied the patch from:
    https://git.drupalcode.org/project/layout_builder_st/-/merge_requests/16...

    And received the error:
    PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Drupal\layout_builder_st\DependencyInjection\DecoratedClassResolver::__construct(), 0 passed in /app/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 and exactly 1 expected in /app/public_html/modules/contrib/layout_builder_st/src/DependencyInjection/DecoratedClassResolver.php:17

    Here is the list of my patches:
    "drupal/layout_builder_st": {
    "Issue #3420063: Error: Call to a member function getConfig() OverridesSectionStorage.php":
    " https://www.drupal.org/files/issues/2024-03-29/layout_builder_st-call_to... β†’
    3420063-26.patch",
    Issue #3069964 Argument 1 passed to Drupal.. must implement interface Drupal null given":
    " https://www.drupal.org/files/issues/2019-07-24/isTranslation-null-given.... β†’ ",
    "Issue #3431600: Automated Drupal 11 compatibility fixes for layout_builder_st":
    "patches/layout_builder_st_3431600_16_2.patch"

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Manual Dependency Injection with Decorator Pattern

    • Manual Injection avoids relying on the #[AutowireDecorated] attribute, which is not natively supported in Drupal's DI system.
    • Explicit Definition aligns with Drupal's preferred service configuration, ensuring compatibility with core patterns.
    • Backward and Forward Compatible: This approach works with both current and future versions of Drupal.
  • Pipeline finished with Failed
    3 days ago
    Total: 147s
    #385139
  • Pipeline finished with Failed
    3 days ago
    Total: 145s
    #385141
  • Pipeline finished with Failed
    3 days ago
    Total: 178s
    #385146
  • Pipeline finished with Failed
    3 days ago
    Total: 513s
    #385152
  • Pipeline finished with Failed
    3 days ago
    Total: 274s
    #385185
  • Pipeline finished with Failed
    3 days ago
    Total: 307s
    #385195
  • Pipeline finished with Failed
    3 days ago
    #385197
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    @almador , sometimes the patch file doesn't work depending on how the patch is being applied, try the diff file instead.

    https://git.drupalcode.org/project/layout_builder_st/-/merge_requests/16...

    With that said, I'm not done fixing.

  • Pipeline finished with Failed
    3 days ago
    Total: 270s
    #385208
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Restored the original override approach as the decorator approach does NOT work. The class_revolver.inner parameter is not available and the service is not available.

  • Pipeline finished with Failed
    3 days ago
    #385225
  • Pipeline finished with Canceled
    3 days ago
    Total: 163s
    #385248
  • Pipeline finished with Failed
    3 days ago
    Total: 319s
    #385249
  • Pipeline finished with Failed
    3 days ago
    Total: 358s
    #385270
  • Pipeline finished with Failed
    3 days ago
    Total: 465s
    #385314
  • Pipeline finished with Failed
    3 days ago
    Total: 320s
    #385332
  • Pipeline finished with Failed
    3 days ago
    Total: 477s
    #385346
  • Pipeline finished with Failed
    3 days ago
    Total: 314s
    #385351
  • Pipeline finished with Failed
    3 days ago
    Total: 470s
    #385361
  • Pipeline finished with Failed
    3 days ago
    Total: 317s
    #385372
  • Pipeline finished with Failed
    3 days ago
    Total: 443s
    #385374
  • Pipeline finished with Failed
    3 days ago
    Total: 352s
    #385409
  • Pipeline finished with Canceled
    3 days ago
    Total: 221s
    #385421
  • Pipeline finished with Failed
    3 days ago
    Total: 325s
    #385425
  • Pipeline finished with Failed
    3 days ago
    Total: 364s
    #385428
  • πŸ‡¬πŸ‡ͺGeorgia almador

    Hi, Joseph and thank you for your efforts!

    AFAIU, it's not the final version yet?

    Tried both diff and patch in my local environment, they are not applying cleanly:
    https://git.drupalcode.org/project/layout_builder_st/-/merge_requests/16...
    https://git.drupalcode.org/project/layout_builder_st/-/merge_requests/16...

  • πŸ‡¬πŸ‡ͺGeorgia almador

    If I'm applying only 2 first patches (without the patch from this topic):

    "drupal/layout_builder_st": {
    "Issue #3420063: Error: Call to a member function getConfig() OverridesSectionStorage.php": "https://www.drupal.org/files/issues/2024-03-29/layout_builder_st-call_to_a_member_function_getconfig-3420063-26.patch",
    "Issue #3069964: Argument 1 passed to Drupal.. must implement interface Drupal null given": "https://www.drupal.org/files/issues/2019-07-24/isTranslation-null-given.patch"
    },

    I'm receiving this error:
    Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "class_resolver", path: "string_translation -> string_translator.locale.lookup -> config.factory -> config.typed -> class_resolver -> entity_type.manager". in Drupal\Component\DependencyInjection\Container->get() (line 149 of core/lib/Drupal/Component/DependencyInjection/Container.php).

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    @almador, delete your version, back off your other patches, grab the 8.x-1.x dev release clean clone or the latest tagged release and apply the merge request diff, see how that works.
    The only other patch you might need other than the MR diff is this one: https://www.drupal.org/files/issues/2025-01-02/3069964-null-fix.patch β†’

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    I'll get back to reviewing this the next few days, with that said, follow my instructions, this diff is applying cleanly against the head of 8.x-1.x provided there's no conflicting patches being applied and I had no choice but to add two fixes from two other issues into this MR. The only fix I didn't include that I'm using elsewhere is this one: https://www.drupal.org/files/issues/2025-01-02/3069964-null-fix.patch β†’

  • πŸ‡¬πŸ‡ͺGeorgia almador

    Thank you so much,@ Joseph!

    I followed your instructions and successfully applied 2 patches, at least I can now clear caches from Drupal admin interface without errors!

    Here are my steps (if someone want to repeat them):
    1. composer require 'drupal/layout_builder_st:1.x-dev@dev'

    2. I applied the patch in composer.json

    "drupal/layout_builder_st": {
    "Issue #3069964: Argument 1 passed to Drupal.. must implement interface Drupal null given": "https://www.drupal.org/files/issues/2025-01-02/3069964-null-fix.patch"}
    

    3. I downloaded https://git.drupalcode.org/project/layout_builder_st/-/merge_requests/16... to my patches folder and renamed it to 16.patch.

    4. I added the new patch in composer.json (now we have 2 patches):

    "drupal/layout_builder_st": {
    "Issue #3069964: Argument 1 passed to Drupal.. must implement interface Drupal null given": "https://www.drupal.org/files/issues/2025-01-02/3069964-null-fix.patch",
    "Issue #3431600: Automated Drupal 11 compatibility fixes for layout_builder_st":"16.patch"
    }

    5. composer install

  • Pipeline finished with Failed
    1 day ago
    Total: 347s
    #386650
  • Pipeline finished with Failed
    about 24 hours ago
    Total: 346s
    #386663
  • Pipeline finished with Canceled
    about 23 hours ago
    Total: 90s
    #386683
  • Pipeline finished with Failed
    about 23 hours ago
    Total: 184s
    #386684
  • Pipeline finished with Failed
    about 23 hours ago
    Total: 155s
    #386708
  • Pipeline finished with Failed
    about 23 hours ago
    Total: 414s
    #386718
  • Pipeline finished with Failed
    about 22 hours ago
    Total: 399s
    #386738
  • Pipeline finished with Canceled
    about 22 hours ago
    Total: 221s
    #386747
  • Pipeline finished with Failed
    about 22 hours ago
    Total: 339s
    #386752
  • Pipeline finished with Failed
    about 22 hours ago
    Total: 329s
    #386757
  • Pipeline finished with Failed
    about 22 hours ago
    Total: 386s
    #386762
  • Pipeline finished with Failed
    about 21 hours ago
    Total: 333s
    #386784
  • Pipeline finished with Failed
    about 20 hours ago
    Total: 388s
    #386818
  • Pipeline finished with Canceled
    about 20 hours ago
    Total: 281s
    #386829
  • Pipeline finished with Failed
    about 20 hours ago
    Total: 419s
    #386833
  • Pipeline finished with Failed
    about 20 hours ago
    Total: 342s
    #386849
  • Pipeline finished with Failed
    about 18 hours ago
    Total: 337s
    #386895
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    I am going to mark this as RTBC as an iterative improvement, this is a significant improvement over what we currently have.

    BEFORE:

    The dev branch release and tagged releases of layout_builder_st are crashing on supported releases of Drupal core (D10.3 and will not install at all on D11).
    The last successful test run was in July 2024 with Drupal core 9.5. Drupal 9.5 is no longer a supported release of Drupal core.

    AFTER:

    An installable Drupal 11 build
    An installable Drupal 10.3 build
    The module is able to install without crashing using this merge request code

    The path forward:

    I've updated the tests to make it a bit more obvious what is going on.

    1 Jul 2024 at 00:50 EDT PHP 7.3 & MySQL 5.7, D9.5 40 pass β†’

    Conclusion

    While this module in it's current state IS broken on Drupal 10.3 / Drupal 11.1, this MR should be merged so that we can move forward with the various fixes.

    Open followup issues to deal with the rest in a future release.

    Marking this as critical due to the current state of compatibility. (if we do nothing, fatally broken project that basically crashes sites unless patching with this merge request).

    Merging this MR is the best action forward so that we can focus on the remaining translation issue as seen in the test failures.

  • Pipeline finished with Failed
    about 18 hours ago
    #386919
  • Pipeline finished with Failed
    about 18 hours ago
    #386920
  • Pipeline finished with Failed
    about 18 hours ago
    Total: 338s
    #386912
  • Pipeline finished with Failed
    about 18 hours ago
    Total: 343s
    #386921
  • Pipeline finished with Failed
    about 18 hours ago
    Total: 411s
    #386925
  • Pipeline finished with Failed
    about 17 hours ago
    Total: 370s
    #386930
  • Pipeline finished with Canceled
    about 17 hours ago
    Total: 338s
    #386936
  • Pipeline finished with Canceled
    about 17 hours ago
    Total: 136s
    #386938
  • Pipeline finished with Failed
    about 17 hours ago
    Total: 392s
    #386942
  • Pipeline finished with Failed
    about 7 hours ago
    Total: 341s
    #387487
  • Pipeline finished with Canceled
    about 7 hours ago
    Total: 135s
    #387498
  • Pipeline finished with Failed
    about 7 hours ago
    Total: 377s
    #387505
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Can you run the tests locally and replicate the 403 statuses? Do you see 403 outside of tests?

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

     @liam morland,

    these tests last succeeded under drupal 9.5

    We hadn't EVER ran them on 10 until now, and take a look, I used the variables to go back to run 10.4, same thing as 11.0 and 11.1, same results.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    If the results are the same on every version tested, then that does decouple fixing the tests from Drupal 11 compatibility.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Sure, with that said, this module crashes if installed with D10.4.0 unless patching. I've included those fixes in the MR.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Holy smoke, this is making way too many changes for us to merge it. If there's a bug here (and it seems like there might be), we should solve it in another issue and then only make compatibility fixes here.

    It's impossible to review enormous patches (that make many sweeping changes) with confidence. Let's do this incrementally.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    First things first: let's open a new issue to add .gitlab-ci.yml. It's okay if there are failures, I'll merge it anyway because it gives us a roadmap for what we need to fix next.

    If it helps, in that issue we can drop support for Drupal <10.2.

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    It is preferable to get tests passing on the currently-supported version and then do the compatibility changes.

Production build 0.71.5 2024