Merge "Consolidate AtomicSectionUpdate code in DerivedPageDataUpdater."
[lhc/web/wiklou.git] / includes / Storage / RevisionStoreFactory.php
1 <?php
2
3 /**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 *
19 * Attribution notice: when this file was created, much of its content was taken
20 * from the Revision.php file as present in release 1.30. Refer to the history
21 * of that file for original authorship.
22 *
23 * @file
24 */
25
26 namespace MediaWiki\Storage;
27
28 use ActorMigration;
29 use CommentStore;
30 use Psr\Log\LoggerInterface;
31 use WANObjectCache;
32 use Wikimedia\Assert\Assert;
33 use Wikimedia\Rdbms\LoadBalancer;
34
35 /**
36 * @since 1.32
37 */
38 class RevisionStoreFactory {
39
40 /** @var SqlBlobStore */
41 private $blobStore;
42
43 /** @var LoadBalancer */
44 private $loadBalancer;
45
46 /** @var WANObjectCache */
47 private $cache;
48
49 /** @var CommentStore */
50 private $commentStore;
51
52 /** @var ActorMigration */
53 private $actorMigration;
54
55 /** @var NameTableStore */
56 private $contentModelStore;
57
58 /** @var NameTableStore */
59 private $slotRoleStore;
60
61 /** @var int One of the MIGRATION_* constants */
62 private $mcrMigrationStage;
63
64 /**
65 * @var bool
66 * @see $wgContentHandlerUseDB
67 */
68 private $contentHandlerUseDB;
69
70 /** @var LoggerInterface */
71 private $logger;
72
73 /**
74 * @todo $blobStore should be allowed to be any BlobStore!
75 *
76 * @param LoadBalancer $loadBalancer
77 * @param SqlBlobStore $blobStore
78 * @param WANObjectCache $cache
79 * @param CommentStore $commentStore
80 * @param NameTableStore $contentModelStore
81 * @param NameTableStore $slotRoleStore
82 * @param int $migrationStage
83 * @param ActorMigration $actorMigration
84 * @param LoggerInterface $logger
85 * @param bool $contentHandlerUseDB see {@link $wgContentHandlerUseDB}
86 */
87 public function __construct(
88 LoadBalancer $loadBalancer,
89 SqlBlobStore $blobStore,
90 WANObjectCache $cache,
91 CommentStore $commentStore,
92 NameTableStore $contentModelStore,
93 NameTableStore $slotRoleStore,
94 $migrationStage,
95 ActorMigration $actorMigration,
96 LoggerInterface $logger,
97 $contentHandlerUseDB
98 ) {
99 Assert::parameterType( 'integer', $migrationStage, '$migrationStage' );
100
101 $this->loadBalancer = $loadBalancer;
102 $this->blobStore = $blobStore;
103 $this->cache = $cache;
104 $this->commentStore = $commentStore;
105 $this->contentModelStore = $contentModelStore;
106 $this->slotRoleStore = $slotRoleStore;
107 $this->mcrMigrationStage = $migrationStage;
108 $this->actorMigration = $actorMigration;
109 $this->logger = $logger;
110 $this->contentHandlerUseDB = $contentHandlerUseDB;
111 }
112
113 /**
114 * @since 1.32
115 *
116 * @param bool|string $wikiId false for the current domain / wikid
117 *
118 * @return RevisionStore for the given wikiId with all necessary services and a logger
119 */
120 public function getRevisionStore( $wikiId = false ) {
121 Assert::parameterType( 'string|boolean', $wikiId, '$wikiId' );
122
123 $store = new RevisionStore(
124 $this->loadBalancer,
125 $this->blobStore,
126 $this->cache,
127 $this->commentStore,
128 $this->contentModelStore,
129 $this->slotRoleStore,
130 $this->mcrMigrationStage,
131 $this->actorMigration,
132 $wikiId
133 );
134
135 $store->setLogger( $this->logger );
136 $store->setContentHandlerUseDB( $this->contentHandlerUseDB );
137
138 return $store;
139 }
140
141 }