Adding backticks instead of quotation marks in query creation for field names

Created on 27 November 2024, 25 days ago

Problem/Motivation

In web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php function tableExists tries to check `information_schema.tables` but the field names are given in quotation marks instead of backticks. It produces an error below:

SQLSTATE[HY000]: General error: 2000 Unknown or undefined error code: SELECT 1 FROM information_schema.tables WHERE ("table_schema" = :db_condition_placeholder_0) AND ("table_name" = :db_condition_placeholder_1); Array ( [:db_condition_placeholder_0] => tdxhilyswq_drupalfilharmonia [:db_condition_placeholder_1] => semaphore ) w Drupal\Core\Lock\DatabaseLockBackend->catchException() (linia 207 w /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php)
#0 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Database/Connection.php(883): Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException(Object(PDOException), Object(Drupal\Core\Database\StatementWrapperIterator), Array, Array)
#1 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Database/Schema.php(178): Drupal\Core\Database\Connection->query('SELECT 1 FROM i...', Array)
#2 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php(207): Drupal\Core\Database\Schema->tableExists('semaphore')
#3 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php(154): Drupal\Core\Lock\DatabaseLockBackend->catchException(Object(Drupal\Core\Database\DatabaseExceptionWrapper))
#4 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/ProxyClass/Lock/DatabaseLockBackend.php(91): Drupal\Core\Lock\DatabaseLockBackend->release('locale:pl::anon...')
#5 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Cache/CacheCollector.php(268): Drupal\Core\ProxyClass\Lock\DatabaseLockBackend->release('locale:pl::anon...')
#6 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/Cache/CacheCollector.php(339): Drupal\Core\Cache\CacheCollector->updateCache()
#7 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/modules/locale/src/LocaleTranslation.php(158): Drupal\Core\Cache\CacheCollector->destruct()
#8 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(723): Drupal\locale\LocaleTranslation->destruct()
#9 /home/tdxhilyswq/domains/tdxhilyswq.cfolks.pl/public_html/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#10 {main}

Manualy entering this query produces always 0 results. When quptation marks are changed to backticks query results are correct.
It produces an error witch logs and bother our clients and developers.

Proposed resolution

The query generation should be changed so that the field names in the table are always between backtick characters.

🐛 Bug report
Status

Active

Version

10.3

Component

database system

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • How would another developer reproduce this bug? Please add those steps to the issue summary.

  • 🇳🇿New Zealand quietone

    Changing status since we needs steps to reproduce.

    Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

Production build 0.71.5 2024