@trigger_error('db_query_range() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call queryRange() on it. For example, $injected_database->queryRange($query, $from, $count, $args, $options). See https://www.drupal.org/node/2993033',E_USER_DEPRECATED);
@@ -150,7 +151,7 @@ public function getFeedEditObject($feed_url = NULL, array $values = []) {
*/
publicfunctiongetDefaultFeedItemCount(){
// Our tests are based off of rss.xml, so let's find out how many elements should be related.
$feed_count=db_query_range('SELECT COUNT(DISTINCT nid) FROM {node_field_data} n WHERE n.promote = 1 AND n.status = 1',0,$this->config('system.rss')->get('items.limit'))->fetchField();
$feed_count=Database::getConnection()->queryRange('SELECT COUNT(DISTINCT nid) FROM {node_field_data} n WHERE n.promote = 1 AND n.status = 1',0,$this->config('system.rss')->get('items.limit'))->fetchField();
@@ -147,7 +148,7 @@ public function getFeedEditObject($feed_url = NULL, array $values = []) {
*/
publicfunctiongetDefaultFeedItemCount(){
// Our tests are based off of rss.xml, so let's find out how many elements should be related.
$feed_count=db_query_range('SELECT COUNT(DISTINCT nid) FROM {node_field_data} n WHERE n.promote = 1 AND n.status = 1',0,$this->config('system.rss')->get('items.limit'))->fetchField();
$feed_count=Database::getConnection()->queryRange('SELECT COUNT(DISTINCT nid) FROM {node_field_data} n WHERE n.promote = 1 AND n.status = 1',0,$this->config('system.rss')->get('items.limit'))->fetchField();
@@ -174,7 +175,7 @@ public function testImmutableFormLegacyProtection() {
// Assert that a watchdog message was logged by
// \Drupal::formBuilder()->setCache().
$status=(bool)db_query_range('SELECT 1 FROM {watchdog} WHERE message = :message',0,1,[':message'=>'Form build-id mismatch detected while attempting to store a form in the cache.']);
$status=(bool)Database::getConnection()->queryRange('SELECT 1 FROM {watchdog} WHERE message = :message',0,1,[':message'=>'Form build-id mismatch detected while attempting to store a form in the cache.']);
$this->assert($status,'A watchdog message was logged by \Drupal::formBuilder()->setCache');
// Ensure that the form state was not poisoned by the preceding call.
@@ -398,4 +398,14 @@ public function testDbQueryTemporary() {
$this->assertSame($expected,$count);
}
/**
* Tests deprecation of the db_query_range() function.
*
* @expectedDeprecation db_query_range() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call queryRange() on it. For example, $injected_database->queryRange($query, $from, $count, $args, $options). See https://www.drupal.org/node/2993033
*/
publicfunctiontestDbQueryRange(){
$count=count(db_query_range('SELECT name FROM {test}',1,3)->fetchAll());