Problem/Motivation

Using ->range() in EntityFieldQuery returns zero rows. Same if you extend SelectQuery, implement it with parent::range($start, $length) and then call ->range() on the extended class.

Proposed resolution

Remove func_num_args() from the method.

Remaining tasks

None.

User interface changes

None.

API changes

Previously if you called ->range($start) this resulted in 0 rows, it will result in all rows now. Note that MySQL does not support just specifying a start without a limit and so this is a rather pointless call and as it always resulted in 0 rows it's extremely unlikely anyone used it. If you were using ->range($start, $length) where $length can be 0, your code still will work.

Comments

chx’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, range_extended_or_efq_returns_zero_rows.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.51 KB

sigh.

Status: Needs review » Needs work

The last submitted patch, range_extended_or_efq_returns_zero_rows.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.51 KB

This is what happens when i develop on D7 and upload a D8patch.

Status: Needs review » Needs work

The last submitted patch, range_extended_or_efq_returns_zero_rows.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new1.55 KB

Keeping up w HEAD

Crell’s picture

Status: Needs review » Needs work

chx and I discussed this in IRC previously. This is the correct fix for Drupal 7, but a stopgap for 8. Ideally I'd like to get rid of range() and specify limit and offset in separate methods, but we can do that later.

My only concern is that it would be better to test the builder directly. We should not go through EFQ, which is not part of the database system, to test SelectQuery when we can just test SelectQuery directly.

chx’s picture

Status: Needs work » Needs review

To the contrary, testing this directly makes no sense as it would require a call to range(NULL, NULL) which is pretty WTF-y. We do not particularly care how a ->range() call results in a removal of range conditions only that in it happens. And if I just use a ->range() call that won't catch the bug! Or you want me to extend that class just for a test? That'd be a waste of time and effort.

chx’s picture

Ie. if you want me to write another test give me some example code that can be fleshed out into a test.

kscheirer’s picture

#7: 1461890-7.patch queued for re-testing.

kscheirer’s picture

Retesting against latest HEAD since it has been over a year.

Status: Needs review » Needs work

The last submitted patch, 1461890-7.patch, failed testing.

chx’s picture

Version: 8.x-dev » 7.x-dev

Aaand it's gone. From D8 at least.

jibran’s picture

Assigned: chx » Unassigned
Issue summary: View changes
Status: Needs work » Patch (to be ported)

According to #14

Status: Patch (to be ported) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.