The DS configurations are empty on template_preprocess_ds_entity_view and could lead to WOD if no conditional statements there to check if the configurations exits before creating the instance.
Recoverable fatal error: Argument 2 passed to Drupal\\Component\\Plugin\\PluginManagerBase::createInstance() must be of the type array, null given, called in /Users/heshan/Sites/.../modules/contrib/ds/ds.module on line 318

Patch attached.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

heshanlk created an issue. See original summary.

heshanlk’s picture

Status: Active » Needs review
FileSize
433 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 2864864-patch.diff, failed testing.

heshanlk’s picture

FileSize
427 bytes
heshanlk’s picture

Status: Needs work » Needs review
swentel’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests
+++ b/ds.module
@@ -274,6 +274,7 @@ function ds_entity_view_alter(&$build, EntityInterface $entity, EntityDisplayInt
+  if(empty($configuration)) return;

please make sure this is following the coding standards

heshanlk’s picture

Status: Needs work » Needs review
FileSize
439 bytes

Status: Needs review » Needs work

The last submitted patch, 7: 2864864-patch_1.diff, failed testing.

heshanlk’s picture

Status: Needs work » Needs review
FileSize
439 bytes
aspilicious’s picture

Status: Needs review » Closed (cannot reproduce)

#ds_configuration can't be empty... I think this was caused by the failing upgrade path.

fabianderijk’s picture

Version: 8.x-3.x-dev » 8.x-3.1
Status: Closed (cannot reproduce) » Reviewed & tested by the community

This is actually still an issue for me as you can see in the stacktrace below. Using the patch in #9 everything works OK. I get this error when indexing my content with search_api, or when saving the nodes. What I saw using XDebug was that the $variables['content'] value was empty as well.

array_keys() expects parameter 1 to be array, null given ds.module:433                                                                                                                                                             [warning]
Invalid argument supplied for foreach() ds.module:433                                                                                                                                                                              [warning]
TypeError: Argument 2 passed to Drupal\Component\Plugin\PluginManagerBase::createInstance() must be of the type array, null given, called in                                                                                       [error]
/Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/ds/ds.module on line 458 in Drupal\Component\Plugin\PluginManagerBase->createInstance() (line 71 of
/Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Component/Plugin/PluginManagerBase.php) #0 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/ds/ds.module(458):
Drupal\Component\Plugin\PluginManagerBase->createInstance(NULL, NULL)
#1 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): template_preprocess_ds_entity_view(Array, 'ds_entity_view', Array)
#2 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(435): Drupal\Core\Theme\ThemeManager->render('ds_entity_view', Array)
#3 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false)
#4 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array)
#5 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code(257): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL,
true)
#6 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(677): __TwigTemplate_6f9c4b23c672d2a1b2cf2964ea7b5d41e2b5759c915ad22af44ffa3a2135e0b7->getcontent(Array, Array, Object(Drupal\ds\DsAttribute))
#7 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code(188): Twig_Template->getAttribute(Object(__TwigTemplate_6f9c4b23c672d2a1b2cf2964ea7b5d41e2b5759c915ad22af44ffa3a2135e0b7),
'content', Array, 'method')
#8 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(677): __TwigTemplate_6f9c4b23c672d2a1b2cf2964ea7b5d41e2b5759c915ad22af44ffa3a2135e0b7->getfield(Array, Array, 'Page content',
Object(Drupal\Core\Template\Attribute), Object(Drupal\ds\DsAttribute), Object(Drupal\ds\DsAttribute), Object(Drupal\ds\DsAttribute), true, Array)
#9 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code(76): Twig_Template->getAttribute(Object(__TwigTemplate_6f9c4b23c672d2a1b2cf2964ea7b5d41e2b5759c915ad22af44ffa3a2135e0b7),
'field', Array, 'method')
#10 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_6f9c4b23c672d2a1b2cf2964ea7b5d41e2b5759c915ad22af44ffa3a2135e0b7->doDisplay(Array, Array)
#11 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array)
#12 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array)
#13 /Users/fabianderijk/Sites/ow/profile/docroot/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array)
#14 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('profiles/open_w...', Array)
#15 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(435): Drupal\Core\Theme\ThemeManager->render('field', Array)
#16 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(448): Drupal\Core\Render\Renderer->doRender(Array)
#17 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false)
#18 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array)
#19 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code(75): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL,
true)
#20 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_f90202fafcfe35b65e7baf26bd2a3e7ff05e1af84801ccb8f7509db20d5983b4->doDisplay(Array, Array)
#21 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array)
#22 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array)
#23 /Users/fabianderijk/Sites/ow/profile/docroot/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array)
#24 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('profiles/open_w...', Array)
#25 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(435): Drupal\Core\Theme\ThemeManager->render('ds_2col_stacked', Array)
#26 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false)
#27 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array)
#28 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Environment.php(462) : eval()'d code(43): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL,
true)
#29 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_3455d298a8a6bedcc477416b512495999e99e9e37688022039b7f38d1744ddca->doDisplay(Array, Array)
#30 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array)
#31 /Users/fabianderijk/Sites/ow/profile/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array)
#32 /Users/fabianderijk/Sites/ow/profile/docroot/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array)
#33 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('profiles/open_w...', Array)
#34 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(435): Drupal\Core\Theme\ThemeManager->render('ds_entity_view', Array)
#35 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true)
#36 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(151): Drupal\Core\Render\Renderer->render(Array, true)
#37 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#38 /Users/fabianderijk/Sites/ow/profile/docroot/core/lib/Drupal/Core/Render/Renderer.php(152): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#39 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/search_api/src/Plugin/search_api/processor/RenderedItem.php(272): Drupal\Core\Render\Renderer->renderPlain(Array)
#40 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/search_api/src/Item/Item.php(252):
Drupal\search_api\Plugin\search_api\processor\RenderedItem->addFieldValues(Object(Drupal\search_api\Item\Item))
#41 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/search_api/src/Entity/Index.php(935): Drupal\search_api\Item\Item->getFields()
#42 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/search_api/src/Entity/Index.php(893): Drupal\search_api\Entity\Index->indexSpecificItems(Array)
#43 /Users/fabianderijk/Sites/ow/profile/docroot/profiles/open_world/modules/contrib/search_api/src/IndexBatchHelper.php(154): Drupal\search_api\Entity\Index->indexItems(2)
#44 /Users/fabianderijk/drush/commands/core/drupal/batch.inc(163): Drupal\search_api\IndexBatchHelper::process(Object(Drupal\search_api\Entity\Index), 50, 2, Object(DrushBatchContext))
#45 /Users/fabianderijk/drush/commands/core/drupal/batch.inc(111): _drush_batch_worker()
#46 /Users/fabianderijk/drush/includes/batch.inc(98): _drush_batch_command('8')
#47 /Users/fabianderijk/drush/commands/core/core.drush.inc(1212): drush_batch_command('8')
#48 /Users/fabianderijk/drush/includes/command.inc(422): drush_core_batch_process('8')
#49 /Users/fabianderijk/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#50 /Users/fabianderijk/drush/includes/command.inc(199): drush_command('8')
#51 /Users/fabianderijk/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#52 /Users/fabianderijk/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#53 /Users/fabianderijk/drush/drush.php(12): drush_main()
#54 {main}.
rwam’s picture

Same problem here. The patch #9 works for me too, but it doesn't handle the previous notice:

Notice: Undefined index: #ds_configuration in template_preprocess_ds_entity_view() (line 414 of /xxx/modules/ds/ds.module)

May it's related to the Drupal Core Update from 8.3.5 to 8.3.6, which I did last week. And the error has only occurred after a content has been edited.

rwam’s picture

Priority: Normal » Major

I would change this to Major (or Critical?), because all of our live sites are affected.

rwam’s picture

Priority: Major » Normal

Back to Normal. After using the changes from the patch, it works. But I can remove the affected lines again and I cannot reproduce this error now. Strange…

rwam’s picture

The attached patch removes the notice and the error and leads to a working environment for me.

aspilicious’s picture

As I said before, this bug is caused by a broken configuration in the system.
This patch just removes the warning it doesn't fix the configuration.