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:
- 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.
- 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.
- 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
- Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
- Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
- Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.
Using the merge request
- Review the merge request and test it.
- Thoroughly test the changes. These changes are automatically generated so they haven't been tested manually or automatically.
- 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.
Issue fork entity_embed-3430164
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
Comment #2
project update bot commentedThis 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.ymlfile 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
This patch was created using these packages:
Comment #4
project update bot commentedThis 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.ymlfile 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
These packages were used to generate the fixes:
Comment #8
baluertlBased 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().Comment #9
baluertlReviewed and tested (module install, configuring, trying out, uninstalling) on a D11-beta1 site, found working as expected:
Comment #10
project update bot commentedThis 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.ymlfile 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
These packages were used to generate the fixes:
Comment #11
japerryThe 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.
Comment #12
baluertlI believe the MR of #3415080: Fix functional javascript tests for entity_embed / ckeditor4 should be included first before we move forward with this one.
Comment #13
baluertlDrupal Rector still suggests one point to fix:
As discussed today with @japerry, we agreed this could be ignored because there is a
@todocomment 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.)
Comment #14
project update bot commentedThis 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.ymlfile 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
These packages were used to generate the fixes:
Comment #16
ukor commentedVersion entity_embed 8.x-1.6
Patch including rector's fixes from
entity_embed.1.x-dev.rector.patchandinfo.ymlfile fix.Comment #17
baluertl@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!
Comment #18
evgen commentedCould not apply patch MR 36.
Comment #26
ankitv18 commentedComment #27
ok4p1 commentedI 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).
Comment #28
rahul17 commentedTested MR !47 changes in Drupal 10.3 and Drupal 11, functionality is working fine for me.
Changing status to RTBC.
Comment #30
phenaproxima#27 is concerning and suggests that there may have been a backwards compatibility break here - can we look into that, please?
Comment #31
heddnembed.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.
Comment #32
ok4p1 commentedHello, 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.
Comment #33
anybodySee #31
Comment #34
joseph.olstadI've reviewed the blocker. It's ready to go imho. Action is needed by a maintainer.
Comment #36
acbramley commentedThis 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.
Comment #37
rajab natshahComment #38
joseph.olstadthe MR for embed was merged however we're still waiting for a tagged release.
Comment #39
phenaproximaDone.
Comment #40
phenaproximaThis needs significant work; I'm seeing many changes that appear to be unrelated to Drupal 11 compatibility. For reference:
Godspeed!
Comment #41
joseph.olstadck4 tests won't pass in D11
Comment #42
phenaproximaThen add something like this to them in
setUp():Comment #43
joseph.olstadMerging 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.
Comment #44
acbramley commentedI believe everything is actioned, and the pipeline's green.
Comment #45
znerol commentedIt looks like changes in JavaScript source files have been reverted. I think that
js/build/drupalentity.jsshould be reverted as well.Comment #46
znerol commentedOn 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:
_LENIENT_ALLOW_LIST: "ckeditor"in.gitlab-ci.ymlbefore_scriptwhich 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.
Comment #47
joseph.olstad@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.
Comment #48
rajab natshahHoping for a tag release soon to simplify and accelerate testing and updates in projects.
A new
2.0.xbranch dedicated to CKE5-only support could be helpful, while maintaining minimal support for CKE4 in the8.x-1.xbranch.Comment #49
joseph.olstad@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.
Comment #50
znerol commentedWorking on the tests in order to minimize the amount of coverage loss.
Comment #51
znerol commentedThis 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.
Comment #52
joseph.olstadGreat 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
Comment #53
znerol commentedRemoved
OPT_IN_TEST_PREVIOUS_MINORfrom.gitlab-ci.yml.Comment #54
acbramley commentedSecurity support is for another 4 months, there's no harm in keeping it here.
Comment #55
phenaproximaA 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)andphpunit (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.The other stuff would be fine to fix in follow-ups.
Comment #56
joseph.olstad@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.
Comment #57
znerol commentedComment #58
berdirI 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.
Comment #59
znerol commentedSo, the test fail in phpunit (next minor) is in fact really interesting. MediaImageDecorator::build() attempts to pass the
altandtitleattribute 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 $entitywhich is triggered duringparent::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.
Comment #60
znerol commentedFound a way to refresh the entity context value.
Comment #61
joseph.olstadGreat sleuthing on the next minor fix @znerol ! that core commit happened only about 9 days ago
Comment #62
znerol commentedLooking at failing phpunit (max PHP version) now.
A lot of noise is due to one line in
EntityEmbedDialog.php, lets get rid of that:Comment #63
znerol commentedLooks like phpunit (max PHP version) was failing because of PHP8.4 deprecations around implicit nullable type hints. All phpunit jobs are green now.
Comment #64
znerol commentedFixed the phpstan jobs as well. The
phpstan.neonconfig 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:
\Drupal calls should be avoided in classes, use dependency injection insteadconfig:entity_view_mode_list cache tag might be unclear and does not contain the cache key in it.(see #58.Comment #65
znerol commentedNote that
EntityEmbedHooksTestrandomly fails in any of thephpstanjobs. This is most probably due to its reliance onstateto activate the hook in the test module (see #3496257: Race conditions in CacheCollector/State (again)).Comment #66
phenaproximaThanks 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.
Comment #67
berdirAdding ? is not a type change, it's fine to add this.
Comment #68
phenaproximaOK, 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:
If I understand this correctly,
?Type = NULL(which is what will be in the parent) andType = 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.
Comment #70
phenaproximaMerged into 8.x-1.x and will tag shortly. Thanks, everyone.
Comment #71
acbramley commentedGreat work everyone 💪