I just tested setting up Drupal 9 with the Insert module from the branch 8.x-2.x on PHP 7.4 and then switching to PHP 8. I did not experience a particular issue, not in general, and neither related to the Insert module. It would be interesting to examine the logs when that error appears, that should give a good hint about the issue.
Thanks for the patch, it does not look to be PHP 8 related unless I miss out on something; but it might make sense to have a check there anyway. I attached an optimised version, because it would not make sense to even process the
foreach
when there are no$text_formats
if that is indeed the problem.-
Snater β
committed fa5ab1d9 on 8.x-2.x
Issue #3309608 by srdtwc, Snater: Check text formats
-
Snater β
committed fa5ab1d9 on 8.x-2.x
- Status changed to Fixed
over 1 year ago 7:05am 5 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 4:11pm 21 April 2023 - πΊπΈUnited States bill_redman
I just encountered this same error when trying to add a new page or block on a newly created site. Running Drupal 9.5.7, PHP 8.1.14, Insert 8.x-2.0-beta3. I did not yet try your patch. You had stated that it might be helpful to see the log messages, so here are the dumps of the 2 error messages I got. I'd be interested in knowing if you think your patch would still apply.
Warning: Undefined array key "drupalExternalPlugins" in insert_editor_js_settings_alter() (line 833 of /code/web/modules/contrib/insert/insert.module) #0 /code/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Undefined array...', '/code/web/modul...', 833) #1 /code/web/modules/contrib/insert/insert.module(833): _drupal_error_handler(2, 'Undefined array...', '/code/web/modul...', 833) #2 /code/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): insert_editor_js_settings_alter(Array, NULL, NULL) #3 /code/web/core/modules/editor/src/Plugin/EditorManager.php(88): Drupal\Core\Extension\ModuleHandler->alter('editor_js_setti...', Array) #4 /code/web/core/modules/editor/src/Element.php(100): Drupal\editor\Plugin\EditorManager->getAttachments(Array) #5 [internal function]: Drupal\editor\Element->preRenderTextFormat(Array) #6 /code/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array) #7 /code/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...') #8 /code/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) #9 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #10 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array) #11 /tmp/rolling/4a6f9b5/twig/6442aaa046ece_field-multiple-value-form_ds57qloNMUETHurvFKNX-za-X/UXcq92eApIyaFd_9jU2PsSbYTrS9Dlq25M0HUjeWgsU.php(89): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #12 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_d93c6c9fa59ad0649a07dcce1924ac9a->doDisplay(Array, Array) #13 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array) #14 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array) #15 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array) #16 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/cla...', Array) #17 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('field_multiple_...', Array) #18 /code/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array) #19 /code/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array) #20 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #21 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array) #22 /tmp/rolling/4a6f9b5/twig/6442aaa046ece_node-edit-form.html.twig_6IvRpo8LMM79vlgE1EN6FQKYH/-LUlf70mQ5q_r3jRYdvRndx7paIbZSz8jScARe-tL-U.php(44): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #23 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_8d7605f11e792d80e3297ebd3db6e904->doDisplay(Array, Array) #24 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array) #25 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array) #26 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array) #27 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/cla...', Array) #28 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('node_edit_form', Array) #29 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #30 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->render(Array, false) #31 /code/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() #32 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(243): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #33 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #34 /code/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #35 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #36 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #37 /code/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view') #38 /code/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #39 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #40 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #41 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #42 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #43 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #44 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #45 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #46 /code/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #47 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #48 {main}
TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 833 of /code/web/modules/contrib/insert/insert.module) #0 /code/web/modules/contrib/insert/insert.module(833): array_keys(NULL) #1 /code/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): insert_editor_js_settings_alter(Array, NULL, NULL) #2 /code/web/core/modules/editor/src/Plugin/EditorManager.php(88): Drupal\Core\Extension\ModuleHandler->alter('editor_js_setti...', Array) #3 /code/web/core/modules/editor/src/Element.php(100): Drupal\editor\Plugin\EditorManager->getAttachments(Array) #4 [internal function]: Drupal\editor\Element->preRenderTextFormat(Array) #5 /code/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array) #6 /code/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...') #7 /code/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) #8 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #9 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array) #10 /tmp/rolling/4a6f9b5/twig/6442aaa046ece_field-multiple-value-form_ds57qloNMUETHurvFKNX-za-X/UXcq92eApIyaFd_9jU2PsSbYTrS9Dlq25M0HUjeWgsU.php(89): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #11 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_d93c6c9fa59ad0649a07dcce1924ac9a->doDisplay(Array, Array) #12 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array) #13 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array) #14 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array) #15 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/cla...', Array) #16 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('field_multiple_...', Array) #17 /code/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array) #18 /code/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array) #19 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #20 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array) #21 /tmp/rolling/4a6f9b5/twig/6442aaa046ece_node-edit-form.html.twig_6IvRpo8LMM79vlgE1EN6FQKYH/-LUlf70mQ5q_r3jRYdvRndx7paIbZSz8jScARe-tL-U.php(44): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #22 /code/vendor/twig/twig/src/Template.php(405): __TwigTemplate_8d7605f11e792d80e3297ebd3db6e904->doDisplay(Array, Array) #23 /code/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array) #24 /code/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array) #25 /code/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array) #26 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('core/themes/cla...', Array) #27 /code/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('node_edit_form', Array) #28 /code/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false) #29 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->render(Array, false) #30 /code/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() #31 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(243): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #32 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #33 /code/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #34 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #35 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #36 /code/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view') #37 /code/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #38 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #39 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #40 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #41 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #42 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #43 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #44 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #45 /code/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #46 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #47 {main}