Automated Drupal 11 compatibility fixes for jsonapi_schema

Created on 18 March 2024, about 1 year 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 on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Waiting for branch to 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 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, 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 on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Waiting for branch to pass
  • Status changed to RTBC 5 months ago
  • 🇩🇪Germany onfire84

    Patch worked for me on a Drupal 10.3.6 site. Setting to RTBC.

  • 🇺🇸United States m.stenta

    I wonder if we can get this merged, and tag a "stable" 1.0? The last release was made 16 month ago. I know there's a lot of interesting things happening in core for Drupal 11 (see Introduce "schematic" normalizers Active ) but it seems that there is still some followup work necessary, and this module is still needed right now for users moving to Drupal 11. It is currently a blocker for farmOS: 🌱 Update Drupal core to 11.x in farmOS Active

  • 🇫🇮Finland Alexander Tallqvist

    Patch seems to be working for me on a Drupal 10.3.14 site.

  • 🇺🇸United States m.stenta

    Thanks for testing @onfire84 and @alexander-tallqvist.

    Let's get confirmation that this works on Drupal 11. Setting back to Needs Review.

  • 🇺🇸United States m.stenta

    I tested installing on Drupal 11.1.5 and it failed with the following error:

    $ drush en jsonapi_schema
    
    Fatal error: Declaration of Drupal\jsonapi_schema\Normalizer\DataDefinitionNormalizer::normalize($entity, $format = null, array $context = []) must be compatible with Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize(mixed $data, ?string $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null in /opt/repos/jsonapi_schema/src/Normalizer/DataDefinitionNormalizer.php on line 53
     [warning] Drush command terminated abnormally.
    

    I had to fix this in farmOS as well, so I'm familiar with the solution. I'll work on this...

  • 🇫🇮Finland Alexander Tallqvist

    @m.stena Probably related to this: https://www.drupal.org/project/jsonapi_schema/issues/3504440 🐛 PHP8.3 compatibility issues Active

  • 🇺🇸United States m.stenta

    Fatal error: Declaration of Drupal\jsonapi_schema\Normalizer\DataDefinitionNormalizer::normalize($entity, $format = null, array $context = []) must be compatible with Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize(mixed $data, ?string $format = null, array $context = [])

    I think fixing this is going to necessitate dropping support for Drupal 10.

    @bradjones1: I see that you have started a 2.x (and 2.0.x) branch that makes some of these changes already. Should I base a MR off of one of those? I can't find any mention of them in the issue queue, and there are a number of other changes. Any guidance you can provide on your intentions would be appreciated! I want to help push this forward, but don't want to step on toes or duplicate efforts.

  • 🇺🇸United States m.stenta

    @m.stena Probably related to this: https://www.drupal.org/project/jsonapi_schema/issues/3504440 🐛 PHP8.3 compatibility issues Active

    Thanks @alexander-tallqvist!

    This error is actually a result of changes in the upstream Symfony class that we extend from. So I don't think it's specific to PHP 8.3.

    We can probably close 🐛 PHP8.3 compatibility issues Active as a duplicate of this issue, and incorporate the MR changes into here. I'll start a new MR and cherry-pick them over.

  • Merge request !13Drupal 11 → (Open) created by m.stenta
  • 🇺🇸United States m.stenta

    Opened a merge request with @volha_si's commit from 🐛 PHP8.3 compatibility issues Active (I updated the commit message to be more descriptive of its purpose, but kept the author credit).

    I also added a commit that drops support for Drupal 8, 9, and 10. So this will need to be a new major release (not on the 8.x-1.x branch) - pending @bradjones1's response to my question above (#10).

    I will do more testing locally and report back if I find any other issues.

  • 🇺🇸United States m.stenta

    Not working yet...

    I tried to view a schema endpoint (/api/[entity-type]/[bundle]/resource/schema) in my browser and the following error occurs:

    Uncaught PHP Exception Symfony\\Component\\Serializer\\Exception\\NotNormalizableValueException: "Could not normalize object of type "Drupal\\Core\\Field\\BaseFieldDefinition", no supporting normalizer found." at /opt/drupal/vendor/symfony/serializer/Serializer.php line 181
    
  • 🇺🇸United States m.stenta

    The root /api/schema endpoint and collection endpoints (/api/[entity-type]/[bundle]/collection/schema) seem to be working.

  • 🇺🇸United States m.stenta

    Pushed a commit that fixes the /api/[entity-type]/[bundle]/resource/schema routes.

    This Drupal core change record describes the change that was necessary: https://www.drupal.org/node/3359695

    Back to Needs Review!

  • 🇫🇮Finland Alexander Tallqvist

    Tested MR!13 on a fresh Drupal site running 11.1.5. The schemas at /api/[entity-type]/[bundle]/resource/schema seem to be working fine, and the implemented changes are in line with change records at https://www.drupal.org/node/3359695 . Everything looks good to me! Setting to RTBTC.

Production build 0.71.5 2024