X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FpurgeChangedPages.php;h=81fb5e39d7a5852289a7e6ba6b77150452a3293d;hb=4d6828ef7835b7c5c5e903637fcba4bf5c487e1b;hp=22020e7d0640176f8a46b376f1c38981816f08c2;hpb=c2adecb31b16a36efdb509a575533c7f103a0576;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/purgeChangedPages.php b/maintenance/purgeChangedPages.php index 22020e7d06..81fb5e39d7 100644 --- a/maintenance/purgeChangedPages.php +++ b/maintenance/purgeChangedPages.php @@ -52,7 +52,7 @@ class PurgeChangedPages extends Maintenance { global $wgHTCPRouting; if ( $this->hasOption( 'htcp-dest' ) ) { - $parts = explode( ':', $this->getOption( 'htcp-dest' ) ); + $parts = explode( ':', $this->getOption( 'htcp-dest' ), 2 ); if ( count( $parts ) < 2 ) { // Add default htcp port $parts[] = '4827'; @@ -99,7 +99,7 @@ class PurgeChangedPages extends Maintenance { __METHOD__, [ 'ORDER BY' => 'rev_timestamp', 'LIMIT' => $bSize ], [ - 'page' => [ 'INNER JOIN', 'rev_page=page_id' ], + 'page' => [ 'JOIN', 'rev_page=page_id' ], ] ); @@ -170,23 +170,31 @@ class PurgeChangedPages extends Maintenance { */ protected function pageableSortedRows( ResultWrapper $res, $column, $limit ) { $rows = iterator_to_array( $res, false ); - $count = count( $rows ); - if ( !$count ) { - return [ [], null ]; // nothing to do - } elseif ( $count < $limit ) { - return [ $rows, $rows[$count - 1]->$column ]; // no more rows left + + // Nothing to do + if ( !$rows ) { + return [ [], null ]; + } + + $lastValue = end( $rows )->$column; + if ( count( $rows ) < $limit ) { + return [ $rows, $lastValue ]; } - $lastValue = $rows[$count - 1]->$column; // should be the highest - for ( $i = $count - 1; $i >= 0; --$i ) { - if ( $rows[$i]->$column === $lastValue ) { - unset( $rows[$i] ); - } else { + + for ( $i = count( $rows ) - 1; $i >= 0; --$i ) { + if ( $rows[$i]->$column !== $lastValue ) { break; } + + unset( $rows[$i] ); + } + + // No more rows left + if ( !$rows ) { + return [ [], null ]; } - $lastValueLeft = count( $rows ) ? $rows[count( $rows ) - 1]->$column : null; - return [ $rows, $lastValueLeft ]; + return [ $rows, end( $rows )->$column ]; } }