Undefined array key 0 in Drupal\Core\Database\Query\Condition->condition()

Created on 9 January 2025, 13 days ago

Problem/Motivation

I have to remove the Warning: Undefined array key 0 en Drupal\Core\Database\Query\Condition->condition() (línea 116 de /var/www/html/web/core/lib/Drupal/Core/Database/Query/Condition.php)

Steps to reproduce

you may install Drupal 10.4.1

Proposed resolution

In the line 116 add a if

if(isset($value[0])){
    $value = $value[0];
}

Instead of this

$value = $value[0];
🐛 Bug report
Status

Active

Version

10.4

Component

other

Created by

🇪🇸Spain jifernandezs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jifernandezs
  • I am unable to reproduce this bug as written. I am tagging this for needing more steps to reproduce.

  • 🇪🇸Spain jifernandezs

    I have PHP 8.1.29 and I have Drupal 10.4.1. you need to configure the enviroment to show all errors and warmings.

    This is my recent messages of register tab information:

    Mensaje Warning: Undefined array key 0 en Drupal\Core\Database\Query\Condition->condition() (línea 114 de /var/www/html/web/core/lib/Drupal/Core/Database/Query/Condition.php)
    #0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
    #1 /var/www/html/web/core/lib/Drupal/Core/Database/Query/Condition.php(114): _drupal_error_handler()
    #2 /var/www/html/web/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php(27): Drupal\Core\Database\Query\Condition->condition()
    #3 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(77): Drupal\Core\Database\Query\Select->condition()
    #4 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
    #5 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(82): Drupal\Core\Entity\Query\Sql\Query->compile()
    #6 /var/www/html/web/modules/custom/grid_news/grid_news.module(343): Drupal\Core\Entity\Query\Sql\Query->execute()
    #7 /var/www/html/web/modules/custom/grid_news/grid_news.module(49): grid_news_creation()
    #8 [internal function]: grid_news_entity_presave()
    #9 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): call_user_func_array()
    #10 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
    #11 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(423): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #12 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(217): Drupal\Core\Extension\ModuleHandler->invokeAll()
    #13 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
    #14 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(529): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
    #15 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(753): Drupal\Core\Entity\EntityStorageBase->doPreSave()
    #16 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave()
    #17 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(806): Drupal\Core\Entity\EntityStorageBase->save()
    #18 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
    #19 /var/www/html/web/modules/custom/grid_news/grid_news.module(249): Drupal\Core\Entity\EntityBase->save()
    #20 /var/www/html/web/modules/custom/grid_news/grid_news.module(149): reloadGrid()
    #21 [internal function]: grid_news_entity_update()
    #22 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): call_user_func_array()
    #23 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
    #24 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(423): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #25 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(217): Drupal\Core\Extension\ModuleHandler->invokeAll()
    #26 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
    #27 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(564): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
    #28 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave()
    #29 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(489): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
    #30 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(806): Drupal\Core\Entity\EntityStorageBase->save()
    #31 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
    #32 /var/www/html/web/modules/custom/chg/chg.module(880): Drupal\Core\Entity\EntityBase->save()
    #33 [internal function]: chg_entity_view()
    ...

    What would may you help to reproduce this warning?

  • There seems to be something with a custom grid_news module which isn't part of a default Drupal install. Perhaps it has a coding bug.

    I updated this comment to fix my typos.

Production build 0.71.5 2024