pager_query() misses multi.line SELECT\tab\FROM\tab.. SQL-Strings

spiffl - July 30, 2007 - 15:19
Project:Drupal
Version:6.x-dev
Component:base system
Category:bug report
Priority:minor
Assigned:Unassigned
Status:duplicate
Description

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.

AttachmentSize
pager_count-query-matching.diff.txt800 bytes

#1

aufumy - October 31, 2007 - 23:05
Status:patch (code needs review)» patch (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.

#2

Gábor Hojtsy - November 4, 2007 - 16:31
Status:patch (reviewed & tested by the community)» patch (code needs work)

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

#3

Damien Tournoud - August 6, 2008 - 19:45
Status:patch (code needs work)» duplicate

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

 
 

Drupal is a registered trademark of Dries Buytaert.