Index: branches/5.3.x/core/kernel/db/dblist.php
===================================================================
diff -u -r15902 -r16111
--- branches/5.3.x/core/kernel/db/dblist.php (.../dblist.php) (revision 15902)
+++ branches/5.3.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16111)
@@ -1,6 +1,6 @@
Records = $this->Conn->Query($sql);
if (!$this->Records && ($this->Page > 1)) {
- // no records & page > 1, show 404 page
- trigger_error('Unknown page ' . $this->Page . ' in ' . $this->getPrefixSpecial() . ' list, leading to "404 Not Found"', E_USER_NOTICE);
-
- $this->Application->UrlManager->show404();
+ if ( $this->Application->isAdmin ) {
+ // no records & page > 1, try to reset to 1st page (works only when list in not counted before)
+ $this->Application->StoreVar($this->getPrefixSpecial() . '_Page', 1, true);
+ $this->SetPage(1);
+ $this->Query($force);
+ }
+ else {
+ // no records & page > 1, show 404 page
+ trigger_error('Unknown page ' . $this->Page . ' in ' . $this->getPrefixSpecial() . ' list, leading to "404 Not Found"', E_USER_NOTICE);
+ $this->Application->UrlManager->show404();
+ }
}
$this->SelectedCount = count($this->Records);
@@ -697,7 +704,7 @@
if ( $for_counting ) {
$usage_string = $where . '|' . $having . '|' . $order . '|' . $group . '|' . $keep_clause;
- $optimizer = new LeftJoinOptimizer($q, str_replace('%1$s', $this->TableName, $usage_string));
+ $optimizer = new LeftJoinOptimizer($q, $this->replaceModePrefix( str_replace('%1$s', $this->TableName, $usage_string) ));
$q = $optimizer->simplify();
}
@@ -745,7 +752,12 @@
$where = $this->Application->makeClass('kMultipleFilter');
/* @var $where kMultipleFilter */
- $where->addFilter('system_where', $this->WhereFilter[self::FLT_SYSTEM] );
+ if ( $for_counting ) {
+ $where->addFilter('system_where', $this->extractCalculatedFields($this->WhereFilter[self::FLT_SYSTEM]->getSQL()) );
+ }
+ else {
+ $where->addFilter('system_where', $this->WhereFilter[self::FLT_SYSTEM] );
+ }
if (!$system_filters_only) {
$where->addFilter('view_where', $this->WhereFilter[self::FLT_VIEW] );
@@ -1653,7 +1665,7 @@
*/
private function parseJoins()
{
- if ( !preg_match_all('/LEFT\s+JOIN\s+(.*?|.*?\s+AS\s+.*?|.*?\s+.*?)\s+ON\s+(.*?\n|.*?$)/i', $this->sql, $regs) ) {
+ if ( !preg_match_all('/LEFT\s+JOIN\s+(.*?|.*?\s+AS\s+.*?|.*?\s+.*?)\s+ON\s+(.*?\n|.*?$)/si', $this->sql, $regs) ) {
$this->joins = Array ();
}
@@ -1758,4 +1770,4 @@
{
return preg_match('/(`' . $escaped_alias . '`|' . $escaped_alias . ')\./', $string);
}
-}
\ No newline at end of file
+}