1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-20 21:32:09 +02:00

Fixes #851 - Admin-UI - when the listQry doesn't contain backticks around table names.

This commit is contained in:
Cameron
2015-02-01 18:45:33 -08:00
parent 9e5f201ff1
commit af5c0b2ead
2 changed files with 34 additions and 4 deletions

View File

@@ -3411,6 +3411,7 @@ class e_admin_controller_ui extends e_admin_controller
}
}
// check for table & field aliases
$fields = array(); // preserve order
foreach ($this->fields as $field => $att)
@@ -3488,7 +3489,7 @@ class e_admin_controller_ui extends e_admin_controller
$this->fields = $fields;
$this->_alias_parsed = true;
return $this;
}
@@ -3544,6 +3545,23 @@ class e_admin_controller_ui extends e_admin_controller
}
/**
* Quick fix for bad custom $listQry;
*/
protected function parseCustomListQry($qry)
{
if(strpos($qry,'`')===false)
{
$ret = preg_replace("/FROM\s*(#[\w]*/","FROM `$1`", $qry); // backticks missing, so add them.
e107::getMessage()->addDebug('Your $listQry is missing `backticks` around the table name!');
return $ret;
}
return $qry;
}
// TODO - abstract, array return type, move to parent?
protected function _modifyListQry($raw = false, $isfilter = false, $forceFrom = false, $forceTo = false, $listQry = '')
{
@@ -3741,7 +3759,7 @@ class e_admin_controller_ui extends e_admin_controller
}
else
{
$qry = $listQry ? $listQry : "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields." FROM ".$tableFrom;
$qry = $this->parseCustomListQry($listQry) ? $listQry : "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields." FROM ".$tableFrom;
}
// group field - currently auto-added only if there are joins
@@ -3843,7 +3861,12 @@ class e_admin_controller_ui extends e_admin_controller
}
// Debug Filter Query.
if($listQry)
{
e107::getMessage()->addDebug('Using Custom listQry ');
}
e107::getMessage()->addDebug('QRY='.str_replace('#', MPREFIX, $qry));
// echo $qry.'<br />';
// print_a($this->fields);
// print_a($_GET);