2018-06-27 12:16:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* Attribution notice: when this file was created, much of its content was taken
|
|
|
|
|
* from the Revision.php file as present in release 1.30. Refer to the history
|
|
|
|
|
* of that file for original authorship.
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2018-09-20 17:29:04 +00:00
|
|
|
namespace MediaWiki\Revision;
|
2018-06-27 12:16:35 +00:00
|
|
|
|
|
|
|
|
use ActorMigration;
|
|
|
|
|
use CommentStore;
|
|
|
|
|
use MediaWiki\Logger\Spi as LoggerSpi;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Storage\BlobStoreFactory;
|
|
|
|
|
use MediaWiki\Storage\NameTableStoreFactory;
|
2018-06-27 12:16:35 +00:00
|
|
|
use WANObjectCache;
|
|
|
|
|
use Wikimedia\Assert\Assert;
|
|
|
|
|
use Wikimedia\Rdbms\ILBFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory service for RevisionStore instances. This allows RevisionStores to be created for
|
|
|
|
|
* cross-wiki access.
|
|
|
|
|
*
|
|
|
|
|
* @warning Beware compatibility issues with schema migration in the context of cross-wiki access!
|
|
|
|
|
* This class assumes that all wikis are at compatible migration stages for all relevant schemas.
|
|
|
|
|
* Relevant schemas are: revision storage (MCR), the revision comment table, and the actor table.
|
|
|
|
|
* Migration stages are compatible as long as a) there are no wikis in the cluster that only write
|
|
|
|
|
* the old schema or b) there are no wikis that read only the new schema.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.32
|
|
|
|
|
*/
|
|
|
|
|
class RevisionStoreFactory {
|
|
|
|
|
|
|
|
|
|
/** @var BlobStoreFactory */
|
|
|
|
|
private $blobStoreFactory;
|
|
|
|
|
/** @var ILBFactory */
|
|
|
|
|
private $dbLoadBalancerFactory;
|
|
|
|
|
/** @var WANObjectCache */
|
|
|
|
|
private $cache;
|
|
|
|
|
/** @var LoggerSpi */
|
|
|
|
|
private $loggerProvider;
|
|
|
|
|
|
|
|
|
|
/** @var CommentStore */
|
|
|
|
|
private $commentStore;
|
|
|
|
|
/** @var ActorMigration */
|
|
|
|
|
private $actorMigration;
|
|
|
|
|
/** @var int One of the MIGRATION_* constants */
|
|
|
|
|
private $mcrMigrationStage;
|
|
|
|
|
/**
|
|
|
|
|
* @var bool
|
|
|
|
|
* @see $wgContentHandlerUseDB
|
|
|
|
|
*/
|
|
|
|
|
private $contentHandlerUseDB;
|
|
|
|
|
|
2018-09-04 01:59:03 +00:00
|
|
|
/** @var NameTableStoreFactory */
|
|
|
|
|
private $nameTables;
|
|
|
|
|
|
2018-11-19 11:39:56 +00:00
|
|
|
/** @var SlotRoleRegistry */
|
|
|
|
|
private $slotRoleRegistry;
|
|
|
|
|
|
2018-06-27 12:16:35 +00:00
|
|
|
/**
|
|
|
|
|
* @param ILBFactory $dbLoadBalancerFactory
|
|
|
|
|
* @param BlobStoreFactory $blobStoreFactory
|
2018-09-04 01:59:03 +00:00
|
|
|
* @param NameTableStoreFactory $nameTables
|
2018-11-19 11:39:56 +00:00
|
|
|
* @param SlotRoleRegistry $slotRoleRegistry
|
2018-06-27 12:16:35 +00:00
|
|
|
* @param WANObjectCache $cache
|
|
|
|
|
* @param CommentStore $commentStore
|
|
|
|
|
* @param ActorMigration $actorMigration
|
|
|
|
|
* @param int $migrationStage
|
|
|
|
|
* @param LoggerSpi $loggerProvider
|
2018-08-06 12:31:04 +00:00
|
|
|
* @param bool $contentHandlerUseDB see {@link $wgContentHandlerUseDB}. Must be the same
|
|
|
|
|
* for all wikis in the cluster. Will go away after MCR migration.
|
2018-06-27 12:16:35 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
ILBFactory $dbLoadBalancerFactory,
|
|
|
|
|
BlobStoreFactory $blobStoreFactory,
|
2018-09-04 01:59:03 +00:00
|
|
|
NameTableStoreFactory $nameTables,
|
2018-11-19 11:39:56 +00:00
|
|
|
SlotRoleRegistry $slotRoleRegistry,
|
2018-06-27 12:16:35 +00:00
|
|
|
WANObjectCache $cache,
|
|
|
|
|
CommentStore $commentStore,
|
|
|
|
|
ActorMigration $actorMigration,
|
|
|
|
|
$migrationStage,
|
|
|
|
|
LoggerSpi $loggerProvider,
|
|
|
|
|
$contentHandlerUseDB
|
|
|
|
|
) {
|
|
|
|
|
Assert::parameterType( 'integer', $migrationStage, '$migrationStage' );
|
|
|
|
|
$this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
|
|
|
|
|
$this->blobStoreFactory = $blobStoreFactory;
|
2018-11-19 11:39:56 +00:00
|
|
|
$this->slotRoleRegistry = $slotRoleRegistry;
|
2018-09-04 01:59:03 +00:00
|
|
|
$this->nameTables = $nameTables;
|
2018-06-27 12:16:35 +00:00
|
|
|
$this->cache = $cache;
|
|
|
|
|
$this->commentStore = $commentStore;
|
|
|
|
|
$this->actorMigration = $actorMigration;
|
|
|
|
|
$this->mcrMigrationStage = $migrationStage;
|
|
|
|
|
$this->loggerProvider = $loggerProvider;
|
|
|
|
|
$this->contentHandlerUseDB = $contentHandlerUseDB;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.32
|
|
|
|
|
*
|
2019-06-27 01:33:18 +00:00
|
|
|
* @param bool|string $dbDomain DB domain of the relevant wiki or false for the current one
|
2018-06-27 12:16:35 +00:00
|
|
|
*
|
|
|
|
|
* @return RevisionStore for the given wikiId with all necessary services and a logger
|
|
|
|
|
*/
|
2019-06-27 01:33:18 +00:00
|
|
|
public function getRevisionStore( $dbDomain = false ) {
|
|
|
|
|
Assert::parameterType( 'string|boolean', $dbDomain, '$dbDomain' );
|
2018-06-27 12:16:35 +00:00
|
|
|
|
|
|
|
|
$store = new RevisionStore(
|
2019-06-27 01:33:18 +00:00
|
|
|
$this->dbLoadBalancerFactory->getMainLB( $dbDomain ),
|
2019-09-01 12:45:11 +00:00
|
|
|
// @phan-suppress-next-line PhanAccessMethodInternal
|
2019-06-27 01:33:18 +00:00
|
|
|
$this->blobStoreFactory->newSqlBlobStore( $dbDomain ),
|
2018-06-27 12:16:35 +00:00
|
|
|
$this->cache, // Pass local cache instance; Leave cache sharing to RevisionStore.
|
|
|
|
|
$this->commentStore,
|
2019-06-27 01:33:18 +00:00
|
|
|
$this->nameTables->getContentModels( $dbDomain ),
|
|
|
|
|
$this->nameTables->getSlotRoles( $dbDomain ),
|
2018-11-19 11:39:56 +00:00
|
|
|
$this->slotRoleRegistry,
|
2018-06-27 12:16:35 +00:00
|
|
|
$this->mcrMigrationStage,
|
|
|
|
|
$this->actorMigration,
|
2019-06-27 01:33:18 +00:00
|
|
|
$dbDomain
|
2018-06-27 12:16:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$store->setLogger( $this->loggerProvider->getLogger( 'RevisionStore' ) );
|
|
|
|
|
$store->setContentHandlerUseDB( $this->contentHandlerUseDB );
|
|
|
|
|
|
|
|
|
|
return $store;
|
|
|
|
|
}
|
|
|
|
|
}
|