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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Project Update Bot created an issue. See original summary.

project update bot’s picture

Status: Active » Needs review
StatusFileSize
new1.21 KB

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

project update bot’s picture

Version: 8.x-1.5 » 8.x-1.x-dev
StatusFileSize
new0 bytes
new1.21 KB
new1.57 KB

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

Balu Ertl made their first commit to this issue’s fork.

Balu Ertl changed the visibility of the branch project-update-bot-only to hidden.

baluertl’s picture

Issue summary: View changes

Based on the answers on this Slack thread, I have the conclusion that it's not strictly necessary to rely on the DeprecationHelper::backwardsCompatibleCall() utility. I assume the module maintainers probably still plan to continue supporting D9, in which this deprecation handling solution was not present yet and thus would have no effect anyway.

Although the change record about the deprecation of watchdog_exception() suggests using \Drupal\Core\Utility\Error::logException() but for me, it still seems to be just another wrapper around the \Drupal\Core\Logger\LoggerChannel::log().

Therefore I simplified exception logging with a more informative solution I peeked from core's \Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber::makeSubrequest().

baluertl’s picture

StatusFileSize
new55.96 KB

Reviewed and tested (module install, configuring, trying out, uninstalling) on a D11-beta1 site, found working as expected:

Screenshot

project update bot’s picture

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.3, 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-199781

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.3
japerry’s picture

Issue summary: View changes
Status: Needs review » Needs work

The tests are failing in head, but its possible thats due to current incompatibilities, which would be made worse with D11 support. Those should get fixed before this gets committed.

baluertl’s picture

Status: Needs work » Postponed
Related issues: +#3415080: Fix functional javascript tests for entity_embed / ckeditor4

I believe the MR of #3415080: Fix functional javascript tests for entity_embed / ckeditor4 should be included first before we move forward with this one.

baluertl’s picture

Status: Postponed » Needs review
StatusFileSize
new10.64 KB

Drupal Rector still suggests one point to fix:

Screenshot

As discussed today with @japerry, we agreed this could be ignored because there is a @todo comment above the line communicating this should be fixed eventually in the future. So setting ticket status back to Needs Review.

Also, as he suggested the following open tickets should be resolved before we focus on D11 compatibility:

13 #3410132: Entity embed dialog can no longer use custom data- attributes in CKEditor 5

8 #3295818: TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given

5 #3416512: Trying to edit embedded entities causes uncaught exception

4 #3402443: PHP error: Call to a member function id() on null

3 #3402255: Button label double-escaped in CKEditor5

2 #3362388: PHP 8.2 Deprecation: Creation dynamic property

1 #3450460: Warning: Array to string conversion in entity_embed/src/Form/EntityEmbedDialog.php on line 839

(In order of ticket subscribers.)

project update bot’s picture

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.3, 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-223311

These packages were used to generate the fixes:

  1. drupal/upgrade_status: 4.3.4
  2. mglaman/phpstan-drupal: 1.2.11
  3. palantirnet/drupal-rector: 0.20.3

Balu Ertl changed the visibility of the branch 8.x-1.x to hidden.

ukor’s picture

Issue summary: View changes
StatusFileSize
new7.67 KB

Version entity_embed 8.x-1.6
Patch including rector's fixes from entity_embed.1.x-dev.rector.patch and info.yml file fix.

baluertl’s picture

@ukor thanks for contributing code. This issue already has an open merge request. Would you mind committing the content of your patch file onto the feature branch of this issue repository, please? This would make this issue solved earlier by easing the module maintainer's job of reviewing changes. Thanks in advance!

evgen’s picture

Could not apply patch MR 36.

ankitv18 made their first commit to this issue’s fork.

abhinavk made their first commit to this issue’s fork.

ankitv18 changed the visibility of the branch 3430164-d11_ready to hidden.

ankitv18’s picture

ok4p1’s picture

I get the following error after trying to use the latest MR. Drupal 10.3.8.

