23use InvalidArgumentException;
38 private $linkTargetLookup;
43 'page_id' =>
'tl_from',
44 'ns' =>
'tl_namespace',
45 'title' =>
'tl_title',
46 'target_id' =>
'tl_target_id',
51 'page_id' =>
'pl_from',
52 'ns' =>
'pl_namespace',
53 'title' =>
'pl_title',
54 'target_id' =>
'pl_target_id',
55 'deprecated_configs' => [],
60 'tl' =>
'templatelinks',
69 $this->config = $config;
70 $this->linkTargetLookup = $linktargetLookup;
81 $this->assertMapping( $table );
83 $targetId = $this->linkTargetLookup->getLinkTargetId( $linkTarget );
89 self::$mapping[$table][
'target_id'] => $targetId,
93 self::$mapping[$table][
'ns'] => $linkTarget->
getNamespace(),
94 self::$mapping[$table][
'title'] => $linkTarget->
getDBkey(),
107 public function getQueryInfo(
string $table,
string $joinTable =
'linktarget',
string $joinType =
'JOIN' ) {
108 $this->assertMapping( $table );
110 $targetId = self::$mapping[$table][
'target_id'];
111 if ( $joinTable ===
'linktarget' ) {
112 $tables = [ $table,
'linktarget' ];
114 $tables = [
'linktarget', $table ];
123 'joins' => [ $joinTable => [
125 [
"$targetId=lt_id" ]
131 self::$mapping[$table][
'ns'],
132 self::$mapping[$table][
'title']
134 'tables' => [ $table ],
141 $this->assertMapping( $table );
144 return [
'lt_namespace',
'lt_title' ];
146 return [ self::$mapping[$table][
'ns'], self::$mapping[$table][
'title'] ];
150 private function assertMapping(
string $table ) {
151 if ( !isset( self::$mapping[$table] ) ) {
152 throw new InvalidArgumentException(
153 "LinksMigration doesn't support the $table table yet"
157 $config = $this->config->
get( self::$mapping[$table][
'config'] );
158 if ( in_array( $config, self::$mapping[$table][
'deprecated_configs'] ) ) {
159 throw new InvalidArgumentException(
160 "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 PageLinksSchemaMigrationStage
Name constant for the PageLinksSchemaMigrationStage setting, for use with Config::get()
const TemplateLinksSchemaMigrationStage
Name constant for the TemplateLinksSchemaMigrationStage setting, for use with Config::get()