24 use 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 );
80 self::$mapping[$table][
'target_id'] => $targetId,
84 self::$mapping[$table][
'ns'] => $linkTarget->
getNamespace(),
85 self::$mapping[$table][
'title'] => $linkTarget->
getDBkey(),
98 public function getQueryInfo(
string $table,
string $joinTable =
'linktarget',
string $joinType =
'JOIN' ) {
99 $this->assertMapping( $table );
101 $targetId = self::$mapping[$table][
'target_id'];
102 if ( $joinTable ===
'linktarget' ) {
103 $tables = [ $table,
'linktarget' ];
105 $tables = [
'linktarget', $table ];
114 'joins' => [ $joinTable => [
116 [
"$targetId=lt_id" ]
122 self::$mapping[$table][
'ns'],
123 self::$mapping[$table][
'title']
125 'tables' => [ $table ],
132 $this->assertMapping( $table );
135 return [
'lt_namespace',
'lt_title' ];
137 return [ self::$mapping[$table][
'ns'], self::$mapping[$table][
'title'] ];
141 private function assertMapping(
string $table ) {
142 if ( !isset( self::$mapping[$table] ) ) {
143 throw new InvalidArgumentException(
144 "LinksMigration doesn't support the $table table yet"
148 $config = $this->config->
get( self::$mapping[$table][
'config'] );
149 if ( in_array( $config, self::$mapping[$table][
'deprecated_configs'] ) ) {
150 throw new InvalidArgumentException(
151 "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.".