Error: Call to undefined method Drupal\embed\EmbedType\EmbedTypeBase::create() in Drupal\entity_embed\Plugin\EmbedType\Entity::create() (line 56 of modules/contrib/entity_embed/src/Plugin/EmbedType/Entity.php).

rahul17’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new188.96 KB
new181.46 KB
new1.22 MB
new268.45 KB

Tested MR !47 changes in Drupal 10.3 and Drupal 11, functionality is working fine for me.
Changing status to RTBC.

ankitv18 changed the visibility of the branch 3430164-automated-drupal-11 to hidden.

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs review

#27 is concerning and suggests that there may have been a backwards compatibility break here - can we look into that, please?

heddn’s picture

Status: Needs review » Postponed

embed.module support for D11 got rolled back. We'll need to wait on https://www.drupal.org/project/embed/issues/3430097 to land first. I'm way down the line in https://www.drupal.org/project/media_migration/issues/3431903 waiting for this to land. So hopefully the upstream issues land soonish.

ok4p1’s picture

Hello, you can disregard my previous message. I realized that I wasn’t using the latest D11 patch from the embed module. Once I updated it, the error disappeared, and I have been using the patch from this ticket in production since then, with no issues.

anybody’s picture

Title: Automated Drupal 11 compatibility fixes for entity_embed » [PP-1] Automated Drupal 11 compatibility fixes for entity_embed

See #31

joseph.olstad’s picture

Priority: Normal » Major

I've reviewed the blocker. It's ready to go imho. Action is needed by a maintainer.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

This is testing against 8.x-1.8 which is the D11 compatible release that was rolled back.

#3430097: Automated Drupal 11 compatibility fixes for embed now has a minimal MR that does not include the addition of EmbedTypeBase::create meaning we can't call parent::create. This looks like the MR that will eventually be committed.

We need to figure out how to run tests against a patched version of embed 8.x-1.9 using that MR.

rajab natshah’s picture

Priority: Major » Critical
joseph.olstad’s picture

the MR for embed was merged however we're still waiting for a tagged release.

phenaproxima’s picture

Title: [PP-1] Automated Drupal 11 compatibility fixes for entity_embed » Automated Drupal 11 compatibility fixes for entity_embed
Status: Postponed » Active

Done.

phenaproxima’s picture

Status: Active » Needs work

This needs significant work; I'm seeing many changes that appear to be unrelated to Drupal 11 compatibility. For reference:

  • Let's deprecate CKEditor 4 support, but not remove it.
  • Let's not add any new code or do any refactoring beyond what's needed for Drupal 11 compatibility.

Godspeed!

joseph.olstad’s picture

ck4 tests won't pass in D11

phenaproxima’s picture

Then add something like this to them in setUp():

if (version_compare(\Drupal::VERSION, 10, '>')) {
  $this->markTestSkipped('This test will not run on Drupal 11 because CKEditor 4 is no longer supported.');
}
joseph.olstad’s picture

Merging to a new branch and dropping ^10, changing core requirements to ^11 only would prevent D10 folks from installing the D11 release and getting stuck on missing ck4 support and would allow future D10 releases that support both while the D11 branch supports only D11+ck5.

acbramley’s picture

Status: Needs work » Needs review

I believe everything is actioned, and the pipeline's green.

znerol’s picture

It looks like changes in JavaScript source files have been reverted. I think that js/build/drupalentity.js should be reverted as well.

znerol’s picture

On the general approach: I think it is quite risky to attempt to convert all tests from cke4 to cke5 in this issue. It looks like some people are thinking that it is impossible to run cke4 tests in D11. Luckily this is not true, i.e., it is in fact possible to run tests against cke4 in D11.

In order to do that, the following is needed:

  • Specify _LENIENT_ALLOW_LIST: "ckeditor" in .gitlab-ci.yml
  • Add a before_script which unconditionally patches all contrib modules so as to make them installable in the current core version.

An example of this approach can be found in .gitlab-ci.yml of Entity Browser which has had D11 releases for weeks even though embed and entity embed were still lacking D11 support.

