30 private const CORE_LIST = [
32 'class' => CategoryLinksTable::class,
34 'LanguageConverterFactory',
38 'needCollation' =>
true,
41 'class' => ExternalLinksTable::class,
47 'class' => ImageLinksTable::class
50 'class' => InterwikiLinksTable::class
53 'class' => LangLinksTable::class
56 'class' => PageLinksTable::class
59 'class' => PagePropsTable::class,
66 'class' => TemplateLinksTable::class,
74 private $objectFactory;
80 private $collationFactory;
89 private $parserOutput;
92 private $linkTargetLookup;
104 private $tables = [];
107 private $tempCollations;
119 ObjectFactory $objectFactory,
125 array $tempCollations
127 $this->objectFactory = $objectFactory;
128 $this->lbFactory = $lbFactory;
129 $this->collationFactory = $collationFactory;
131 $this->batchSize = $batchSize;
132 $this->linkTargetLookup = $linkTargetLookup;
133 $this->tempCollations = [];
134 foreach ( $tempCollations as $info ) {
135 $this->tempCollations[$info[
'table']] = $info;
145 $this->parserOutput = $parserOutput;
146 foreach ( $this->tables as $table ) {
147 $table->setParserOutput( $parserOutput );
157 $this->movedPage = $oldPage;
158 foreach ( $this->tables as $table ) {
159 $table->setMoveDetails( $oldPage );
169 $this->ticket = $ticket;
170 foreach ( $this->tables as $table ) {
171 $table->setTransactionTicket( $ticket );
181 $this->revision = $revision;
182 foreach ( $this->tables as $table ) {
183 $table->setRevision( $revision );
193 foreach ( $this->
getAll() as $table ) {
194 $table->setStrictTestMode( $mode );
204 private function getSpec( $tableName ) {
205 if ( isset( self::CORE_LIST[$tableName] ) ) {
206 $spec = self::CORE_LIST[$tableName];
207 return $this->addCollationArgs( $spec, $tableName,
false );
209 if ( isset( $this->tempCollations[$tableName] ) ) {
210 $info = $this->tempCollations[$tableName];
211 $spec = self::CORE_LIST[
'categorylinks'];
212 return $this->addCollationArgs( $spec, $tableName,
true, $info );
214 throw new \InvalidArgumentException(
215 __CLASS__ .
": unknown table name \"$tableName\"" );
227 private function addCollationArgs( $spec, $tableName, $isTempTable, $info = [] ) {
228 if ( isset( $spec[
'needCollation'] ) ) {
229 if ( isset( $info[
'collation'] ) ) {
230 $collation = $this->collationFactory->makeCollation( $info[
'collation'] );
231 $collationName = $info[
'fakeCollation'] ?? $info[
'collation'];
233 $collation = $this->collationFactory->getCategoryCollation();
234 $collationName = $this->collationFactory->getDefaultCollationName();
238 $info[
'fakeCollation'] ?? $collationName,
242 unset( $spec[
'needCollation'] );
253 public function get( $tableName ) {
254 if ( !isset( $this->tables[$tableName] ) ) {
255 $spec = $this->getSpec( $tableName );
256 if ( isset( $spec[
'serviceOptions'] ) ) {
258 $extraArgs = [
new ServiceOptions( $spec[
'serviceOptions'], $config ) ];
259 unset( $spec[
'serviceOptions'] );
264 $table = $this->objectFactory->createObject( $spec, [
'extraArgs' => $extraArgs ] );
265 $table->injectBaseDependencies(
267 $this->linkTargetLookup,
271 if ( $this->parserOutput ) {
272 $table->setParserOutput( $this->parserOutput );
274 if ( $this->movedPage ) {
275 $table->setMoveDetails( $this->movedPage );
277 if ( $this->ticket ) {
278 $table->setTransactionTicket( $this->ticket );
280 if ( $this->revision ) {
281 $table->setRevision( $this->revision );
283 $this->tables[$tableName] = $table;
285 return $this->tables[$tableName];
293 foreach ( self::CORE_LIST as $tableName => $spec ) {
294 yield $this->
get( $tableName );
296 foreach ( $this->tempCollations as $tableName => $collation ) {
297 yield $this->
get( $tableName );