31 private const CORE_LIST = [
33 'class' => CategoryLinksTable::class,
35 'LanguageConverterFactory',
42 'needCollation' =>
true,
45 'class' => ExternalLinksTable::class,
48 'class' => ImageLinksTable::class
51 'class' => InterwikiLinksTable::class
54 'class' => LangLinksTable::class
57 'class' => PageLinksTable::class,
63 'class' => PagePropsTable::class,
70 'class' => TemplateLinksTable::class,
75 private $objectFactory;
81 private $collationFactory;
90 private $parserOutput;
93 private $linkTargetLookup;
105 private $tables = [];
108 private $tempCollations;
120 ObjectFactory $objectFactory,
126 array $tempCollations
128 $this->objectFactory = $objectFactory;
129 $this->lbFactory = $lbFactory;
130 $this->collationFactory = $collationFactory;
132 $this->batchSize = $batchSize;
133 $this->linkTargetLookup = $linkTargetLookup;
134 $this->tempCollations = [];
135 foreach ( $tempCollations as $info ) {
136 $this->tempCollations[$info[
'table']] = $info;
144 $this->parserOutput = $parserOutput;
145 foreach ( $this->tables as $table ) {
146 $table->setParserOutput( $parserOutput );
154 $this->movedPage = $oldPage;
155 foreach ( $this->tables as $table ) {
156 $table->setMoveDetails( $oldPage );
166 $this->ticket = $ticket;
167 foreach ( $this->tables as $table ) {
168 $table->setTransactionTicket( $ticket );
176 $this->revision = $revision;
177 foreach ( $this->tables as $table ) {
178 $table->setRevision( $revision );
188 foreach ( $this->
getAll() as $table ) {
189 $table->setStrictTestMode( $mode );
199 private function getSpec( $tableName ) {
200 if ( isset( self::CORE_LIST[$tableName] ) ) {
201 $spec = self::CORE_LIST[$tableName];
202 return $this->addCollationArgs( $spec, $tableName,
false );
204 if ( isset( $this->tempCollations[$tableName] ) ) {
205 $info = $this->tempCollations[$tableName];
206 $spec = self::CORE_LIST[
'categorylinks'];
207 return $this->addCollationArgs( $spec, $tableName,
true, $info );
209 throw new InvalidArgumentException(
210 __CLASS__ .
": unknown table name \"$tableName\"" );
222 private function addCollationArgs( $spec, $tableName, $isTempTable, $info = [] ) {
223 if ( isset( $spec[
'needCollation'] ) ) {
224 if ( isset( $info[
'collation'] ) ) {
225 $collation = $this->collationFactory->makeCollation( $info[
'collation'] );
226 $collationName = $info[
'fakeCollation'] ?? $info[
'collation'];
228 $collation = $this->collationFactory->getCategoryCollation();
229 $collationName = $this->collationFactory->getDefaultCollationName();
233 $info[
'fakeCollation'] ?? $collationName,
237 unset( $spec[
'needCollation'] );
248 public function get( $tableName ) {
249 if ( !isset( $this->tables[$tableName] ) ) {
250 $spec = $this->getSpec( $tableName );
251 if ( isset( $spec[
'serviceOptions'] ) ) {
253 $extraArgs = [
new ServiceOptions( $spec[
'serviceOptions'], $config ) ];
254 unset( $spec[
'serviceOptions'] );
259 $table = $this->objectFactory->createObject( $spec, [
'extraArgs' => $extraArgs ] );
260 $table->injectBaseDependencies(
262 $this->linkTargetLookup,
266 if ( $this->parserOutput ) {
267 $table->setParserOutput( $this->parserOutput );
269 if ( $this->movedPage ) {
270 $table->setMoveDetails( $this->movedPage );
272 if ( $this->ticket ) {
273 $table->setTransactionTicket( $this->ticket );
275 if ( $this->revision ) {
276 $table->setRevision( $this->revision );
278 $this->tables[$tableName] = $table;
280 return $this->tables[$tableName];
288 foreach ( self::CORE_LIST as $tableName => $spec ) {
289 yield $this->
get( $tableName );
291 foreach ( $this->tempCollations as $tableName => $collation ) {
292 yield $this->
get( $tableName );