Automated Drupal 10 compatibility fixes

Created on 18 July 2022, over 2 years ago
Updated 29 May 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 โ†’

Periodically patches will be added to this issue that remove Drupal 10 deprecated API uses. To stop further patches from being posted simply close this issue (any status besides Active, Needs review or Needs work) or remove the "ProjectUpdateBotD10" tag from the issue.

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 or Needs work) 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.

  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 don't want new automated patches simply leave this issue open but remove the "ProjectUpdateBotD10" tag from the issue.

    You can use Drupal Rector yourself to make these patches.

    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 or Needs work) 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 may be useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the patch in the comment by Project Update Bot โ†’ .
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.

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 Infrastructure project issue queue โ†’ using the component โ€œBot: Drupal Rectorโ€.

๐Ÿ“Œ Task
Status

Needs work

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 rishi kulshreshtha

    Further improvement is required as I can still see errors even after implementing the most recent patch.

    ================================================================================
    Field Collection, --
    Scanned on Mon, 05/29/2023 - 13:36
    
    FILE: modules/contrib/field_collection/src/Entity/FieldCollectionItem.php
    
    STATUS         LINE                           MESSAGE                           
    --------------------------------------------------------------------------------
    Check manually 294  Relying on entity queries to check access by default is     
                        deprecated in drupal:9.2.0 and an error will be thrown from 
                        drupal:10.0.0. Call                                         
                        \Drupal\Core\Entity\Query\QueryInterface::accessCheck() with
                        TRUE or FALSE to specify whether access should be checked.  
    --------------------------------------------------------------------------------
    
    FILE:
    modules/contrib/field_collection/tests/src/FunctionalJavascript/FieldCollectionA
    jaxTest.php
    
    STATUS         LINE                           MESSAGE                           
    --------------------------------------------------------------------------------
    Check manually 15   Drupal\Tests\BrowserTestBase::$defaultTheme is required. See
                        https://www.drupal.org/node/3083055, which includes         
                        recommendations on which theme to use.                      
    --------------------------------------------------------------------------------
    
    FILE: modules/contrib/field_collection/field_collection.info.yml
    
    STATUS         LINE                           MESSAGE                           
    --------------------------------------------------------------------------------
    Check manually 0    Value of core_version_requirement: ^8 || ^9 is not          
                        compatible with the next major version of Drupal core. See  
                        https://drupal.org/node/3070687.                            
    --------------------------------------------------------------------------------
    
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rishi kulshreshtha
  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Bushra Shaikh

    I have reviewed and checked the patch #7 this works for drupal 9.5 and drupal 10.0. and 10.0.1
    Screenshots of the compatibility on 9.5 have been attached for reference:

  • @arti_parmar opened merge request.
  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark blymemikkel Copenhagen

    blyme โ†’ made their first commit to this issueโ€™s fork.

  • Added

    -  public function normalize($field_item, $format = NULL, array $context = []) {
    +  public function normalize($field_item, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    
  • ๐Ÿ‡ท๐Ÿ‡ดRomania sethy

    Hello,

    We have a situation for one of the sites of our clients. The current version of Drupal for the site is 9.5.8 and we have installed:
    - Field collection (version 8.x-1.0-alpha1)
    - Field Collection Views (version 8.x-5.0)

    Most of the content of the site is depending on these modules and rewriting the code of the site is not a solution for us at the current time because we are talking about 3-5 weeks of development.

    We would like to update the site's Drupal version to 10.x and we need your help if we can do it or how to do it.

    Please let us know if you require additional information, thanks!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Tom M Fallon

    I've noticed the following issue.

    > [notice] Update started: block_content_post_update_sort_permissions
    > [13-Oct-2023 08:55:50 UTC] PHP Fatal error: Declaration of Drupal\field_collection\Normalizer\FieldCollectionItemNormalizer::normalize($field_item, $format = null, array $context = []) must be compatible with Drupal\serialization\Normalizer\ComplexDataNormalizer::normalize($object, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null in /var/www/html/docroot/modules/contrib/field_collection/src/Normalizer/FieldCollectionItemNormalizer.php on line 23
    > [warning] Drush command terminated abnormally.

    I suspect it is similar to https://www.drupal.org/project/dynamic_entity_reference/issues/3350347 ๐Ÿ› Declaration of DynamicEntityReferenceItemNormalizer::normalize() must be compatible Needs review

    Setting back to needs work. I'm likely to patch this.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Tom M Fallon
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Tom M Fallon

    Apologies entierly in error. This has already been fixed but I hadn't properly read the above comments. Knocking pack to reviewed & tested as it works.

    Sorry again!

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Tom M Fallon
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia radheymkumar Jaipur, Rajasthan, India

    Hi
    I have tested this patch is working with drupal 10
    Thanks

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany jan kellermann

    Thank you for your work. This version works for us.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    Can not apply #11 because of info.yml is patched for core version requirements (4.0.x-dev requires D9 is patched for D10)
    See @ https://www.drupal.org/project/drupalorg/issues/3066468 ๐Ÿ“Œ Packaging info from .info.yml often creates conflicts when patching (ddo) Active
    Is there any other option than manual patching ?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom RogerB Greenwich, London

    @erwangel

    I managed to get composer to install drupal/field_collection": "dev-4.0.x with patch #17.

    First I added an explicit requirement for drupal/core 10.1.6 aliased as 9.5.11 to the required section of composer.json.

        "require": {
            ...
            "drupal/core": "10.1.6 as 9.5.11",
            "drupal/core-composer-scaffold": "^10.0.0",
            "drupal/core-recommended": "^10.0.0",
            ...
         }
    

    ... and then ran composer update drupal/core.

    Then I added the patch to my composer.json:

        "extra": {
            ...
            "patchLevel": {
                "drupal/core": "-p2"
            },
            "enable-patching": true,
            "patches": {
                "drupal/field_collection": {
                    "3297187 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2023-10-25/field_collection_for_drupal10.patch"
                }
            }
        }
    

    Then ran composer require 'drupal/field_collection:dev-4.0.x'.

    Puzzled over this for a couple of days. Not a well documented solution to the problem of installing D9 modules patched for D10.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    Thank you RogerB for your quick answer. However I still have a problem reported by composer

    - Root composer.json requires drupal/field_collection dev-4.0.x -> satisfiable by drupal/field_collection[dev-4.0.x].
    - drupal/field_collection dev-4.0.x requires drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but it conflicts with your root composer.json require (10.1.6 as 9.5.11).

    My question is
    1 - should I try it with the option --with-all-dependencies, and in such case is there any risk to import update dependencies to D9.5.11 for other parts/modules that are properly running as D10 compatible ?
    2- do I have to remove the line "drupal/core": "10.1.6 as 9.5.11" after installation in order to avoid other modules being downloaded with a D9 version ?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom RogerB Greenwich, London

    @erwangel

    When I developed my fix described in #20 ๐Ÿ“Œ Automated Drupal 10 compatibility fixes RTBC comment #18 had not been posted.

    Using mglaman/composer-drupal-lenient is a much better solution than aliasing the core version. You can target only the package for which you want composer to ignore the core version constraints. This also addresses the concerns you expressed above.

    I have tested this and if works fine with patch at #11 ๐Ÿ“Œ Automated Drupal 10 compatibility fixes RTBC . The patch at #17 does not actually patch the module's info file for D10!

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    I couldn't install it event with #11 + mglaman/composer-drupal-lenient. "composer.json" was correctly updated with the composer config --merge --json extra.drupal-lenient.allowed-list '["field_collection"]' instruction but the composer require gave the following error:

    Problem 1
    - drupal/field_collection dev-4.0.x requires drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.1.6 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - drupal/field_collection 4.0.x-dev is an alias of drupal/field_collection dev-4.0.x and thus requires it to be installed too.
    - Root composer.json requires drupal/field_collection 4.0.x-dev@dev -> satisfiable by drupal/field_collection[4.0.x-dev (alias of dev-4.0.x)].

    I then tried to remove composer.lock and install mglaman/composer-drupal-lenient globally as indicated on its page but this doesn't seem to be the road as it gave a huge list of require incompatibilities. I finally ported the patch modifications manually and installed the module without composer.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine _shy Ukraine, Lutsk ๐Ÿ‡บ๐Ÿ‡ฆ

    Hi @erwangel

    Please, check if you allowed a lenient plugin in composer.json file.

    It could be done with the following command:
    composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine pingwin4eg Zaporizhia ๐Ÿ‡บ๐Ÿ‡ฆ

    @radheymkumar What's the purpose of the patch you uploaded? If I understand correctly, there are only changes to field_collection.api.php and tests (from the patch #11).

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    Hi @_shY,
    Still no chance, with your command composer.json was indeed update to allow lenient but still compatibility errors:

    Problem 1
    - Root composer.json requires drupal/field_collection dev-4.0.x -> satisfiable by drupal/field_collection[dev-4.0.x].
    - drupal/field_collection dev-4.0.x requires drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.1.7 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

    In my composer I have :

     "require": {
            "mglaman/composer-drupal-lenient": "^1.0"
           ...
      },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "config": {
            "allow-plugins": {
                "mglaman/composer-drupal-lenient": true
                ...
            },
        },
        "extra": {
            "patchLevel": {
                "drupal/core": "-p2"
            },
            "patches": {
                 "drupal/field_collection": {
                    "3297187-11 - Automated Drupal 10 compatibility fixes": "https://www.drupal.org/files/issues/2023-09-13/field_>
                }
            },
            "drupal-lenient": {
                "allowed-list": ["field_collection"]
            }
        }
    ...

    Well, this is no more a real problem as I could proceed with a manual patching and installation but just trying to understand why lenient is not working to do it the composer way...

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine _shy Ukraine, Lutsk ๐Ÿ‡บ๐Ÿ‡ฆ

    @erwangel

    Two more things that I want to check about your situation.

    1. I hope you apply patch from the comment #11 ๐Ÿ“Œ Automated Drupal 10 compatibility fixes RTBC .

    2. You need to change the allowed list setting. It should be drupal/field_collection. Like this one:

            "drupal-lenient": {
                "allowed-list": ["drupal/field_collection"]
            }
    
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    @_shY,
    1. yes, it is patch from #11
    2. As you can see below, it works after your correction! ["drupal/field_collection"] not ["field_collection"]

    From the composer require print out:

    - Installing drupal/field_collection (dev-4.0.x 81ea688): Cloning 81ea6884dc from cache
    - Applying patches for drupal/field_collection
    https://www.drupal.org/files/issues/2023-09-13/field_collection-3297187-... โ†’ (3297187-11 - Automated Drupal 10 compatibility fixes)

    Thanks @_shY and @RogerB for all your guidance!!!

  • I get an error with patch from #11
    an accessCheck is missing in field_collection_field_storage_config_delete

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drupalfan2

    Patch #11 helped me to get this module work with Drupal 10.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine ankondrat4 Lutsk

    +1 RTBC for MR6.
    It works as expected on Drupal 10.

  • First commit to issue fork.
  • Merge request !10Drupal 10 readiness โ†’ (Open) created by Kartagis
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany jan kellermann

    In D10.2 was with #1038316 โ†’ a new "Removed" button introduced which destroys the field collection widget. There is no change record for this change.

    The main problem seems a naming collision, I changed the name of remove-button.

    The issue #3421903 โ†’ has the same problem with two buttons and i adapted the patch.

    I added also the missing accessCheck from comment #29.

    I added these changes to the patch #11.

Production build 0.71.5 2024