Fixed bug #9861: Second page of results in list-module with ordering flaw (credits...
authorIngo Renner <ingo.renner@typo3.org>
Sun, 8 Feb 2009 19:23:25 +0000 (19:23 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Sun, 8 Feb 2009 19:23:25 +0000 (19:23 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4971 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/class.db_list_extra.inc

index 235c5af..dcf75b1 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
+2009-02-08  Ingo Renner  <ingo@typo3.org>
+
+       * Fixed bug #9861: Second page of results in list-module with ordering flaw (credits Christian Kuhn)
+
 2009-02-07  Steffen Kamper  <info@sk-typo3.de>
 
 2009-02-07  Steffen Kamper  <info@sk-typo3.de>
 
-       * Fixed bug #10373: Remove doubled check in tceforms 
+       * Fixed bug #10373: Remove doubled check in tceforms
 
 2009-02-07  Dmitry Dulepov  <dmitry@typo3.org>
 
 
 2009-02-07  Dmitry Dulepov  <dmitry@typo3.org>
 
index 85f728b..48d6a8c 100755 (executable)
@@ -383,7 +383,17 @@ class localRecordList extends recordList {
                        $this->iLimit = 0;
                }
 
                        $this->iLimit = 0;
                }
 
-               $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
+               if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
+                               // Get the two previous rows for sorting if displaying page > 1
+                       $this->firstElementNumber = $this->firstElementNumber - 2;
+                       $this->iLimit = $this->iLimit + 2;
+                       $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
+                       $this->firstElementNumber = $this->firstElementNumber + 2;
+                       $this->iLimit = $this->iLimit - 2;
+               } else {
+                       $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
+               }
+
                $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
 
                        // Init:
                $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
 
                        // Init:
@@ -460,6 +470,15 @@ class localRecordList extends recordList {
 
                                $prevUid = 0;
                                $prevPrevUid = 0;
 
                                $prevUid = 0;
                                $prevPrevUid = 0;
+
+                                       // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
+                               if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
+                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
+                                       $prevPrevUid = -(int) $row['uid'];
+                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
+                                       $prevUid = $row['uid'];
+                               }
+
                                $accRows = array();     // Accumulate rows here
                                while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
 
                                $accRows = array();     // Accumulate rows here
                                while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {