24use InvalidArgumentException;
38 private $linkTargetLookup;
43 'page_id' =>
'tl_from',
44 'ns' =>
'tl_namespace',
45 'title' =>
'tl_title',
46 'target_id' =>
'tl_target_id',
52 'tl' =>
'templatelinks'
60 $this->config = $config;
61 $this->linkTargetLookup = $linktargetLookup;
72 $this->assertMapping( $table );
74 $targetId = $this->linkTargetLookup->getLinkTargetId( $linkTarget );
76 self::$mapping[$table][
'target_id'] => $targetId,
80 self::$mapping[$table][
'ns'] => $linkTarget->
getNamespace(),
81 self::$mapping[$table][
'title'] => $linkTarget->
getDBkey(),
94 public function getQueryInfo(
string $table,
string $joinTable =
'linktarget',
string $joinType =
'JOIN' ) {
95 $this->assertMapping( $table );
97 $targetId = self::$mapping[$table][
'target_id'];
98 if ( $joinTable ===
'linktarget' ) {
99 $tables = [ $table,
'linktarget' ];
101 $tables = [
'linktarget', $table ];
110 'joins' => [ $joinTable => [
112 [
"$targetId=lt_id" ]
118 self::$mapping[$table][
'ns'],
119 self::$mapping[$table][
'title']
121 'tables' => [ $table ],
128 $this->assertMapping( $table );
131 return [
'lt_namespace',
'lt_title' ];
133 return [ self::$mapping[$table][
'ns'], self::$mapping[$table][
'title'] ];
137 private function assertMapping(
string $table ) {
138 if ( !isset( self::$mapping[$table] ) ) {
139 throw new InvalidArgumentException(
140 "LinksMigration doesn't support the $table table yet"
144 $config = $this->config->
get( self::$mapping[$table][
'config'] );
145 if ( in_array( $config, self::$mapping[$table][
'deprecated_configs'] ) ) {
146 throw new InvalidArgumentException(
147 "LinksMigration config $config on $table table is not supported anymore"
const SCHEMA_COMPAT_READ_NEW
A class containing constants representing the names of configuration variables.
const TemplateLinksSchemaMigrationStage
Name constant for the TemplateLinksSchemaMigrationStage setting, for use with Config::get()
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".