'original value returned by the previous query', '_badcontinue' );
}
- $from = intval( $cont[0] );
- $prefix = $this->getDB()->strencode( $cont[1] );
- $title = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) );
+ $prefix = $this->getDB()->strencode( $cont[0] );
+ $title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+ $from = intval( $cont[2] );
$this->addWhere(
- "iwl_from > $from OR " .
- "(iwl_from = $from AND " .
- "(iwl_prefix > '$prefix' OR " .
+ "iwl_prefix > '$prefix' OR " .
"(iwl_prefix = '$prefix' AND " .
- "iwl_title >= '$title')))"
+ "(iwl_title > '$title' OR " .
+ "(iwl_title = '$title' AND " .
+ "iwl_from >= $from)))"
);
}
if ( isset( $params['prefix'] ) ) {
$this->addWhereFld( 'iwl_prefix', $params['prefix'] );
- }
-
- if ( isset( $params['title'] ) ) {
- $this->addWhereFld( 'iwl_title', $params['title'] );
+ if ( isset( $params['title'] ) ) {
+ $this->addWhereFld( 'iwl_title', $params['title'] );
+ $this->addOption( 'ORDER BY', 'iwl_from' );
+ } else {
+ $this->addOption( 'ORDER BY', 'iwl_title, iwl_from' );
+ }
+ } else {
+ $this->addOption( 'ORDER BY', 'iwl_prefix, iwl_title, iwl_from' );
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
- $this->addOption( 'ORDER BY', 'iwl_from' );
$db = $this->getDB();
$res = $this->select( __METHOD__ );
if ( ++ $count > $params['limit'] ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// Continue string preserved in case the redirect query doesn't pass the limit
- $this->setContinueEnumParameter( 'continue', "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" );
+ $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" );
break;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry );
if ( !$fit ) {
- $this->setContinueEnumParameter( 'continue', "{$row->iwl_from}|{$row->iwl_prefix}|{$row->iwl_title}" );
+ $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" );
break;
}
}
public function getDescription() {
return array( 'Find all pages that link to the given interwiki link.',
'Can be used to find all links with a prefix, or',
- 'all links to a title (any prefix).',
+ 'all links to a title (with a given prefix).',
'Using neither parameter is effectively "All IW Links"',
- );
+ );
}
public function getPossibleErrors() {
),
'1.17' => array(
array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ),
- array( 'add_index', 'iwlinks', 'iwl_prefix_from_title', 'patch-rename-iwl_prefix.sql' ),
+ array( 'add_index', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
+ array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
+ array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
),
);
}
),
'1.17' => array(
array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ),
- array( 'add_index', 'iwlinks', 'iwl_prefix_from_title', 'patch-rename-iwl_prefix.sql' ),
+ array( 'add_index', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
+ array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
+ array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
),
);
}
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/iwl_from ON /*_*/iwlinks (iwl_from, iwl_prefix, iwl_title);
-CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);
+CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
--- /dev/null
+--
+-- Kill the old iwl_prefix_from_title index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks;
+
--- /dev/null
+--
+-- Kill the old iwl_prefix index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX /*i*/iwl_prefix ON /*_*/iwlinks;
+
--
--- Recreates the iwl_prefix for the iwlinks table
+-- Recreates the iwl_prefix index for the iwlinks table
--
-DROP INDEX /*i*/iwl_prefix ON /*_*/iwlinks;
-CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);
\ No newline at end of file
+CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
iwl_title TEXT NOT NULL DEFAULT ''
);
CREATE UNIQUE INDEX iwl_from ON iwlinks (iwl_from, iwl_prefix, iwl_title);
-CREATE INDEX iwl_prefix ON iwlinks (iwl_prefix, iwl_title);
+CREATE UNIQUE INDEX iwl_prefix_title_from ON iwlinks (iwl_prefix, iwl_title, iwl_from);
--- /dev/null
+--
+-- Kill the old iwl_prefix_from_title index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX iwl_prefix_from_title;
+
--- /dev/null
+--
+-- Kill the old iwl_prefix index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX iwl_prefix;
+
DROP INDEX iwl_prefix;
-CREATE INDEX iwl_prefix_from_title ON iwlinks (iwl_prefix, iwl_from, iwl_title);
\ No newline at end of file
+CREATE UNIQUE INDEX iwl_prefix_title_from ON iwlinks (iwl_prefix, iwl_from, iwl_title);
iwl_title TEXT NOT NULL DEFAULT ''
);
CREATE UNIQUE INDEX iwl_from ON iwlinks (iwl_from, iwl_prefix, iwl_title);
-CREATE INDEX iwl_prefix_from_title ON iwlinks (iwl_prefix, iwl_from, iwl_title);
+CREATE UNIQUE INDEX iwl_prefix_title_from ON iwlinks (iwl_prefix, iwl_title, iwl_from);
--- /dev/null
+--
+-- Kill the old iwl_prefix_from_title index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks;
+
--- /dev/null
+--
+-- Kill the old iwl_prefix index, which may be present on some
+-- installs if they ran update.php between it being added and being renamed
+--
+
+DROP INDEX /*i*/iwl_prefix ON /*_*/iwlinks;
+
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/iwl_from ON /*_*/iwlinks (iwl_from, iwl_prefix, iwl_title);
-CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);
+CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
--
array( "watchlist", "wl_user", "(wl_user)" ),
array( "logging", "logging_user_type_time", "(log_user, log_type, log_timestamp)" ),
array( "logging", "logging_page_id_time", "(log_page,log_timestamp)" ),
+ array( "iwlinks", "iwl_prefix_title_from", "(iwl_prefix, iwl_title, iwl_from)" ),
);
$newrules = array(