I encounter the following stack trace when I am logged in as UID 0 and trying to check /search/node . However when I am anonymous user, it does not do this.

I would assume this is due to some other customization on my site. If I can isolate further, will share here.

[Mon Mar 12 15:02:48.725864 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP Fatal error:  "0" is an invalid render array key in /web/core/lib/Drupal/Core/Render/Element.php on line 97
[Mon Mar 12 15:02:48.725904 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP Stack trace:
[Mon Mar 12 15:02:48.725915 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   1. {main}() /web/index.php:0
[Mon Mar 12 15:02:48.725922 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   2. Drupal\\Core\\DrupalKernel->handle() /web/index.php:19
[Mon Mar 12 15:02:48.725928 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   3. Stack\\StackedHttpKernel->handle() /web/core/lib/Drupal/Core/DrupalKernel.php:657
[Mon Mar 12 15:02:48.725960 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   4. Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle() /vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
[Mon Mar 12 15:02:48.725967 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   5. Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() /web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50
[Mon Mar 12 15:02:48.725973 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   6. Drupal\\page_cache\\StackMiddleware\\PageCache->handle() /web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47
[Mon Mar 12 15:02:48.725979 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   7. Drupal\\page_cache\\StackMiddleware\\PageCache->pass() /web/core/modules/page_cache/src/StackMiddleware/PageCache.php:78
[Mon Mar 12 15:02:48.726005 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   8. Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle() /web/core/modules/page_cache/src/StackMiddleware/PageCache.php:99
[Mon Mar 12 15:02:48.726033 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP   9. Drupal\\Core\\StackMiddleware\\Session->handle() /web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47
[Mon Mar 12 15:02:48.726040 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  10. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /web/core/lib/Drupal/Core/StackMiddleware/Session.php:57
[Mon Mar 12 15:02:48.726045 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  11. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /vendor/symfony/http-kernel/HttpKernel.php:68
[Mon Mar 12 15:02:48.726054 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  12. call_user_func_array:{/vendor/symfony/http-kernel/HttpKernel.php:153}() /vendor/symfony/http-kernel/HttpKernel.php:153
[Mon Mar 12 15:02:48.726062 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  13. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() /vendor/symfony/http-kernel/HttpKernel.php:153
[Mon Mar 12 15:02:48.726069 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  14. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:97
[Mon Mar 12 15:02:48.726077 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  15. Drupal\\Core\\Render\\Renderer->executeInRenderContext() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:124
[Mon Mar 12 15:02:48.726083 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  16. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() /web/core/lib/Drupal/Core/Render/Renderer.php:582
[Mon Mar 12 15:02:48.726092 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  17. call_user_func_array:{/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
[Mon Mar 12 15:02:48.726100 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  18. Drupal\\search\\Controller\\SearchController->view() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
[Mon Mar 12 15:02:48.726108 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  19. Drupal\\Core\\Form\\FormBuilder->getForm() /web/core/modules/search/src/Controller/SearchController.php:88
[Mon Mar 12 15:02:48.726213 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  20. Drupal\\Core\\Form\\FormBuilder->buildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:212
[Mon Mar 12 15:02:48.726326 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  21. Drupal\\Core\\Form\\FormBuilder->prepareForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:272
[Mon Mar 12 15:02:48.726375 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  22. Drupal\\Core\\Extension\\ModuleHandler->alter() /web/core/lib/Drupal/Core/Form/FormBuilder.php:830
[Mon Mar 12 15:02:48.726423 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  23. themable_forms_form_alter() /web/core/lib/Drupal/Core/Extension/ModuleHandler.php:501
[Mon Mar 12 15:02:48.726466 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  24. themable_forms_attach_form_id() /web/modules/contrib/themable_forms/themable_forms.module:62
[Mon Mar 12 15:02:48.726502 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  25. themable_forms_attach_form_id() /web/modules/contrib/themable_forms/themable_forms.module:80
[Mon Mar 12 15:02:48.726521 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  26. themable_forms_attach_form_id() /web/modules/contrib/themable_forms/themable_forms.module:80
[Mon Mar 12 15:02:48.726541 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  27. themable_forms_attach_form_id() /web/modules/contrib/themable_forms/themable_forms.module:80
[Mon Mar 12 15:02:48.726564 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  28. Drupal\\Core\\Render\\Element::children() /web/modules/contrib/themable_forms/themable_forms.module:76
[Mon Mar 12 15:02:48.726589 2018] [php7:notice] [pid 27054] [client 10.12.80.159:61040] PHP  29. trigger_error() /web/core/lib/Drupal/Core/Render/Element.php:97

Based on these lines it involves the interesting recursive function here:

function themable_forms_attach_form_id(&$form, $form_id) {
  foreach (Element::children($form) as $child) {
    if (!isset($form[$child]['#form_id'])) {
      $form[$child]['#form_id'] = $form_id;
    }
    themable_forms_attach_form_id($form[$child], $form_id);
  }
}

Comments

HongPong created an issue. See original summary.

hongpong’s picture

Issue summary: View changes
hongpong’s picture

I also tried applying #2903660: Undefined index: #type in themable_forms_theme_suggestions_form_element() and that did not affect the issue.

hongpong’s picture

Status: Active » Closed (works as designed)

Sorry this error is reproducible without the module being enabled - i am closing with 'works as designed'.

hongpong’s picture

Title: "0" is an invalid render array key » "0" is an invalid render array key when enabled
Project: Themable forms » Better Search Block
Status: Closed (works as designed) » Active
Issue tags: +Element.php, +render array key

Ah the issue is actually with better_search module. When themable_forms is disabled and better_search is enabled, at /search/node with Bartik I get:


[Mon Mar 12 18:21:52.902074 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP Fatal error:  "0" is an invalid render array key in /web/core/lib/Drupal/Core/Render/Element.php on line 97
[Mon Mar 12 18:21:52.902125 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP Stack trace:
[Mon Mar 12 18:21:52.902133 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   1. {main}() /web/index.php:0
[Mon Mar 12 18:21:52.902138 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   2. Drupal\\Core\\DrupalKernel->handle() /web/index.php:19
[Mon Mar 12 18:21:52.902144 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   3. Stack\\StackedHttpKernel->handle() /web/core/lib/Drupal/Core/DrupalKernel.php:657
[Mon Mar 12 18:21:52.902150 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   4. Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle() /vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
[Mon Mar 12 18:21:52.902156 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   5. Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() /web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50
[Mon Mar 12 18:21:52.902164 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   6. Drupal\\page_cache\\StackMiddleware\\PageCache->handle() /web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47
[Mon Mar 12 18:21:52.902170 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   7. Drupal\\page_cache\\StackMiddleware\\PageCache->pass() /web/core/modules/page_cache/src/StackMiddleware/PageCache.php:78
[Mon Mar 12 18:21:52.902200 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   8. Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle() /web/core/modules/page_cache/src/StackMiddleware/PageCache.php:99
[Mon Mar 12 18:21:52.902232 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP   9. Drupal\\Core\\StackMiddleware\\Session->handle() /web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47
[Mon Mar 12 18:21:52.902238 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  10. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /web/core/lib/Drupal/Core/StackMiddleware/Session.php:57
[Mon Mar 12 18:21:52.902243 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  11. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /vendor/symfony/http-kernel/HttpKernel.php:68
[Mon Mar 12 18:21:52.902248 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  12. call_user_func_array:{/vendor/symfony/http-kernel/HttpKernel.php:153}() /vendor/symfony/http-kernel/HttpKernel.php:153
[Mon Mar 12 18:21:52.902254 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  13. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() /vendor/symfony/http-kernel/HttpKernel.php:153
[Mon Mar 12 18:21:52.902260 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  14. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:97
[Mon Mar 12 18:21:52.902266 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  15. Drupal\\Core\\Render\\Renderer->executeInRenderContext() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:124
[Mon Mar 12 18:21:52.902273 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  16. Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() /web/core/lib/Drupal/Core/Render/Renderer.php:582
[Mon Mar 12 18:21:52.902279 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  17. call_user_func_array:{/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
[Mon Mar 12 18:21:52.902316 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  18. Drupal\\search\\Controller\\SearchController->view() /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
[Mon Mar 12 18:21:52.902322 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  19. Drupal\\Core\\Form\\FormBuilder->getForm() /web/core/modules/search/src/Controller/SearchController.php:88
[Mon Mar 12 18:21:52.902376 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  20. Drupal\\Core\\Form\\FormBuilder->buildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:212
[Mon Mar 12 18:21:52.902405 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  21. Drupal\\Core\\Form\\FormBuilder->processForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:314
[Mon Mar 12 18:21:52.902411 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  22. Drupal\\Core\\Form\\FormBuilder->doBuildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:557
[Mon Mar 12 18:21:52.902416 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  23. Drupal\\Core\\Form\\FormBuilder->doBuildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:1056
[Mon Mar 12 18:21:52.902427 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  24. Drupal\\Core\\Form\\FormBuilder->doBuildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:1056
[Mon Mar 12 18:21:52.902508 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  25. Drupal\\Core\\Form\\FormBuilder->doBuildForm() /web/core/lib/Drupal/Core/Form/FormBuilder.php:1056
[Mon Mar 12 18:21:52.902643 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  26. Drupal\\Core\\Render\\Element::children() /web/core/lib/Drupal/Core/Form/FormBuilder.php:1010
[Mon Mar 12 18:21:52.902668 2018] [php7:notice] [pid 28133] [client 10.12.80.159:52618] PHP  27. trigger_error() /web/core/lib/Drupal/Core/Render/Element.php:97
hongpong’s picture

I think the problem is at:
$form['basic']['submit'] = ['class' => ['visually-hidden']];
This probably blows away the form. via var_dump($form['basic']['submit']) I get:

array (size=2)
  '#type' => string 'submit' (length=6)
  '#value' => 
    object(Drupal\Core\StringTranslation\TranslatableMarkup)[511]
      protected 'string' => string 'Search' (length=6)
      protected 'translatedMarkup' => null
      protected 'options' => 
        array (size=0)
          empty
      protected 'stringTranslation' => 
        object(Drupal\Core\StringTranslation\TranslationManager)[296]
          protected 'translators' => 
            array (size=1)
              ...
          protected 'sortedTranslators' => null
          protected 'defaultLangcode' => string 'en' (length=2)
          public '_serviceId' => string 'string_translation' (length=18)
      protected 'arguments' => 
        array (size=0)
          empty
3cwebdev’s picture

Assigned: Unassigned » yogeshmpawar
hongpong’s picture

Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new0 bytes

Hi,

Here this adds two configuration options, to allow us to shut off the alteration of search pages. It also adds configuration toggle for 'visually hidden' and makes it so that statement doesn't give a fatal error. There is also an upgrade .install added, so that the current behavior is preserved, but now made configurable. Not too bad. I tested it and it seems to work as expected. Best regards!

.. edit - patch generating problem, one moment please

3cwebdev’s picture

Hi HongPong,

The patch you attached is empty.

hongpong’s picture

StatusFileSize
new4.37 KB

fixed patch sorry!

hongpong’s picture

StatusFileSize
new4.34 KB

newline was missing on install file. this should add that

yogeshmpawar’s picture

checking this issue.

  • Yogesh Pawar committed 075458d on 8.x-1.x authored by HongPong
    Issue #2952367 by HongPong, quantumized, Yogesh Pawar: "0" is an invalid...
yogeshmpawar’s picture

Status: Needs review » Fixed

Looks good to me so committed & pushed to 8.x-1.x branch.
Thanks @HongPong for pointing this issue & working on patch.

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned

Status: Fixed » Closed (fixed)

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

ddhuri’s picture

Thanks HongPong,

Patch #11 Works for me.