I have created a new Text Format 'Simple Plain' and selected 'Ckeditor' and then save the format. Then in a node, I have used this text format and added some contents.

-Then after I edit Text Format 'Simple Plain' (/admin/config/content/formats/manage/simple_plain) and selected 'none' in Text editor (see image2.jpg), I got below mentioned error on save configuration .

TypeError: Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given, called in /code/core/modules/editor/editor.module on line 251 in Drupal\Core\Form\SubformState::createForSubform() (line 56 of /code/core/lib/Drupal/Core/Form/SubformState.php)
#0 /code/core/modules/editor/editor.module(251): Drupal\Core\Form\SubformState::createForSubform(NULL, Array, Object(Drupal\Core\Form\FormState))
#1 [internal function]: editor_form_filter_admin_format_submit(Array, Object(Drupal\Core\Form\FormState))
#2 /code/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array('editor_form_fil...', Array)
#3 /code/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#4 /code/core/lib/Drupal/Core/Form/FormBuilder.php(591): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#5 /code/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('filter_format_e...', Array, Object(Drupal\Core\Form\FormState))
#6 /code/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\filter\FilterFormatEditForm), Object(Drupal\Core\Form\FormState))
#7 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#8 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#9 /code/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /code/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#12 /code/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /code/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /code/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /code/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /code/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /code/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /code/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /code/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /code/core/lib/Drupal/Core/DrupalKernel.php(694): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /code/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#23 {main}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MahtabAlam created an issue. See original summary.

codersukanta’s picture

Assigned: Unassigned » codersukanta

Reproduced the issue in my local, We don't need to add any content with the new text format to reproduce the issue.

Just add a new Text Format 'Simple Plain' with the 'Ckeditor' selected. Then edit the Text Format with "None" selected.

Assigning to me to start working on it.

codersukanta’s picture

Assigned: codersukanta » Unassigned
Status: Active » Needs review
FileSize
919 bytes

Patch added

dishabhadra’s picture

I am also able to reproduce this issue.

I tested your patch, it looks good to me.

+1 for RTBC.

atul4drupal’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
48.92 KB
18.66 KB

Hello codersukanta,

Thanks for working on this, the fix has come really fast.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for filing this bug report and for fixing the issue.

In order to commit a bug fix, we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:

  1. https://www.drupal.org/docs/8/testing
  2. https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.9.x
atul4drupal’s picture

Status: Needs work » Needs review

Hello xjm,
Thanks for the guidance and the resources shared....

I checked the piece of code that #3 has worked upon, it has a test coverage already mentioned in "core/modules/editor/tests/src/Functional/EditorAdminTest.php" file at function testAddEditorToNewFormat()

How can we have that triggered on the patch at #3, or how D.O test runner checks for the existing test cases to be executed. This will help us better understand the test bot.

Thanks.

atul4drupal’s picture

Status: Needs review » Needs work

didn't noticed status changing to 'Neede Review' reverting as per #6

atul4drupal’s picture

I see this been executed by test bot and bot seems happy with the patch at #3

I think this might meet the test requirement as suggested in #6, kindly correct if I get this otherwise.
Updateing for needs review.

atul4drupal’s picture

Status: Needs work » Needs review
BalajiDS’s picture

Patch #3 is working fine in Drupal-8.8.6 and there are no logs were found in /admin/reports/dblog

Sivaji_Ganesh_Jojodae’s picture