I propose to try this here as well.

joseph.olstad’s picture

@znerol , changes were made also to core in D11 relating to the editor module and ck4 (code removal). I wanted to run ck4 in D11 but I saw the core changes and decided to switch to ck5 (for better or for worse) due to the core and contrib complexity and risks involved and the fact that ck4 might be dropped from contrib also. So even if I was to fork ckeditor and upgrade it to D11, I asked myself what the likelihood that ck4 was still intact in contrib and decided that it was a pretty risky adventure to embark on. It has been a bit tricky however so far we've got ck5 working ok although we did have to sacrifice some functionality like html filtering (due to overhauls that I still do not understand) and one contrib modules widget does not exist in ck5 that we'll migrate to another at some point.

rajab natshah’s picture

Hoping for a tag release soon to simplify and accelerate testing and updates in projects.
A new 2.0.x branch dedicated to CKE5-only support could be helpful, while maintaining minimal support for CKE4 in the 8.x-1.x branch.

joseph.olstad’s picture

@rajab natshah , I 100% agree with your comment in #48

Enough with the dipsy doodling, for those ACTUALLY using Drupal 11 and adopting it, only ckeditor 5 makes sense. Forget ck4 in Drupal 11, it's a non-starter.

znerol’s picture

Assigned: Unassigned » znerol

Working on the tests in order to minimize the amount of coverage loss.

znerol’s picture

Assigned: znerol » Unassigned

This is good to go. There is one weird test fail in phpunit (previous minor). I'd probably just ignore it for the moment.

This module needs a big effort to increase functional JavaScript test coverage for CKEditor5. I wouldn't attempt to convert the existing tests. Just write new ones for the new editor and leave the old ones there for reference until CKE4 support is removed completely. That work needs to happen in another issue though.

joseph.olstad’s picture

Great job, thank you very much!

To resolve the test issue, just adjust the core requirements:

^10.4 || ^11.1

There's no need to support 10.3 for much longer anyway.

Tests are currently passing on 10.4 and 11.1.1

znerol’s picture

Removed OPT_IN_TEST_PREVIOUS_MINOR from .gitlab-ci.yml.

acbramley’s picture

There's no need to support 10.3 for much longer anyway.

Security support is for another 4 months, there's no harm in keeping it here.

phenaproxima’s picture

Status: Needs review » Needs work

A few questions on the MR, which I've left comments for.

My main concern here is that most of the CI jobs are actually failing: https://git.drupalcode.org/issue/entity_embed-3430164/-/pipelines/410987. Too many for comfort.

The ones I'm most concerned about are:

  • phpunit (next minor) and phpunit (max PHP version) -- if we're aiming for D11 compatibility, neither of these should be failing. I'd like these to be fully green in order to merge this.
  • All of the PHPStan jobs. I usually dislike PHPStan because it has a tendency to treat harmless quirks as errors, but in this case it looks like it is catching what might be legitimate bugs; see https://git.drupalcode.org/issue/entity_embed-3430164/-/jobs/4198055#L84, https://git.drupalcode.org/issue/entity_embed-3430164/-/jobs/4198055#L84, and several others. We should fix as many of these as possible, and things that can't be fixed (maybe due to implementing interfaces that only exist in CKEditor 4) should be suppressed explicitly, with comments explaining why.

The other stuff would be fine to fix in follow-ups.

joseph.olstad’s picture

@phenaproxima , next minor and next major have not been released yet. It is completely normal that they could be failing at this point in time. We should focus on 10.4 and 11.1 ambitiously 10.3 and 11.0.

znerol’s picture

Assigned: Unassigned » znerol
berdir’s picture

I was considering to suggest to disable those jobs earlier, especially php max (which is PHP 8.4 now), but yeah, they are definitely not in scope of this issue.

About phpstan, anything that isn't clearly a D11 thing should IMHO also be ignored here. For one I opened an issue because that's IMHO not correct: https://github.com/mglaman/phpstan-drupal/issues/824.

