Bug #14267
closed
sorting must be set for pi_list_query to work
Added by old_cazoo over 20 years ago.
Updated over 18 years ago.
Description
In class.tslib_pibase.php the function pi_list_query() specifies "orderBy" as an optional param. However, it fails if no orderBy (can be empty) is set. This also affects pi_exec_query().
For example this code:
$this->pi_list_query("tx_some_table");
... generates non-vaild SQL like this:
" .... ORDER BY tx_some_table. LIMIT x,y"
(issue imported from #M280)
In the function tslib_pibase::pi_list_query() I suggest to change the following lines from:
// Order by data:
if (!$orderBy) {
if (t3lib_div::inList($this->internal['orderByList'],$this->internal['orderBy'])) {
$orderBy = 'ORDER BY '.$table.'.'.$this->internal['orderBy'].($this->internal['descFlag']?' DESC':'');
}
}
To:
// Order by data:
if (!$orderBy && $this->internal['orderBy']) {
if (t3lib_div::inList($this->internal['orderByList'],$this->internal['orderBy'])) {
$orderBy = 'ORDER BY '.$table.'.'.$this->internal['orderBy'].($this->internal['descFlag']?' DESC':'');
}
}
So the condition includes a check for $this->internal['orderBy'].
Cazoo, can you please verify that my fix works and does not cause any harm?
I would commit the fix to the CVS then.
I would if I could - my testplatform is currently under re-construction after a HD crash. I will test your fix when I'm and running, but it might take a while.
did you test it?
Otherwise it will not go into 3.7.
Also available in: Atom
PDF