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.
Problem/Motivation
In core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php file testRange() function has unused variables such as $name_field and $age_field
public function testRangeUndo() {
$query = $this->connection->select('test');
$name_field = $query->addField('test', 'name');
$age_field = $query->addField('test', 'age', 'age');
$query->range(0, 2);
$query->range(NULL, NULL);
$query_result = $query->countQuery()->execute()->fetchField();
Proposed resolution
public function testRangeUndo() {
$query = $this->connection->select('test');
- $name_field = $query->addField('test', 'name');
- $age_field = $query->addField('test', 'age', 'age');
+ $query->addField('test', 'name');
+ $query->addField('test', 'age', 'age');
$query->range(0, 2);
$query->range(NULL, NULL);
$query_result = $query->countQuery()->execute()->fetchField();
Comment | File | Size | Author |
---|---|---|---|
unsused-variable-removed.patch | 791 bytes | Hardik_Patel_12 | |
Comments
Comment #2
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedComment #3
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedHi, the patch applies cleanly and the test run without errors. Looks good to be merged.
Comment #4
siddhant.bhosale CreditAttribution: siddhant.bhosale as a volunteer and at QED42 commentedAs per @kiamlaluno's comment on the similar issue https://www.drupal.org/project/drupal/issues/3158266,
I am changing the status to Needs work.
Comment #5
paulocsSo we can see in the issue #1806606: Drupal\Core\Database\Query\Select::range() doesn't correctly implement SelectInterface that those variables were added there.
It's no problem to remove them as they are not used. Bellow is code that added the variablels:
Cheers,
Paulo
Comment #6
paulocsComment #7
alexpottCommitted and pushed fde0132b02 to 9.1.x and 1345c2113c to 9.0.x and bcc48076e3 to 8.9.x. Thanks!
Comment #11
alexpottBackported to 8.9.x to keep tests aligned.