X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fjobqueue%2Fjobs%2FRecentChangesUpdateJob.php;h=22afead165254cd4bb677fc0200545d13365c20f;hp=0685299026f07400cb84d4ba932f4db26793b9f9;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hpb=995449ef039b769a613ddf3731ece1e4c20d358c diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php index 0685299026..22afead165 100644 --- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php +++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php @@ -42,7 +42,7 @@ class RecentChangesUpdateJob extends Job { */ final public static function newPurgeJob() { return new self( - SpecialPage::getTitleFor( 'Recentchanges' ), array( 'type' => 'purge' ) + SpecialPage::getTitleFor( 'Recentchanges' ), [ 'type' => 'purge' ] ); } @@ -52,7 +52,7 @@ class RecentChangesUpdateJob extends Job { */ final public static function newCacheUpdateJob() { return new self( - SpecialPage::getTitleFor( 'Recentchanges' ), array( 'type' => 'cacheUpdate' ) + SpecialPage::getTitleFor( 'Recentchanges' ), [ 'type' => 'cacheUpdate' ] ); } @@ -86,12 +86,12 @@ class RecentChangesUpdateJob extends Job { do { $rcIds = $dbw->selectFieldValues( 'recentchanges', 'rc_id', - array( 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ), + [ 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ], __METHOD__, - array( 'LIMIT' => $batchSize ) + [ 'LIMIT' => $batchSize ] ); if ( $rcIds ) { - $dbw->delete( 'recentchanges', array( 'rc_id' => $rcIds ), __METHOD__ ); + $dbw->delete( 'recentchanges', [ 'rc_id' => $rcIds ], __METHOD__ ); } // Commit in chunks to avoid slave lag $dbw->commit( __METHOD__, 'flush' ); @@ -99,7 +99,7 @@ class RecentChangesUpdateJob extends Job { if ( count( $rcIds ) === $batchSize ) { // There might be more, so try waiting for slaves try { - wfGetLBFactory()->waitForReplication( array( 'timeout' => 3 ) ); + wfGetLBFactory()->waitForReplication( [ 'timeout' => 3 ] ); } catch ( DBReplicationWaitError $e ) { // Another job will continue anyway break; @@ -123,7 +123,7 @@ class RecentChangesUpdateJob extends Job { // onTransactionIdle() will run immediately since there is no trx. $dbw->onTransactionIdle( function() use ( $dbw, $days, $window ) { // Avoid disconnect/ping() cycle that makes locks fall off - $dbw->setSessionOptions( array( 'connTimeout' => 900 ) ); + $dbw->setSessionOptions( [ 'connTimeout' => 900 ] ); $lockKey = wfWikiID() . '-activeusers'; if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) { @@ -134,7 +134,7 @@ class RecentChangesUpdateJob extends Job { // Get the last-updated timestamp for the cache $cTime = $dbw->selectField( 'querycache_info', 'qci_timestamp', - array( 'qci_type' => 'activeusers' ) + [ 'qci_type' => 'activeusers' ] ); $cTimeUnix = $cTime ? wfTimestamp( TS_UNIX, $cTime ) : 1; @@ -146,43 +146,43 @@ class RecentChangesUpdateJob extends Job { // Get all the users active since the last update $res = $dbw->select( - array( 'recentchanges' ), - array( 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ), - array( + [ 'recentchanges' ], + [ 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ], + [ 'rc_user > 0', // actual accounts 'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata 'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ), 'rc_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ), 'rc_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $eTimestamp ) ) - ), + ], __METHOD__, - array( - 'GROUP BY' => array( 'rc_user_text' ), + [ + 'GROUP BY' => [ 'rc_user_text' ], 'ORDER BY' => 'NULL' // avoid filesort - ) + ] ); - $names = array(); + $names = []; foreach ( $res as $row ) { $names[$row->rc_user_text] = $row->lastedittime; } // Rotate out users that have not edited in too long (according to old data set) $dbw->delete( 'querycachetwo', - array( + [ 'qcc_type' => 'activeusers', 'qcc_value < ' . $dbw->addQuotes( $nowUnix - $days * 86400 ) // TS_UNIX - ), + ], __METHOD__ ); // Find which of the recently active users are already accounted for if ( count( $names ) ) { $res = $dbw->select( 'querycachetwo', - array( 'user_name' => 'qcc_title' ), - array( + [ 'user_name' => 'qcc_title' ], + [ 'qcc_type' => 'activeusers', 'qcc_namespace' => NS_USER, - 'qcc_title' => array_keys( $names ) ), + 'qcc_title' => array_keys( $names ) ], __METHOD__ ); foreach ( $res as $row ) { @@ -192,16 +192,16 @@ class RecentChangesUpdateJob extends Job { // Insert the users that need to be added to the list if ( count( $names ) ) { - $newRows = array(); + $newRows = []; foreach ( $names as $name => $lastEditTime ) { - $newRows[] = array( + $newRows[] = [ 'qcc_type' => 'activeusers', 'qcc_namespace' => NS_USER, 'qcc_title' => $name, 'qcc_value' => wfTimestamp( TS_UNIX, $lastEditTime ), 'qcc_namespacetwo' => 0, // unused 'qcc_titletwo' => '' // unused - ); + ]; } foreach ( array_chunk( $newRows, 500 ) as $rowBatch ) { $dbw->insert( 'querycachetwo', $rowBatch, __METHOD__ ); @@ -215,9 +215,9 @@ class RecentChangesUpdateJob extends Job { // Touch the data freshness timestamp $dbw->replace( 'querycache_info', - array( 'qci_type' ), - array( 'qci_type' => 'activeusers', - 'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ) ), // not always $now + [ 'qci_type' ], + [ 'qci_type' => 'activeusers', + 'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ) ], // not always $now __METHOD__ );