Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21fo...
The code shown in that page still uses Drupal 6 placeholders for the query string. I am referring to this line, where %d is used as placeholder.
$result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
The next line even calls a function (db_fetch_object()
) that doesn't exist anymore in Drupal 8.
while ($row = db_fetch_array($result)) {
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff-2729171-7-9.txt | 1.3 KB | Vinay15 |
#9 | remove-deprecated-function-2729171-9.patch | 1.46 KB | Vinay15 |
#7 | interdiff-2729171-3-7.txt | 708 bytes | Vinay15 |
#7 | remove-deprecated-function-2729171-7.patch | 888 bytes | Vinay15 |
#3 | remove-drupal-6-code-2729171-3.patch | 871 bytes | apaderno |
Comments
Comment #2
apadernoI am changing the title, since the arguments for
db_query_range()
are in the wrong order: They should be as indb_query_range($query, $from, $count, array $args = array(), array $options = array())
, but the code is putting$from
and$count
after the query placeholder array.Comment #3
apadernoI am attaching the patch I am suggesting.
Comment #4
apadernoThe patch is also required for Drupal 7, for the same errors in the code.
Comment #5
jhodgdonThis looks good for Drupal 7 (and we should create a child issue for Drupal 7). However, in Drupal 8 db_query_range() is deprecated, so we should probably rewrite the code so it doesn't use it?
Comment #6
Vinay15Comment #7
Vinay15I have removed db_query_range() and tried to update the patch in #3.
Comment #8
jhodgdonThis looks right to me, thanks!
While we are at it, should we also fix a few lines above:
$context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
}
db_query() is also deprecated.
Comment #9
Vinay15I have updated both deprecated functions db_query() and db_query_range() in this patch.
Comment #10
jhodgdonLooks good now, thanks!
Comment #13
xjmGood catch!
Committed to 8.2.x and cherry-picked to 8.1.x. Thanks!
Comment #14
xjmCorollary: The batch API has not received a significant update since Drupal 6. :P