Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 301123

DatabaseStorage, readMultiple throws error when receive empty array

$
0
0

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


Viewing all articles
Browse latest Browse all 301123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>