From: jenkins-bot Date: Tue, 29 Nov 2016 03:31:23 +0000 (+0000) Subject: Merge "Revert "MessageCache invalidation improvements" (temporary)" X-Git-Tag: 1.31.0-rc.0~4747 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=d56e2db6a17b9ab0f08b8cd0e88f2cce6cfb48b8;hp=3a4105ba01fc92f2d41e0faee316d02e29f82fe5 Merge "Revert "MessageCache invalidation improvements" (temporary)" --- diff --git a/maintenance/populateContentModel.php b/maintenance/populateContentModel.php index c6bd794e23..b41e0e0d6e 100644 --- a/maintenance/populateContentModel.php +++ b/maintenance/populateContentModel.php @@ -28,6 +28,10 @@ require_once __DIR__ . '/Maintenance.php'; * populateContentModel.php --ns=1 --table=page */ class PopulateContentModel extends Maintenance { + protected $wikiId; + + protected $wanCache; + public function __construct() { parent::__construct(); $this->addDescription( 'Populate the various content_* fields' ); @@ -38,6 +42,11 @@ class PopulateContentModel extends Maintenance { public function execute() { $dbw = $this->getDB( DB_MASTER ); + + $this->wikiId = $dbw->getWikiID(); + + $this->wanCache = ObjectCache::getMainWANInstance(); + $ns = $this->getOption( 'ns' ); if ( !ctype_digit( $ns ) && $ns !== 'all' ) { $this->error( 'Invalid namespace', 1 ); @@ -57,6 +66,18 @@ class PopulateContentModel extends Maintenance { } } + protected function clearCache( $page_id, $rev_id ) { + $contentModelKey = $this->wanCache->makeKey( 'page', 'content-model', $rev_id ); + $revisionKey = + $this->wanCache->makeGlobalKey( 'revision', $this->wikiId, $page_id, $rev_id ); + + // WikiPage content model cache + $this->wanCache->delete( $contentModelKey ); + + // Revision object cache, which contains a content model + $this->wanCache->delete( $revisionKey ); + } + private function updatePageRows( Database $dbw, $pageIds, $model ) { $count = count( $pageIds ); $this->output( "Setting $count rows to $model..." ); @@ -117,6 +138,7 @@ class PopulateContentModel extends Maintenance { [ $key => $ids ], __METHOD__ ); + $this->output( "done.\n" ); } @@ -130,19 +152,27 @@ class PopulateContentModel extends Maintenance { $fields = [ 'ar_namespace', 'ar_title' ]; $join_conds = []; $where = $ns === 'all' ? [] : [ 'ar_namespace' => $ns ]; + $page_id_column = 'ar_page_id'; + $rev_id_column = 'ar_rev_id'; } else { // revision $selectTables = [ 'revision', 'page' ]; $fields = [ 'page_title', 'page_namespace' ]; $join_conds = [ 'page' => [ 'INNER JOIN', 'rev_page=page_id' ] ]; $where = $ns === 'all' ? [] : [ 'page_namespace' => $ns ]; + $page_id_column = 'rev_page'; + $rev_id_column = 'rev_id'; } $toSave = []; + $idsToClear = []; $lastId = 0; do { $rows = $dbw->select( $selectTables, - array_merge( $fields, [ $model_column, $format_column, $key ] ), + array_merge( + $fields, + [ $model_column, $format_column, $key, $page_id_column, $rev_id_column ] + ), // @todo support populating format if model is already set [ $model_column => null, @@ -174,9 +204,17 @@ class PopulateContentModel extends Maintenance { if ( $dbModel === null && $dbFormat === null ) { // Set the defaults $toSave[$defaultModel][] = $row->{$key}; + $idsToClear[] = [ + 'page_id' => $row->{$page_id_column}, + 'rev_id' => $row->{$rev_id_column}, + ]; } else { // $dbModel === null, $dbFormat set. if ( $dbFormat === $defaultFormat ) { $toSave[$defaultModel][] = $row->{$key}; + $idsToClear[] = [ + 'page_id' => $row->{$page_id_column}, + 'rev_id' => $row->{$rev_id_column}, + ]; } else { // non-default format, just update now $this->output( "Updating model to match format for $table $id of $title... " ); $dbw->update( @@ -186,6 +224,7 @@ class PopulateContentModel extends Maintenance { __METHOD__ ); wfWaitForSlaves(); + $this->clearCache( $row->{$page_id_column}, $row->{$rev_id_column} ); $this->output( "done.\n" ); continue; } @@ -200,6 +239,10 @@ class PopulateContentModel extends Maintenance { foreach ( $toSave as $model => $ids ) { $this->updateRevisionOrArchiveRows( $dbw, $ids, $model, $table ); } + + foreach ( $idsToClear as $idPair ) { + $this->clearCache( $idPair['page_id'], $idPair['rev_id'] ); + } } }