Problem/Motivation

We have a PluginFormInterface, but EditorPluginInterface skips it completely.

Because PluginFormInterface was added August 1, 2013 but EditorPluginInterface was added January 16, 2013.

Proposed resolution

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task
Issue priority Major, because the current (legacy) code duplicates a more modern generic interface.
CommentFileSizeAuthor
#113 interdiff-2326721.txt885 bytestim.plunkett
#113 2326721-editor-113.patch9.76 KBtim.plunkett
#108 interdiff.txt4.12 KBwim leers
#108 2326721-107.patch10.16 KBwim leers
#102 interdiff.txt782 byteswim leers
#102 2326721-102.patch7.09 KBwim leers
#98 2326721-98.patch6.37 KBwim leers
#82 drupal_2326721_82.patch22.54 KBxano
#82 interdiff.txt1.95 KBxano
#81 drupal_2326721_73.patch22.43 KBxano
#75 interdiff-2326721-69-73.txt6.06 KBHjarnmastara
#73 2326721-73.patch22.43 KBHjarnmastara
#69 2326721-69.patch22.43 KBrpayanm
#69 2326721-interdiff.txt648 bytesrpayanm
#66 2326721-65-2-test-only.patch22.46 KBrpayanm
#66 2326721-65-1-test-only.patch22.43 KBrpayanm
#65 2326721-65-2-do-not-test.patch22.46 KBrpayanm
#65 2326721-65-1-do-not-test.patch22.43 KBrpayanm
#63 2326721-63.patch22.5 KBrpayanm
#63 2326721-interdiff.txt596 bytesrpayanm
#61 2326721-diff-59-61.txt696 bytesvijaycs85
#61 2326721-61.patch22.53 KBvijaycs85
#59 2326721-59.patch22.45 KBvijaycs85
#59 2326721-diff-56-59.txt716 bytesvijaycs85
#56 2326721-56.patch21.75 KBrpayanm
#56 2326721-interdiff.txt706 bytesrpayanm
#53 2326721-53.patch21.69 KBrpayanm
#53 2326721-interdiff.txt611 bytesrpayanm
#50 2326721-50.patch21.66 KBrpayanm
#50 2326721-interdiff.txt3.17 KBrpayanm
#47 2326721-47.patch21.62 KBrpayanm
#44 editorplugininterface-2326721-44.patch21.6 KBsubhojit777
#44 interdiff-2326721-40-44.txt1.07 KBsubhojit777
#40 editorplugininterface-2326721-40.patch21.43 KBsubhojit777
#40 interdiff-2326721-38-40.txt555 bytessubhojit777
#38 editorplugininterface-2326721-38.patch21.36 KBsubhojit777
#38 interdiff-2326721-36-38.txt1.77 KBsubhojit777
#36 editorplugininterface-2326721-36.patch21.28 KBsubhojit777
#36 interdiff-2326721-31-36.txt1.74 KBsubhojit777
#31 editorplugininterface-2326721-31.patch19.54 KBsubhojit777
#31 interdiff-2326721-24-31.txt5.34 KBsubhojit777
#24 2326721-editorplugininterface-should-use.patch19.51 KBharshil.maradiya
#20 2326721-editorplugininterface-should-use.patch17.22 KBharshil.maradiya
#14 2326721-editorplugin.patch17.53 KBharshil.maradiya
#10 editor-2326721-7.patch18.32 KBHjarnmastara
#6 editor-2326721-6.patch7.65 KBtim.plunkett
#3 interdiff.txt1.01 KBtim.plunkett
#3 plugin-form-2326721-3.patch16.47 KBtim.plunkett
#1 plugin-form-2326721-1.patch16.23 KBtim.plunkett

Comments

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new16.23 KB

Let's see if PHPStorm got everything

Status: Needs review » Needs work

The last submitted patch, 1: plugin-form-2326721-1.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new16.47 KB
new1.01 KB

Not too shabby.

jibran’s picture

Status: Needs review » Needs work

I am only able to find minor issue.

+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
@@ -65,7 +65,7 @@ public function getButtons() {
+   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::buildConfigurationForm().

@@ -93,7 +93,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor
+   * #element_validate handler for the "styles" element in buildConfigurationForm().

+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
@@ -60,7 +60,7 @@ function getFile() {
+   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::buildConfigurationForm().

Unrelated. Revert this please.

What about all the documentation we are removing form the EditorPluginInterface and ImageToolkitInterface?

jibran’s picture

I'd suggest we should ping maintainers of these two component for this change.

PS: I mean Editor and Image maintainers not Plugin maintainer :D

tim.plunkett’s picture

Title: Use PluginFormInterface instead of reinventing in specific plugins » EditorPluginInterface should use PluginFormInterface
Component: plugin system » editor.module
Status: Needs work » Needs review
Related issues: +#2096703: Image toolkits should use PluginFormInterface and ContainerFactoryPluginInterface
StatusFileSize
new7.65 KB

#2096703: Image toolkits should use PluginFormInterface and ContainerFactoryPluginInterface is handling image toolkits directly.
Removed image and unrelated ckeditor hunks.

wim leers’s picture

Issue summary: View changes

PluginFormInterface was added August 1, 2013. EditorPluginInterface was added January 16, 2013.

That's why.


#5: thanks :)


  1. +++ b/core/modules/editor/src/Plugin/EditorPluginInterface.php
    @@ -34,53 +34,6 @@
    -   * If the editor's behavior depends on extensive options and/or external data,
    -   * then the implementing module can choose to provide a separate, global
    -   * configuration page rather than per-text-format settings. In that case, this
    -   * form should provide a link to the separate settings page.
    

    This is lost.

  2. +++ b/core/modules/editor/src/Plugin/EditorPluginInterface.php
    @@ -34,53 +34,6 @@
    -   * The contents of the editor settings are located in
    -   * $form_state->getValue(array('editor', 'settings')). Calls to form_error()
    -   * should reflect this location in the settings form.
    

    This is also lost.

    And this also introduces a subtle but important conflict. Everything used to be consistently named "settings": in the code, in the interface (getDefaultSettings()) and in the config entity. This patch removes that consistency. That's acceptable, but it's definitely a subtle regression.

    I think we should consider renaming everything from "settings" to "configuration" for consistency.

  3. +++ b/core/modules/editor/src/Plugin/EditorPluginInterface.php
    @@ -34,53 +34,6 @@
    -   * Values in $form_state->getValue(array('editor', 'settings')) are saved by
    -   * Editor module in editor_form_filter_admin_format_submit().
    

    Also lost.

wim leers’s picture

Status: Needs review » Needs work
wim leers’s picture

Issue tags: +DrupalCamp Ghent 2014, +Novice, +php-novice, +sprint
Hjarnmastara’s picture

Status: Needs work » Needs review
StatusFileSize
new18.32 KB

Added the lost comments (see: #7).
Reworked everything to configuration instead of settings to keep the consistency.
Added type-hinting to the plugin generated by the plugin manager in Editor.php (see line 85 - 86).

Status: Needs review » Needs work

The last submitted patch, 10: editor-2326721-7.patch, failed testing.

wim leers’s picture

Tests are failing because \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest hasn't been updated yet. Could you please also update that unit test?

+++ b/core/modules/editor/src/Entity/Editor.php
@@ -82,7 +83,8 @@ public function __construct(array $values, $entity_type) {
     // Initialize settings, merging module-provided defaults.
-    $default_settings = $plugin->getDefaultSettings();
+    /* @var EditorPluginInterface $plugin */
+    $default_settings = $plugin->getDefaultConfiguration();
     $default_settings += \Drupal::moduleHandler()->invokeAll('editor_default_settings', array($this->editor));
     \Drupal::moduleHandler()->alter('editor_default_settings', $default_settings, $this->editor);
     $this->settings += $default_settings;

s/settings/configuration/ several times here.

This would also cause a hook name to be changed, hence we'll have to update its documentation in editor.api.php as well.

harshil.maradiya’s picture

Assigned: tim.plunkett » harshil.maradiya
Issue tags: -sprint +sprint @SprintWeekend2015Queue
harshil.maradiya’s picture

StatusFileSize
new17.53 KB

I have implement all changes which are mention (editor-2326721-7.patch)

harshil.maradiya’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: 2326721-editorplugin.patch, failed testing.

wim leers’s picture

The patch doesn't apply to the latest version of Drupal 8. Apply it to your local version, or if you're using a branch, switch to that. Then, you can do git pull --rebase to bring it to the latest version. Then you can just recreate the patch file and upload it :)

yesct’s picture

Issue tags: -sprint @SprintWeekend2015Queue +sprint, +SprintWeekend2015

tags can be confusing.

Thank you for working on this issue.

Note, tags should be separated with a comma, not a space.

The Queue tag was used to line up issues before the sprint. (#2407325: preparing for a sprint, would be good to have a list of candidate issues)
When you work on an issue please add: SprintWeekend2015 (note, no @ or # at the beginning) according to that and https://groups.drupal.org/node/447258

harshil.maradiya’s picture

@Wim Leers
Thanks will update and recreate the patch

harshil.maradiya’s picture

create patch with latest code

harshil.maradiya’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 20: 2326721-editorplugininterface-should-use.patch, failed testing.

wim leers’s picture

Issue tags: +Needs reroll
harshil.maradiya’s picture

re verifying and uploading new patch

harshil.maradiya’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 24: 2326721-editorplugininterface-should-use.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 24: 2326721-editorplugininterface-should-use.patch, failed testing.

wim leers’s picture

The fatal:
PHP Fatal error: Unsupported operand types in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/editor/src/Entity/Editor.php on line 84

subhojit777’s picture

subhojit777’s picture

Assigned: subhojit777 » Unassigned
Status: Needs work » Needs review
Issue tags: -sprint, -SprintWeekend2015, -Needs reroll
StatusFileSize
new5.34 KB
new19.54 KB

- Test was using wrong method.
- Few indentation correction.
- Commented codes removed.

Status: Needs review » Needs work

The last submitted patch, 31: editorplugininterface-2326721-31.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 31: editorplugininterface-2326721-31.patch, failed testing.

subhojit777’s picture

Assigned: Unassigned » subhojit777
subhojit777’s picture

Status: Needs work » Needs review
StatusFileSize
new1.74 KB
new21.28 KB

Status: Needs review » Needs work

The last submitted patch, 36: editorplugininterface-2326721-36.patch, failed testing.

subhojit777’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB
new21.36 KB

Status: Needs review » Needs work

The last submitted patch, 38: editorplugininterface-2326721-38.patch, failed testing.

subhojit777’s picture

Status: Needs work » Needs review
StatusFileSize
new555 bytes
new21.43 KB

Status: Needs review » Needs work

The last submitted patch, 40: editorplugininterface-2326721-40.patch, failed testing.

subhojit777’s picture

Any idea why it is failing with unsupported operand types error. According to the patch in #40 the function getDefaultSettings() has "only" been renamed to getDefaultConfiguration() (or is there something more in it?). Anyone please help!

subhojit777’s picture

$this->settings and $plugin->getDefaultConfiguration() both are of array types too.

subhojit777’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB
new21.6 KB

Uploading new patch with some minor fixes. I am still waiting for some help #42

Status: Needs review » Needs work

The last submitted patch, 44: editorplugininterface-2326721-44.patch, failed testing.

wim leers’s picture

Would love to help with #42, but the patch doesn't apply anymore. If you can get another working test run, I'll try to help :)

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new21.62 KB

Trying.

Status: Needs review » Needs work

The last submitted patch, 47: 2326721-47.patch, failed testing.

tim.plunkett’s picture

  1. +++ b/core/modules/ckeditor/js/views/ControllerView.js
    @@ -138,7 +138,7 @@
    +      // @see \Drupal\ckeditor\Plugin\Editor\CKEditor::buildConfigurationForm.
    

    I realize it was wrong in HEAD, but @see for methods should have () and cannot have a trailing .

  2. +++ b/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
    @@ -30,14 +30,14 @@ class TRexEditor extends EditorBase {
    +  function getDefaultConfiguration() {
    ...
    +  function buildConfigurationForm(array $form, FormStateInterface $form_state, EditorEntity $editor = NULL) {
    
    @@ -49,7 +49,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor
    +  function getJSConfiguration(EditorEntity $editor) {
    
    +++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
    @@ -31,14 +31,14 @@ class UnicornEditor extends EditorBase {
    +  function getDefaultConfiguration() {
    ...
    +  function buildConfigurationForm(array $form, FormStateInterface $form_state, EditorEntity $editor = NULL) {
    

    These should be `public`.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.17 KB
new21.66 KB

@tim.plunkett thank you for review this :)
Here the patch.

Status: Needs review » Needs work

The last submitted patch, 50: 2326721-50.patch, failed testing.

wim leers’s picture

Great! Now let's make the test green :)

The cause of the fatal:

PHP Fatal error:  Unsupported operand types in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/editor/src/Entity/Editor.php on line 85
+++ b/core/modules/editor/src/Entity/Editor.php
@@ -80,7 +80,9 @@ public function __construct(array $values, $entity_type) {
+    $this->settings += $plugin->getDefaultConfiguration();

So either $this->settings is not an array, or whatever $plugin->getDefaultConfiguration() is returning is not an array.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new611 bytes
new21.69 KB

Let me see something first.

Status: Needs review » Needs work

The last submitted patch, 53: 2326721-53.patch, failed testing.

rpayanm queued 50: 2326721-50.patch for re-testing.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new706 bytes
new21.75 KB

There is a error in core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest::testCalculateDependencies()

line 115 when:

$entity = new Editor($values, $this->entityTypeId);

Because in core/modules/editor/src/Entity/Editor::__construct(), $plugin->getDefaultConfiguration() isn't a array, seem it is NULL.

The last submitted patch, 50: 2326721-50.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 56: 2326721-56.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new716 bytes
new22.45 KB

Because in core/modules/editor/src/Entity/Editor::__construct(), $plugin->getDefaultConfiguration() isn't a array, seem it is NULL.

Isn't it because of the method rename?

Status: Needs review » Needs work

The last submitted patch, 59: 2326721-59.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new22.53 KB
new696 bytes

getDefaultConfiguration() called more than once...

Status: Needs review » Needs work

The last submitted patch, 61: 2326721-61.patch, failed testing.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new596 bytes
new22.5 KB
tim.plunkett’s picture

+++ b/core/modules/editor/editor.module
@@ -153,12 +153,13 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
   if ($editor) {

+++ b/core/modules/editor/src/Entity/Editor.php
@@ -80,7 +80,11 @@ public function __construct(array $values, $entity_type) {
+    if (is_array($plugin->getDefaultConfiguration())) {

Why do we need this check?

rpayanm’s picture

StatusFileSize
new22.43 KB
new22.46 KB

@tim.plunkett because the patch fail due $plugin->getDefaultConfiguration() sometime is NULL.

Look this tests:

Tip:
The error more concise: 2326721-65-2-do-not-test.patch

rpayanm’s picture

StatusFileSize
new22.43 KB
new22.46 KB

Ups sorry is test-only.

rpayanm’s picture

Status: Needs review » Needs work

The last submitted patch, 66: 2326721-65-2-test-only.patch, failed testing.

rpayanm’s picture

Assigned: subhojit777 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new648 bytes
new22.43 KB

Umm my mistake :)

#64 suggest.

tim.plunkett’s picture

AFAIK getDefaultConfiguration is documented as always returning an array. So we should remove the check and fix whatever plugin is returning NULL.

rpayanm’s picture

Already #69 patch resolve that.

xano’s picture

Status: Needs review » Needs work

This is a nice improvement :) I only found some minor naming and documentation issues:

  1. +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
    @@ -248,7 +248,7 @@ public function settingsFormSubmit(array $form, FormStateInterface $form_state)
    +  public function getJSConfiguration(EditorEntity $editor) {
    

    If we are renaming this method anyway, we can fix the capitalization error at the same time: JS > Js.

  2. +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php
    @@ -369,7 +369,7 @@ public function getLibraries(EditorEntity $editor) {
    +   * @see getJSConfiguration()
    

    I don't know if it's required, but I would add a bit more context to this, as the documentation in this form refers to a global function. Something like @see self::getJSConfiguration() would work.

  3. +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php
    @@ -71,7 +71,7 @@ protected function setUp() {
    +   * Tests CKEditor::getJSConfiguration().
    

    Missing namespace.

Hjarnmastara’s picture

Status: Needs work » Needs review
StatusFileSize
new22.43 KB

Applied the minor changes.

xano’s picture

Thanks! Could you post an interdiff as well?

Hjarnmastara’s picture

StatusFileSize
new6.06 KB

Done!
I couldn't understand your comment about the missing namespace tho.

xano’s picture

Status: Needs review » Needs work

Thanks for the interdiff. It looks good!

When we refer to classes or interfaces in code comments, the Drupal coding standards require that we include the namespace as well, so we must use @param \Drupal\ckeditor\Plugin\Editor\CKEditor instead of just CKEditor, for example. Other coding standards sometimes allow developers to leave out the namespace, but we don't.

sher1’s picture

Status: Needs work » Needs review

The interdiff doesn't have the namespacing but the patch file does.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice, -php-novice +Needs beta evaluation

This issue is a task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.

+++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php
@@ -71,7 +71,7 @@ protected function setUp() {
   /**
-   * Tests CKEditor::getJSSettings().
+   * Tests CKEditor::getJsConfiguration().
    */
   function testGetJSSettings() {

Lets update the test method name too.

wim leers’s picture

Issue tags: +Needs reroll, +Novice, +php-novice
xano’s picture

Issue summary: View changes
Issue tags: -Needs reroll
StatusFileSize
new22.43 KB

Re-roll.

I'll post another patch that cleans up a few more things.

xano’s picture

Status: Needs work » Needs review
Issue tags: -Needs beta evaluation
StatusFileSize
new1.95 KB
new22.54 KB

There's more we can improve, but for now I only improved the lines that were touched by the previous patch anyway.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 82: drupal_2326721_82.patch, failed testing.

Status: Needs work » Needs review

cbanman queued 82: drupal_2326721_82.patch for re-testing.

daffie queued 82: drupal_2326721_82.patch for re-testing.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

xjm’s picture

Version: 8.0.x-dev » 9.x-dev
Status: Reviewed & tested by the community » Postponed

Thanks for the patch and for keeping this issue going.

Thanks also for adding the beta evaluation. Unfortunately though, it is not correct -- this is definitely not unfrozen. Unfrozen changes are only:

  • CSS
  • markup
  • translatable strings
  • documentation
  • automated tests (excluding BrowserTestBase tests)

Additionally, the provision of a Drupal 6/7 to Drupal 8 migration path is not strictly coupled to the release cycle, so that code remains unfrozen.

In general, on its own, "replacing legacy code with best practices" is not an allowed change during the Drupal 8 beta. Review https://www.drupal.org/core/beta-changes. This patch does also introduce BC breaks that could impact existing implementations. I checked with @Wim Leers and he suggested that it also wouldn't really make sense to try to do this in a non-BC-breaking way in a minor release. So, I am postponing this issue to 9.x. Thanks everyone!

xjm’s picture

Issue summary: View changes

(Removing the unfrozen line from the summary to avoid future confusion and adding reviewer credit.)

catch’s picture

Version: 9.x-dev » 8.1.x-dev

I think we should consider a bc-compatible patch here for a late release of 8.x - while it wouldn't make things clearer, it might allow 9.x compatible cod to be written in 8.x

wim leers’s picture

Status: Postponed » Active

Let's see if we can such a BC-compatible patch done then.

gnuget’s picture

Not sure if the Novice and the php-novice tags are still valid for this issue, can we remove them?

wim leers’s picture

Issue tags: -Novice, -php-novice

Good point!

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

Title: EditorPluginInterface should use PluginFormInterface » EditorPluginInterface should extend PluginFormInterface
Version: 8.3.x-dev » 9.x-dev
Status: Active » Postponed

We cannot do this in a BC-compatible way. Only in a half-BC-compatible way: we could change \Drupal\editor\Plugin\EditorPluginInterface to let it extend PluginFormInterface, but then all implementations of that interface will cease to work. We can "automatically fix" any implementations that extend EditorBase by letting EditorBase implement the PluginFormInterface methods, but then that'd mean letting that base class redirect all the "proper" method implementations to the "bad" (current) ones. Otherwise it's still a BC break. But then we're effectively encouraging incorrect implementations!

So, AFAICT there's no way to make this change in a BC-compatible way. In other words, I think this can only happen in D9.

catch’s picture

Version: 9.x-dev » 8.3.x-dev
Status: Postponed » Active

We can "automatically fix" any implementations that extend EditorBase by letting EditorBase implement the PluginFormInterface methods, but then that'd mean letting that base class redirect all the "proper" method implementations to the "bad" (current) ones. Otherwise it's still a BC break. But then we're effectively encouraging incorrect implementations!

This would allow modules to update to the new interface though right? In which case I think it's worthwhile in 8.x, albeit ugly. If 9.x only drops backwards compatibility with 8.x, then we need to get our heads around problems like this.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new6.37 KB

Like this?

wim leers’s picture

Note that the lack of changes to EditorBase subclasses proves that this maintains BC.

wim leers’s picture

TODO: look into whether https://www.drupal.org/node/2774077 affects this or not.

catch’s picture

That looks right to me.

wim leers’s picture

StatusFileSize
new7.09 KB
new782 bytes

Then I think this is ready to be committed.

wim leers’s picture

Issue tags: +Needs change record
catch’s picture

So we should ideally @trigger_error('...', E_USER_DEPRECATED) in the bc methods on the base class, that will encourage people to implement the interface properly. As well as adding test coverage (i.e. a test subclass that doesn't have those methods) so we can confirm the bc layer works per #2575081: [policy, no patch] Use E_USER_DEPRECATED in Drupal 8 minor releases.

tim.plunkett’s picture

+++ b/core/modules/editor/editor.module
@@ -168,12 +168,13 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
+    $settings_form['#element_validate'][] = array($plugin, 'validateConfigurationForm');
+    $form['editor']['settings']['subform'] = $plugin->buildConfigurationForm($settings_form, $form_state, $editor);
...
+    $form['actions']['submit']['#submit'][] = array($plugin, 'submitConfigurationForm');

This should be using SubformState, see \Drupal\block\BlockForm::form() for an example of doing that. Or I can help with the conversion.

Or is that a separate issue? Hmm.

wim leers’s picture

Or is that a separate issue? Hmm.

I wasn't sure about that either. SubFormState is so very new. This used to work just fine. So I think adopting SubFormState should be a separate issue. This issue is already more than 100 comments long. Adopting SubFormState should be less tricky and controversial, because it is solely internal refactoring.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
wim leers’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new10.16 KB
new4.12 KB

#104: done.

wim leers’s picture

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Interdiff checks out. Thanks @Wim Leers!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/editor/editor.module
@@ -168,12 +168,13 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
-    $form['editor']['settings']['subform'] = $plugin->settingsForm($settings_form, $form_state, $editor);
...
+    $form['editor']['settings']['subform'] = $plugin->buildConfigurationForm($settings_form, $form_state, $editor);

+++ b/core/modules/editor/src/Plugin/EditorBase.php
@@ -31,21 +31,51 @@ public function getDefaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
...
+  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    return $this->settingsForm($form, $form_state, $form_state->get('editor'));

Previously, the $editor was passed to settingsForm(), which declared it as a required parameter.

This implementation of buildConfigurationForm() should declare $editor as an optional parameter. It can't pull it from $form_state->get(), because nothing ever set it.

Sorry for missing this initially.

wim leers’s picture

This implementation of buildConfigurationForm() should declare $editor as an optional parameter. It can't pull it from $form_state->get(), because nothing ever set it.

If this didn't work, then we'd have several failing tests for the CKEditor test coverage.

It's \editor_form_filter_admin_format_editor_configure() that sets it.

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new9.76 KB
new885 bytes

Aha, reading the larger context made this clearer. This whole hunk in editor.module *only runs* if $form_state->get('editor') returns something.
Passing it along to buildConfigurationForm isn't needed, and it threw me off.
Removing that since everything already uses $form_state->get('editor'), and even though that is a little non-standard, it works fine and is needed by other parts of the code.

wim leers’s picture

Excellent catch, that was indeed a small oversight on my part :)

Thanks for the reroll & explanation!

  • catch committed aed10c0 on 8.3.x
    Issue #2326721 by rpayanm, subhojit777, tim.plunkett, Wim Leers, harshil...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed aed10c0 and pushed to 8.3.x. Thanks!

Nice to rescue this from 9.x purgatory.

wim leers’s picture

Cool :) AFAIK this is the first patch of its kind! Hopefully it's a solid precedent.

Publishing CR & unpostponing follow-up.

Status: Fixed » Closed (fixed)

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