+++ b/core/modules/editor/editor.module
@@ -247,7 +247,9 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_
+  if (($editor_plugin = $form_state->get('editor_plugin')) && $editor_set && $subform_array_exists) {

$editor_plugin = $form_state..., is that meant to be an assignment = or comparison ==?

codersukanta’s picture

Hi @Devjojodae,

$editor_plugin = $form_state->get('editor_plugin')
This is an assignment statement(=) as $editor_plugin is used to call the submitConfigurationForm function.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

peterx’s picture

I just had the same error in 9.0.3. Tried to switch off CKEditor in the settings. No error switching CKEditor on. I guess the code is the similar.

In 9.0.3, the change is at line 250 but #3 does not fix it. The code must be a bit different.

ericdsd’s picture

Patch #3 works like a charm with 8.9.6

catch’s picture

Priority: Normal » Critical
Issue tags: +Bug Smash Initiative

This is a fatal error reproducible purely by configuration in the UI, so bumping to critical.

@atul4drupal

We need to add test coverage to show that this patch fixes the bug - at the moment the test coverage only shows that it doesn't make things worse.

So Functional/EditorAdminTest.php should be expanded to check the case where the editor selection is changed to none - and that test should fail without the patch applied.

IJsbrandy’s picture

Patch #3 works.

I can reproduce this fatal error by saving the editor configuration under the testAddEditorToExistingFormat() test without the patch.

Patch added with minor adjustment to the tests. Should we make separate test for this issue or should this minor change to the tests be sufficient enough?

heddn’s picture

I an confirm the steps to reproduce in the IS are accurate.

thomaswalther’s picture

I changed the form settings for "/admin/config/content/formats/manage/full_html".

In the dropdown "form-item-editor-editor" I select "none" (not CKeditor)

Error:

TypeError: Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given, called in /Applications/MAMP/htdocs/drupal9/core/modules/editor/editor.module on line 251 in /Applications/MAMP/htdocs/drupal9/core/lib/Drupal/Core/Form/SubformState.php on line 56 #0 /Applications/MAMP/htdocs/drupal9/core/modules/editor/editor.module(251): Drupal\Core\Form\SubformState::createForSubform(NULL, Array, Object(Drupal\Core\Form\FormState))
#1 [internal function]: editor_form_filter_admin_format_submit(Array, Object(Drupal\Core\Form\FormState))
#2 /Applications/MAMP/htdocs/drupal9/core/lib/Drupal/Core/Form/FormSubmitter.php(113): call_user_func_array('editor_form_fil...', Array)
#3 /Applications/MAMP/htdocs/drupal9/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
...
Spokje’s picture

Version: 8.9.x-dev » 9.2.x-dev
Assigned: Unassigned » Spokje
Status: Needs review » Needs work

I can confirm the following steps produce the same error on the latest 9.2.x-dev branch:

- Go to /admin/config/content/formats/manage/full_html
- Change the drop-down Text editor from CKEditor to None
- Press button Save configuration
- CLUNK
TypeError: Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given, called in D:\htdocs\drupal\core\modules\editor\editor.module on line 251 in Drupal\Core\Form\SubformState::createForSubform() (line 56 of D:\htdocs\drupal\core\lib\Drupal\Core\Form\SubformState.php)

Bumping version to 9.2.x-dev (looks like this is going to be a backport-party when we got a working patch...)
Assigning to myself to create a test that fails without the patch and passes when it's applied

Spokje’s picture

Spokje’s picture

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

Ok, so now we have a failing test without the patch and the same test passes with the patch, so Needs Review seems in order.

Also:

We have confirmation that this bug also appears in 9.0.x and 8.9.x.
Basically that means it also appears in 9.1.x

I think this patch will smoothly apply to 9.1 and 9.0, for 8.9 we probably have to change the $this->submitForm to the 8.x equivalent $this->drupalPostForm

heddn’s picture

Status: Needs review » Reviewed & tested by the community

I like it.

Spokje’s picture

As expected argument_one_must_be_an_array-3136406-22.patch applies cleanly on 9.0.x, 9.1.x and 9.2.x.

Looks like 8.9.x just has a few lines offset, but no code changes are needed.
Let's see if that theory is correct with the attached patch.

Spokje’s picture

quietone’s picture

Issue tags: -Needs tests

Removing needs tests tag because there is test.

  • larowlan committed acb4b85 on 9.2.x
    Issue #3136406 by Spokje, codersukanta, IJsbrandy, atul4drupal,...

  • larowlan committed 21b3390 on 9.1.x
    Issue #3136406 by Spokje, codersukanta, IJsbrandy, atul4drupal,...
larowlan’s picture

Title: Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given » [backport] Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given
Version: 9.2.x-dev » 9.0.x-dev

I manually tested this locally before and after the patch and confirmed both the bug and that this fixes it.

We also have test coverage for the bug.

I also verified that we could switch back to an editor, and this worked too.

As this is a bug fix, non disruptive and critical - backported to 9.1.x

Leaving at 9.0.x for possible backport there too.

alexpott’s picture

I think this should go in 8.9.x as well as 9.0.x too

  • larowlan committed 69345ad on 9.0.x
    Issue #3136406 by Spokje, codersukanta, IJsbrandy, atul4drupal,...

  • larowlan committed e94c8af on 8.9.x
    Issue #3136406 by Spokje, codersukanta, IJsbrandy, atul4drupal,...
larowlan’s picture

Title: [backport] Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given » Argument 1 passed to Drupal\Core\Form\SubformState::createForSubform() must be of the type array, null given
Version: 9.0.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed

Backported to 9.0.x and 8.9.x

Thanks all

Status: Fixed » Closed (fixed)

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