Update formatting on includes/deferred/

Change-Id: Id3f143eae3781b26dcbc3ba63a566b7a6006c0cc
This commit is contained in:
Siebrand Mazeland 2013-11-20 18:20:36 +01:00 committed by Chad
parent 1e0bd351b7
commit 368a95dc65
10 changed files with 55 additions and 33 deletions

View file

@ -4,7 +4,6 @@
* Deferrable Update for closure/callback
*/
class MWCallableUpdate implements DeferrableUpdate {
/**
* @var closure/callabck
*/
@ -26,5 +25,4 @@ class MWCallableUpdate implements DeferrableUpdate {
public function doUpdate() {
call_user_func( $this->callback );
}
}

View file

@ -30,7 +30,6 @@
* subclasses can override the beginTransaction() and commitTransaction() methods.
*/
abstract class DataUpdate implements DeferrableUpdate {
/**
* Constructor
*/
@ -122,5 +121,4 @@ abstract class DataUpdate implements DeferrableUpdate {
throw $exception; // rethrow after cleanup
}
}
}

View file

@ -89,6 +89,7 @@ class DeferredUpdates {
// No need to get master connections in case of empty updates array
if ( !count( $updates ) ) {
wfProfileOut( __METHOD__ );
return;
}

View file

@ -61,7 +61,7 @@ class HTMLCacheUpdate implements DeferrableUpdate {
JobQueueGroup::singleton()->deduplicateRootJob( $job );
} else { // few backlinks ($count might be off even if 0)
$dbw = wfGetDB( DB_MASTER );
$dbw->onTransactionIdle( function() use ( $job ) {
$dbw->onTransactionIdle( function () use ( $job ) {
$job->run(); // just do the purge query now
} );
}

View file

@ -26,22 +26,21 @@
* @todo document (e.g. one-sentence top-level class description).
*/
class LinksUpdate extends SqlDataUpdate {
// @todo make members protected, but make sure extensions don't break
public $mId, //!< Page ID of the article linked from
$mTitle, //!< Title object of the article linked from
$mParserOutput, //!< Parser output
$mLinks, //!< Map of title strings to IDs for the links in the document
$mImages, //!< DB keys of the images used, in the array key only
$mTemplates, //!< Map of title strings to IDs for the template references, including broken ones
$mExternals, //!< URLs of external links, array key only
$mCategories, //!< Map of category names to sort keys
$mInterlangs, //!< Map of language codes to titles
$mProperties, //!< Map of arbitrary name to value
$mDb, //!< Database connection reference
$mOptions, //!< SELECT options to be used (array)
$mRecursive; //!< Whether to queue jobs for recursive updates
public $mId, //!< Page ID of the article linked from
$mTitle, //!< Title object of the article linked from
$mParserOutput, //!< Parser output
$mLinks, //!< Map of title strings to IDs for the links in the document
$mImages, //!< DB keys of the images used, in the array key only
$mTemplates, //!< Map of title strings to IDs for the template references, including broken ones
$mExternals, //!< URLs of external links, array key only
$mCategories, //!< Map of category names to sort keys
$mInterlangs, //!< Map of language codes to titles
$mProperties, //!< Map of arbitrary name to value
$mDb, //!< Database connection reference
$mOptions, //!< SELECT options to be used (array)
$mRecursive; //!< Whether to queue jobs for recursive updates
/**
* @var null|array Added links if calculated.
@ -330,6 +329,7 @@ class LinksUpdate extends SqlDataUpdate {
);
}
}
return $arr;
}
@ -350,6 +350,7 @@ class LinksUpdate extends SqlDataUpdate {
);
}
}
return $arr;
}
@ -368,6 +369,7 @@ class LinksUpdate extends SqlDataUpdate {
'il_to' => $iname
);
}
return $arr;
}
@ -388,6 +390,7 @@ class LinksUpdate extends SqlDataUpdate {
);
}
}
return $arr;
}
@ -432,6 +435,7 @@ class LinksUpdate extends SqlDataUpdate {
'cl_type' => $type,
);
}
return $arr;
}
@ -452,6 +456,7 @@ class LinksUpdate extends SqlDataUpdate {
'll_title' => $title
);
}
return $arr;
}
@ -470,6 +475,7 @@ class LinksUpdate extends SqlDataUpdate {
'pp_value' => $value,
);
}
return $arr;
}
@ -491,6 +497,7 @@ class LinksUpdate extends SqlDataUpdate {
);
}
}
return $arr;
}
@ -509,6 +516,7 @@ class LinksUpdate extends SqlDataUpdate {
$del[$ns] = $existing[$ns];
}
}
return $del;
}
@ -527,6 +535,7 @@ class LinksUpdate extends SqlDataUpdate {
$del[$ns] = $existing[$ns];
}
}
return $del;
}
@ -594,6 +603,7 @@ class LinksUpdate extends SqlDataUpdate {
$del[$prefix] = $existing[$prefix];
}
}
return $del;
}
@ -612,6 +622,7 @@ class LinksUpdate extends SqlDataUpdate {
}
$arr[$row->pl_namespace][$row->pl_title] = 1;
}
return $arr;
}
@ -630,6 +641,7 @@ class LinksUpdate extends SqlDataUpdate {
}
$arr[$row->tl_namespace][$row->tl_title] = 1;
}
return $arr;
}
@ -645,6 +657,7 @@ class LinksUpdate extends SqlDataUpdate {
foreach ( $res as $row ) {
$arr[$row->il_to] = 1;
}
return $arr;
}
@ -660,6 +673,7 @@ class LinksUpdate extends SqlDataUpdate {
foreach ( $res as $row ) {
$arr[$row->el_to] = 1;
}
return $arr;
}
@ -675,6 +689,7 @@ class LinksUpdate extends SqlDataUpdate {
foreach ( $res as $row ) {
$arr[$row->cl_to] = $row->cl_sortkey_prefix;
}
return $arr;
}
@ -691,6 +706,7 @@ class LinksUpdate extends SqlDataUpdate {
foreach ( $res as $row ) {
$arr[$row->ll_lang] = $row->ll_title;
}
return $arr;
}
@ -708,6 +724,7 @@ class LinksUpdate extends SqlDataUpdate {
}
$arr[$row->iwl_prefix][$row->iwl_title] = 1;
}
return $arr;
}
@ -723,6 +740,7 @@ class LinksUpdate extends SqlDataUpdate {
foreach ( $res as $row ) {
$arr[$row->pp_propname] = $row->pp_value;
}
return $arr;
}
@ -783,8 +801,9 @@ class LinksUpdate extends SqlDataUpdate {
}
$result = array();
foreach ( $this->linkInsertions as $insertion ) {
$result[] = Title::makeTitle( $insertion[ 'pl_namespace' ], $insertion[ 'pl_title' ] );
$result[] = Title::makeTitle( $insertion['pl_namespace'], $insertion['pl_title'] );
}
return $result;
}
@ -803,6 +822,7 @@ class LinksUpdate extends SqlDataUpdate {
$result[] = Title::makeTitle( $ns, $title );
}
}
return $result;
}
}
@ -811,8 +831,7 @@ class LinksUpdate extends SqlDataUpdate {
* Update object handling the cleanup of links tables after a page was deleted.
**/
class LinksDeletionUpdate extends SqlDataUpdate {
protected $mPage; //!< WikiPage the wikipage that was deleted
protected $mPage; //!< WikiPage the wikipage that was deleted
/**
* Constructor

View file

@ -180,6 +180,7 @@ class SearchUpdate implements DeferrableUpdate {
# Strip wiki '' and '''
$text = preg_replace( "/''[']*/", " ", $text );
wfProfileOut( __METHOD__ . '-regexps' );
return $text;
}
}

View file

@ -85,6 +85,7 @@ class SiteStatsUpdate implements DeferrableUpdate {
|| !$dbw->lock( $lockKey, __METHOD__, 1 ) // 1 sec timeout
) {
$this->doUpdatePendingDeltas();
return;
}
$pd = $this->getPendingDeltas();
@ -143,6 +144,7 @@ class SiteStatsUpdate implements DeferrableUpdate {
array( 'ss_row_id' => 1 ),
__METHOD__
);
return $activeUsers;
}
@ -216,8 +218,8 @@ class SiteStatsUpdate implements DeferrableUpdate {
$pending = array();
foreach ( array( 'ss_total_views', 'ss_total_edits',
'ss_good_articles', 'ss_total_pages', 'ss_users', 'ss_images' ) as $type )
{
'ss_good_articles', 'ss_total_pages', 'ss_users', 'ss_images' ) as $type
) {
// Get pending increments and pending decrements
$pending[$type]['+'] = (int)$wgMemc->get( $this->getTypeCacheKey( $type, '+' ) );
$pending[$type]['-'] = (int)$wgMemc->get( $this->getTypeCacheKey( $type, '-' ) );
@ -242,4 +244,3 @@ class SiteStatsUpdate implements DeferrableUpdate {
}
}
}

View file

@ -31,11 +31,10 @@
* the beginTransaction() and commitTransaction() methods.
*/
abstract class SqlDataUpdate extends DataUpdate {
protected $mDb; //!< Database connection reference
protected $mOptions; //!< SELECT options to be used (array)
protected $mDb; //!< Database connection reference
protected $mOptions; //!< SELECT options to be used (array)
private $mHasTransaction; //!< bool whether a transaction is open on this object (internal use only!)
private $mHasTransaction; //!< bool whether a transaction is open on this object (internal use only!)
protected $mUseTransaction; //!< bool whether this update should be wrapped in a transaction
/**
@ -148,5 +147,4 @@ abstract class SqlDataUpdate extends DataUpdate {
), __METHOD__
);
}
}

View file

@ -26,7 +26,6 @@
* @ingroup Cache
*/
class SquidUpdate {
/**
* Collection of URLs to purge.
* @var array
@ -83,6 +82,7 @@ class SquidUpdate {
}
wfProfileOut( __METHOD__ );
return new SquidUpdate( $blurlArr );
}
@ -102,6 +102,7 @@ class SquidUpdate {
break;
}
}
return new SquidUpdate( $urlArr );
}
@ -111,6 +112,7 @@ class SquidUpdate {
*/
public static function newSimplePurge( Title $title ) {
$urlArr = $title->getSquidURLs();
return new SquidUpdate( $urlArr );
}
@ -194,11 +196,12 @@ class SquidUpdate {
// pfsockopen doesn't work because we need set_sock_opt
$conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
if ( ! $conn ) {
if ( !$conn ) {
$errstr = socket_strerror( socket_last_error() );
wfDebugLog( 'squid', __METHOD__ .
": Error opening UDP socket: $errstr\n" );
wfProfileOut( __METHOD__ );
return;
}
@ -295,6 +298,7 @@ class SquidUpdate {
return $routing;
}
}
return false;
}
}

View file

@ -49,6 +49,7 @@ class ViewCountUpdate implements DeferrableUpdate {
if ( $wgHitcounterUpdateFreq <= 1 || $dbw->getType() == 'sqlite' ) {
$dbw->update( 'page', array( 'page_counter = page_counter + 1' ), array( 'page_id' => $this->id ), __METHOD__ );
return;
}
@ -59,7 +60,8 @@ class ViewCountUpdate implements DeferrableUpdate {
if ( rand() % $checkfreq == 0 && $dbw->lastErrno() == 0 ) {
$this->collect();
}
} catch ( DBError $e ) {}
} catch ( DBError $e ) {
}
}
protected function collect() {