Index: trunk/phase3/includes/Pager.php |
— | — | @@ -119,18 +119,22 @@ |
120 | 120 | $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' ); |
121 | 121 | $this->mDb = wfGetDB( DB_SLAVE ); |
122 | 122 | |
123 | | - $index = $this->getIndexField(); |
124 | | - $extraSort = $this->getExtraSortFields(); |
| 123 | + $index = $this->getIndexField(); // column to sort on |
| 124 | + $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning |
125 | 125 | $order = $this->mRequest->getVal( 'order' ); |
126 | 126 | if( is_array( $index ) && isset( $index[$order] ) ) { |
127 | 127 | $this->mOrderType = $order; |
128 | 128 | $this->mIndexField = $index[$order]; |
129 | | - $this->mExtraSortFields = (array)$extraSort[$order]; |
| 129 | + $this->mExtraSortFields = isset( $extraSort[$order] ) |
| 130 | + ? (array)$extraSort[$order] |
| 131 | + : array(); |
130 | 132 | } elseif( is_array( $index ) ) { |
131 | 133 | # First element is the default |
132 | 134 | reset( $index ); |
133 | 135 | list( $this->mOrderType, $this->mIndexField ) = each( $index ); |
134 | | - $this->mExtraSortFields = (array)$extraSort[$this->mOrderType]; |
| 136 | + $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] ) |
| 137 | + ? (array)$extraSort[$this->mOrderType] |
| 138 | + : array(); |
135 | 139 | } else { |
136 | 140 | # $index is not an array |
137 | 141 | $this->mOrderType = null; |
— | — | @@ -599,8 +603,8 @@ |
600 | 604 | * not be used in the pager offset or in any links for users. |
601 | 605 | * |
602 | 606 | * If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then |
603 | | - * this must return a corresponding array of 'querykey' => array( fields...) pairs, |
604 | | - * so that a request with &count=querykey will use array( fields...) to sort. |
| 607 | + * this must return a corresponding array of 'querykey' => array( fields...) pairs |
| 608 | + * in order for a request with &count=querykey to use array( fields...) to sort. |
605 | 609 | * |
606 | 610 | * This is useful for pagers that GROUP BY a unique column (say page_id) |
607 | 611 | * and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on |