znerol’s picture

So, the test fail in phpunit (next minor) is in fact really interesting. MediaImageDecorator::build() attempts to pass the alt and title attribute values into the referenced entity image / thumbnail.

This worked well until #3489179: Referring the same entity multiple times breaks _referringItem fixed a corner case by introducing a clone $entity which is triggered during parent::build(). As a result, $build['#media'] and $this->decorated->getEntityFromContext(); are not referring to the same object anymore. Modifications to the latter do not have any effect anymore.

When I revert core commit 40c1ab52 tests are passing.

znerol’s picture

Assigned: znerol » Unassigned
Status: Needs work » Needs review

Found a way to refresh the entity context value.

joseph.olstad’s picture

Great sleuthing on the next minor fix @znerol ! that core commit happened only about 9 days ago

znerol’s picture

Assigned: Unassigned » znerol

Looking at failing phpunit (max PHP version) now.

A lot of noise is due to one line in EntityEmbedDialog.php, lets get rid of that:

    Deprecated: Drupal\entity_embed\Form\EntityEmbedDialog::buildForm(): Implicitly marking parameter $editor as nullable is deprecated, the explicit nullable type must be used instead in /builds/issue/entity_embed-3430164/src/Form/EntityEmbedDialog.php on line 183
    
    Deprecated: Drupal\entity_embed\Form\EntityEmbedDialog::buildForm(): Implicitly marking parameter $embed_button as nullable is deprecated, the explicit nullable type must be used instead in /builds/issue/entity_embed-3430164/src/Form/EntityEmbedDialog.php on line 183
znerol’s picture

Assigned: znerol » Unassigned

Looks like phpunit (max PHP version) was failing because of PHP8.4 deprecations around implicit nullable type hints. All phpunit jobs are green now.

znerol’s picture

Fixed the phpstan jobs as well. The phpstan.neon config is based on the official drupal ci template.

Additionally it ignores CKEditor 4 plugin paths. I also added a phpstan baseline in order to suppress the following non-D11 related isues:

  1. \Drupal calls should be avoided in classes, use dependency injection instead
  2. config:entity_view_mode_list cache tag might be unclear and does not contain the cache key in it. (see #58.
znerol’s picture

Note that EntityEmbedHooksTest randomly fails in any of the phpstan jobs. This is most probably due to its reliance on state to activate the hook in the test module (see #3496257: Race conditions in CacheCollector/State (again)).

phenaproxima’s picture

Status: Needs review » Needs work

Thanks for this effort @znerol! And thanks for explaining some of the test changes.

I think I'm mostly okay with this, but we probably shouldn't change parameter types in base classes (I'm okay with it in forms -- those shouldn't be subclassed anyway) since that would violate PHP's contravariance rules, IIRC. I know that restoring them would cause some deprecation notices but if it's just those, I think that's worthwhile in order to not break this module for people who might have subclassed it.

berdir’s picture

Status: Needs work » Needs review

Adding ? is not a type change, it's fine to add this.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

OK, I took a look at the original PHP 7.1 RFC for nullable types: https://wiki.php.net/rfc/nullable_types, and I think you're probably right. Quoting:

Because a parameter with = null is a superset of ?, you can use a parameter with a default value of null where a nullable type existed in the parent.

interface Contract {
    function method(?Foo $foo): bool;
}
 
class Implementation implements Contract {
    function method(?Foo $foo = null): bool {
        return is_null($foo);
    }
}

The reverse is not true, however: you cannot use only a nullable type where a default value existed in the parent, because the parameter is no longer optional.

If I understand this correctly, ?Type = NULL (which is what will be in the parent) and Type = NULL (which is what will be in any subclasses) are considered compatible by PHP, since either one could be NULL.

Proof (thanks @berdir): https://3v4l.org/Shl6Y

So okay...I think that addresses my concerns. Let's ship it.

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Merged into 8.x-1.x and will tag shortly. Thanks, everyone.

acbramley’s picture

Great work everyone 💪

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.