DatabaseStorage, readMultiple throws error when receive empty array

Created on 23 January 2024, about 1 year ago
Updated 24 August 2024, 7 months ago

Problem/Motivation

SQLSTATE[42000]: Syntax error or access violation: 1064 is triggered when we pass empty array with name to readMultiple method, when trying to get information about setting.

I hit a case where I pass empty array to this method and SQL error is thrown.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1: SELECT "name", "data" FROM "config" WHERE "collection" = :collection AND "name" IN ( ); Array ( [:collection] => ) in Drupal\Core\Config\DatabaseStorage->readMultiple() (line 115 of core/lib/Drupal/Core/Config/DatabaseStorage.php).

Steps to reproduce

Inject config.storage.active into a class (as it is not public you should not be able to use \Drupal::service('config.storage.active')
Call $active_storage->readMultiple([]);

Proposed resolution

First check if the value is not empty, otherwise return empty array.

Remaining tasks

Review

šŸ› Bug report
Status

Fixed

Version

10.3 āœØ

Component
ConfigurationĀ  ā†’

Last updated 1 day ago

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024