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

Risky count() in SQLite Statement

$
0
0

In Drupal\Core\Database\Driver\sqlite\Statement::getStatement we have the following:

  protected function getStatement($query, &$args = []) {
    if (count($args)) {
      // Check if $args is a simple numeric array.
      if (range(0, count($args) - 1) === array_keys($args)) {

under PHP 7.2, if for any reason the $args is NULL or not an array, this will lead to notices and/or test failures, like

1) Drupal\KernelTests\Core\Database\DatabaseExceptionWrapperTest::testPreparedStatement
Thrown exception is not a PDOException:
count(): Parameter must be an array or an object that implements Countable
/home/travis/drupal8/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:262
/home/travis/drupal8/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php:30
/home/travis/drupal8/core/lib/Drupal/Core/Database/StatementPrefetch.php:158
/home/travis/drupal8/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php:90
/home/travis/drupal8/core/lib/Drupal/Core/Database/Connection.php:612
/home/travis/drupal8/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php:28
/home/travis/drupal8/core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php:39

Note: There is no SQLite testing on DrupalCI with PHP 7.2, yet - it's likely that this will appear once there'll be. The error above is result from a TravisCI test.


Viewing all articles
Browse latest Browse all 300530

Trending Articles



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