Automated Drupal 10 compatibility fixes

Created on 16 June 2022, over 2 years ago
Updated 17 April 2023, over 1 year ago

Problem/Motivation

Hello project maintainers,

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

To read more about this effort by the Drupal Association, please read: The project update bot is being refreshed to support Drupal 10 readiness of contributed projects β†’

Patches will periodically be added to this issue that remove Drupal 10 deprecated API uses. To stop further patches 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 "ProjectUpdateBotD10" tag from the issue to stop the bot from posting updates.

The patches 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 patches 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 "ProjectUpdateBotD10" tag is left on this issue, new patches 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 patches 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 patches. The bot will still post new patches then if there is a change in the new generated patch compared to the patch that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated patches.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated patches, remove the "ProjectUpdateBotD10" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated patches again, add back the "ProjectUpdateBotD10" 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 patches will be posted here.

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

    If you are using another issue(s) to work on Drupal 10 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.

Providing feedback

If there are problems with one of the patches 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

Fixed

Version

4.0

Component

Code

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    A few things here...

    1. Holy cow this patch is a monster...
    2. I think there were some things from the D8 -> D9 upgrade that weren't resolved.
    3. Some of the tests rely on the juicebox JS library being installed -- not sure how the D.O. test runner will cope with this...?

    Let's see what the test runner thinks about this patch (note - totally a manual effort here. I don't think the patch bot stands a chance with this one...

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Add drupalci.yml to see if we can coerce drupalci to install the required libs...

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Fix composer.json

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    wget isn't installed on the build container. Let's try curl instead?

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    ....unzip isn't installed either...hopefully tar is...

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Add the -L flag to curl (and run it as the proper user).

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania
  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Fix web root (hopefully).

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Move library to correct directory...

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Know what they say, 21st time's the charm.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania
  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Hiding incomplete / red patches.

    #22 is green on 9.5.x and 10.0.x -- should be good for human review!

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Amazing work Luke!

    With the exception of the coding standards nits this looks like it should be good to go. It also quickly obsoletes my "juicey" sandbox project. If we can move this forward within the juicebox project itself that will save a lot of duplication of effort.

    Just wondering: should we create a new release specifically planning to get a release that works with Drupal 10 and that has your patches? I would love to test these on PHPstorm locally. I am not expert on version naming and numbering but maybe something in the order of 10.x-3.1 labeled as a dev release. This should also work with 9.x code but be primarily intended as code that could be used with Drupal 10.

    Having a whole bunch of pending patches sitting on top of one another is not really productive. But we need to commit the patches that pass testing and fix up coding standards so that people can have something to test with. I am just about ready to upgrade my local testing site and then my live shared hosting site to Drupal 10. I'll will happily test away with the hundreds of Juicebox albums I am using.

    I will email Neslee to see what he wants to do.

  • πŸ‡ΊπŸ‡ΈUnited States contiveros

    Great job fellas. Thanks for moving this forward. I wish I had the expertise to make this work.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    @contiveros ... thanks for the encouragement. I think we are (as of 3/12/2023) a few days away from being able to apply the first round of patches. Then we'll have to assess where that gets us and have a better estimate of when we can do a dev release for Drupal 10. But we always have to be cautious about not counting our chickens before ...

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Adjust support range to ^9.3 || ^10 due to service usage added in 9.3. These changes are fundamentally incompatible with versions of Drupal <= 9.2.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    I will apply and test these changes locally. It will be on my 10.0.7 local system.

    A question: if we adjust the support range on 8.x-3-x will this include
    8.x-3.x-dev AND 8.x-3.0-alpha2 ??

    Last time I checked these were identical branches. Or should we have a new release that's pegged to Drupal 10 or at least to ^9.3 || ^10 as in your patch. And warn people off from downloading it if they are below 9.3? And perhaps just leave the alpha2 release alone as the last version for anything below 10.

    Off topic, but I see I've been added as a maintainer. I'll stay within the bounds of my skills, which are limited. I have some questions about tools to use, but I'll make a separate issue for it so we can keep focused on this immediate patch.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    After applying patch to my local system and updating phpunit.xml to include:

    " "

    all the tests and all assertions ran successfully. This is on 10.0.7. With a temporary hand patched info.yml to allow the module to run under 10.

    This is just an enormous enormous improvement due to the patch and a few other adjustments.

    I'm going to focus on looking at PHPstan and getting PHPCS running properly so we can validate the code changes as they are completed. I think there is some "technical debt" due to several years of inactivity. PHPSTAN suggest a whole bunch of fixes ... not sure how literally we should take them.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Hey Frank.

    I think at this point, it'd be safest to cut 4.x and 4.0.x branches, create a 4.0.x-dev release, change the version of this issue to target 4.0.x, re-run testing, and ultimately merge this into 4.0.x (and subsequently 4.x).

    At that point, we can safely cut a 4.0.0-alpha1 release that supports ^9.3 | ^10.

    I have a window tomorrow morning to do some of this "administrative" git work and get green tests running against 4.0.x, but for now it's family o'clock :-).

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Enjoy Family O'clock.

    I wonder at some point if we could run the tests and see the results without:

    "09:03:09 sudo -u www-data mkdir -p cd ${SOURCE_DIR}/libraries && cd ${SOURCE_DIR}/libraries && sudo -u www-data curl -L https://github.com/maxstrim/juicebox/archive/refs/tags/1.5.1.tar.gz --output 1.5.1.tar.gz && sudo -u www-data tar -zxf 1.5.1.tar.gz && mv juicebox-1.5.1 juicebox"

    What I'm wondering is whether by having the correct modules loaded in the test programs, we might in effect be accomplishing the same thing as getting the maxstrim programs ... the juicebox javascript .. off the Internet and loading them in the container.

    That is the only way I can explain why the test programs would work on PHPstorm. I think you made a LOT of corrections in the first patch file that worked ... especially in the USE statements at the tops of the programs and that the rest of the code did not have a chance of working without having that done. Last week I had one of the test programs (I honestly forget which) that was failing and when I added some additional modules in:

      protected static $modules = [
        'node',
        'text',
        'field',
        'image',
        'editor',
        'juicebox',
        'views',
        'contextual',
        'juicebox_mimic_article',
        'juicebox_test_views',
      ];
    

    All of a sudden the tests and assertions passed. I believe it's the juicebox module itself that loads the javascript.

    I will have to study the intricacies of version naming. I haven't done much testing on my 10.0.7 system running Juicebox 8-x-3.x with a modified info.yml. I am seeing some log messages such as:

    Location	http://ndrupal/web/contextual/render
    Referrer	http://ndrupal/web/admin/reports
    Message	Error: Call to undefined method Drupal\Core\Config\Entity\ConfigEntityType::isSubclassOf() in Drupal\juicebox\Plugin\Derivative\JuiceboxConfFieldContextualLinks->getDerivativeDefinitions() (line 62 of D:\webpage\compg\web\modules\contrib\juicebox\src\Plugin\Derivative\JuiceboxConfFieldContextualLinks.php

    but I realize we need to be more systematic about tracking these down.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    re #32 - it looks like isSubclassOf was removed in Drupal 10 ([#2842808]). Seems easy enough to fix, just change isSubclassOf to entityClassImplements.

    Now targeting 4.0.x and uploaded a new patch/interdiff that resolves #32.

    Let's see how the test runner fares against the new automated test configuration for 4.0.x, fingers crossed!

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    Sure enough, it now looks like we now have our contextual links back in D9 + D10.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    I'm going to commit #34 to 4.0.x.

    Since this is a new branch, merging this will do no harm to existing 8.x-3.x users and it'll open us up to making smaller, more controlled and incremental changes. Smaller the scope, smaller the risk :-)

  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania
  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    I modified the patch relating to JuiceBoxFieldContextualLinks.php so the patched function reads:

      public function getDerivativeDefinitions($base_plugin_definition) {
        // We need a contextual link defined for each entity type (that may contain
        // a Juicebox gallery) in order to provide a link to the relevant edit
        // display screen. These link definitions must be unique because the related
        // route to the edit display screen is different for each entity type.
        foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
          // Only fieldable entity are candidates.
          if ($entity_type->entityClassImplements('\Drupal\Core\Entity\ContentEntityInterface'))  {
            $this->derivatives['juicebox.conf_field_' . $entity_type_id]['title'] = $this->t('Configure galleries of this field instance');
            $this->derivatives['juicebox.conf_field_' . $entity_type_id]['route_name'] = 'entity.entity_view_display.' . $entity_type_id . '.view_mode';
            $this->derivatives['juicebox.conf_field_' . $entity_type_id]['group'] = 'juicebox_conf_field_' . $entity_type_id;
      }
         }
        return parent::getDerivativeDefinitions($base_plugin_definition);
      }

    eliminating what seems to be an unused variable.

    I have been spelunking around my Wampserver local test 10.0.7 system for a half hour trying as much Juicebox stuff as I can. Not seeing any errors kick off ... though I do see "curl" related errors due to Wampserver not having the right certificates set up. Addressing that is no a priority right now.

    Time to do some file comparisons between 4.0.x-dev and my local juicebox code so we can be on synchronized wave lengths and I can contribute patches according to Drupal git guidelines. I don't know how to test for contextual links. I will have to spelunk around to even see what they are.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Did file comparison yesterday and it looks like we have things pretty well in synch. between 4.0.x-dev and what I've been testing (and have running) locally on Drupal 10. I got bogged down with my local git, unfortunately.

    I noticed that:

    protected $defaultTheme = 'stark';

    is only in the JuiceBoxTestCase program in the tests directory. I read up on a couple of issue queue discussions as well as the documentation and looked at tests in some of the core modules as well as the devel module. It's not clear to me whether we need it in all the programs or not. Devel leaves it out in some cases. The core file module includes it in all. @Luke knows better than I whether it is needed.

    At the bottom of JuiceBoxCaseTestBase we have " return $this->drupalPost('contextual/render', 'application/json', $post, ['query' => ['destination' => $current_path]]);" where I believe drupalPost is deprecated and we may need submitForm.

    On an unrelated note, I was reading through the Project page. That's going to need some loving. We still reference the need to get the separate libraries module. This is true prior to 8.3 but no longer is applicable. All library discovery is done right in Juicebox now and will stay that way in Drupal 10.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024