diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php index 76e93fc..455c294 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php @@ -39,10 +39,7 @@ protected function getStatement($query, &$args = array()) { $count = 0; $new_args = array(); foreach ($args as $value) { - // Integers expressed as strings (e.g. '5') have to treated as numeric - // values. Sadly, PHP has an upper limit on integers, PHP_INT_MAX, so - // we can not support numbers higher than that. - if (is_float($value) || is_int($value) || (is_numeric($value) && $value <= PHP_INT_MAX)) { + if (is_float($value) || is_int($value)) { if (is_float($value)) { // Force the conversion to float so as not to loose precision // in the automatic cast. @@ -61,10 +58,7 @@ protected function getStatement($query, &$args = array()) { else { // Else, this is using named placeholders. foreach ($args as $placeholder => $value) { - // Integers expressed as strings (e.g. '5') have to treated as numeric - // values. Sadly, PHP has an upper limit on integers, PHP_INT_MAX, so - // we can not support numbers higher than that. - if (is_float($value) || is_int($value) || (is_numeric($value) && $value <= PHP_INT_MAX)) { + if (is_float($value) || is_int($value)) { if (is_float($value)) { // Force the conversion to float so as not to loose precision // in the automatic cast. diff --git a/core/modules/system/src/Tests/Database/QueryTest.php b/core/modules/system/src/Tests/Database/QueryTest.php index a799d60..be0dbc7 100644 --- a/core/modules/system/src/Tests/Database/QueryTest.php +++ b/core/modules/system/src/Tests/Database/QueryTest.php @@ -80,12 +80,6 @@ public function testNumericExpressionSubstitution() { ':count' => 3, ))->fetchField(); $this->assertEqual((bool) $count, TRUE); - - // Test that numeric arguments expressed as strings also work properly. - $count = db_query('SELECT COUNT(*) >= :count FROM {test}', array( - ':count' => (string) 3, - ))->fetchField(); - $this->assertEqual((bool) $count, TRUE); } } diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php index a077b73..9713351 100644 --- a/core/modules/views/src/Plugin/views/filter/StringFilter.php +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php @@ -320,12 +320,16 @@ protected function opNotLike($field) { protected function opShorterThan($field) { $placeholder = $this->placeholder(); - $this->query->addWhereExpression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => $this->value)); + // Type cast the argument to an integer because the SQLite database driver + // has to do some specific alterations to the query base on that data type. + $this->query->addWhereExpression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => (int) $this->value)); } protected function opLongerThan($field) { $placeholder = $this->placeholder(); - $this->query->addWhereExpression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => $this->value)); + // Type cast the argument to an integer because the SQLite database driver + // has to do some specific alterations to the query base on that data type. + $this->query->addWhereExpression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => (int) $this->value)); } /** diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 41ff298..cfdbc83 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -745,7 +745,18 @@ function _views_query_tag_alter_condition(AlterableInterface $query, &$condition views_query_views_alter($condition['value']); } elseif (isset($condition['value'])) { - $condition['value'] = str_replace(array_keys($substitutions), array_values($substitutions), $condition['value']); + // We can not use a simple str_replace() here because it always returns + // a string and we have to keep the type of the condition value intact. + if (is_array($condition['value'])) { + foreach ($condition['value'] as &$value) { + if (is_string($value)) { + $value = str_replace(array_keys($substitutions), array_values($substitutions), $value); + } + } + } + elseif (is_string($condition['value'])) { + $condition['value'] = str_replace(array_keys($substitutions), array_values($substitutions), $condition['value']); + } } } }