Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It looks like tests are failing on Drupal 8.8 due to changes to linkability in this issue: #2994696: Render embedded media items in CKEditor
See https://www.drupal.org/pift-ci-job/1374140
Proposed resolution
Use the new api drupallink.registerLinkableWidget() if available (Drupal is >= 8.8), otherwise fallback to existing code that uses a workaround where we borrow the functionality form the drupalimage plugin.
New API:
+ if (CKEDITOR.plugins.drupallink.hasOwnProperty('registerLinkableWidget')) {
+ CKEDITOR.plugins.drupallink.registerLinkableWidget('drupalentity');
+ }
Remaining tasks
review/commit
User interface changes
none
API changes
none on our end.
Data model changes
none
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#23 | 3074061-23.patch | 6.06 KB | oknate |
#23 | 3074061-interdiff--21-23.txt | 2.47 KB | oknate |
#21 | 3074061-21.patch | 5.95 KB | oknate |
#21 | 3074061-interdiff--18-21.txt | 1.63 KB | oknate |
#18 | 3074061-18.patch | 6.16 KB | oknate |
Comments
Comment #2
oknateComment #3
oknateHere's the fix. It updates the plugin to use new drupallink API with a fallback for backwards compatibility.
Comment #4
oknateComment #6
oknateHandling case where drupallink doesn't exist:
Comment #8
oknateI can't recreate the failure in the 8.8 test in comment #6 locally. I'm trying to adjust the code to be more robust, let's see if this helps.
Comment #10
oknateReverting the change to the test in #8 as it didn't help. I'm now kind of stuck on this. I can't reproduce the failure locally, and I'm not sure why it's failing.
Comment #11
oknateTesting another set of changes on testbot.
Comment #13
oknateAlright, sweet! Now I can see the bug locally, I needed to update composer in the root of the repo:
Comment #14
oknateI think I have it now. I was able to reproduce and fix the autocomplete bug locally on 8.8.
The issue is some change in either behat or the selenium driver that was causing the focus to change after filling in the field, making the autocomplete disappear.
I borrowed a fix from EntityReferenceAutocompleteWidgetTest:
Comment #15
oknateComment #16
oknateOops, attached the patch twice instead of the interdiff in the last comment.
This
$this->assertSession()->waitOnAutocomplete();
is perhaps unnecessary. It was working without it, but EntityReferenceAutocompleteWidgetTest has it, and it seems like it might make the test more stable, so throwing it in.Comment #17
oknatePhenaproxima raised the issue that checking if the drupallink plugin exists before adding the workaround doesn't make sense:
Comment #18
oknateTesting changing the logic so that workaround isn't added if drupallink not enabled. This makes more sense. I was fixing the bug where CKEDITOR.plugins.drupallink.hasOwnProperty('registerLinkableWidget') was throwing an error by adding a check if
typeof CKEDITOR.plugins.drupallink === 'undefined'
But linking shouldn't be enabled without CKEDITOR.plugins.drupallink, so reversing the logic:
typeof CKEDITOR.plugins.drupallink !== 'undefined'
Comment #19
oknateTriggered a retest for #18 after #2994699: Create a CKEditor plugin to select and embed a media item from the Media Library went in to 8.8. And it passed: all green!
Comment #20
Wim Leers👍
🤔 This is repeating the same if-test. How about we check that once around line 28, assign the result to a variable, and use that in both lines 28 and 76?
😨 Why does this need to change?
Comment #21
oknateRe #20.2:
After looking at registerLinkableWidget(), I see it takes a string, so we can do it before the plugin is instantiated, so moving the code into beforeInit() method of drupalentity plugin, right where the other condition sits.
Re #20.3:
The change to ContentTranslationTest has to do with #13. Some change to Behat or Selenium was breaking my autocomplete test code. Fixed in #14. I don't know the cause of it, but I was able to adjust the code, by borrowing the process used to test entity reference autocomplete fields.
Comment #23
oknateWrapping the whole thing in
if (editor.plugins.drupallink)
.I forgot, this was the same reason I had failures in #3 (fixed in #6). In some cases editor.plugins.drupallink is undefined.
This passed all the function javascript tests for me locally on Drupal 8.8.
Comment #24
oknateComment #25
oknateComment #26
oknateI think this is in a good place now. Ready for another review.
Comment #27
Wim LeersWhy change this comment? And the change contains a typo too: s/
//W
/// W
/I'd just keep the original comment.
Assuming you fix this on commit, RTBC :)
Comment #29
oknateI think the linter was complaining the comment didn't start with a capital letter. I'll just revert the change on commit.
Comment #30
Wim Leers👍
Comment #31
oknateComment #33
oknateCommitted!