I've wondered why pager_query() returned me 41 results, when there were only 36 nodes in the table.

Reason: db_result in combination with a multi-line SQL string misses to match a query (see below) that contains tabs or newlines.
$query = "
SELECT
n.nid,
n.title,
n.uid,
n.type,
n.status,
n.created,
u.name AS username
FROM
{node} n
...
";

The attached patch properly checks for whitespace instead of space-character and matches also the above query.

CommentFileSizeAuthor
pager_count-query-matching.diff.txt800 bytesspiffl

Comments

aufumy’s picture

Status: Needs review » Reviewed & tested by the community

Tested on pager.inc revision 1.62, and indeed the sql query on different lines returned only the first page of 10 nodes, instead of 4 pages of 35 nodes.

Applying the patch produced the correct results.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Why do we restrict the ORDER BY to work with spaces only then?

damien tournoud’s picture

Status: Needs work » Closed (duplicate)

Now a duplicate of #288837: Pager.inc regexp misses whitespace use case, even if this one is older.