Merge "Add checkDependencies.php"
[lhc/web/wiklou.git] / maintenance / purgeChangedPages.php
index feeac92..8f47b16 100644 (file)
@@ -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' ],
                                ]
                        );
 
@@ -136,9 +136,9 @@ class PurgeChangedPages extends Maintenance {
                                }
                        }
 
-                       // Send batch of purge requests out to squids
-                       $squid = new CdnCacheUpdate( $urls, count( $urls ) );
-                       $squid->doUpdate();
+                       // Send batch of purge requests out to CDN servers
+                       $cdn = new CdnCacheUpdate( $urls, count( $urls ) );
+                       $cdn->doUpdate();
 
                        if ( $this->hasOption( 'sleep-per-batch' ) ) {
                                // sleep-per-batch is milliseconds, usleep wants micro seconds.
@@ -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 ];
        }
 }