54 $this->redirTitle = Title::newFromText(
$params[
'redirTitle'] );
66 # Need to use the master to get the redirect table updated in the same transaction
69 [
'redirect',
'page' ],
70 [
'page_namespace',
'page_title' ],
76 if ( !
$res->numRows() ) {
80 foreach (
$res as $row ) {
81 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
86 $jobs[] =
new self(
$title, [
89 # Avoid excessive memory usage
90 if ( count( $jobs ) > 10000 ) {
91 JobQueueGroup::singleton()->push( $jobs );
95 JobQueueGroup::singleton()->push( $jobs );
102 if ( !$this->redirTitle ) {
108 $targetRev = MediaWikiServices::getInstance()
109 ->getRevisionLookup()
110 ->getRevisionByTitle( $this->title, 0, RevisionLookup::READ_LATEST );
112 wfDebug( __METHOD__ .
": target redirect already deleted, ignoring" );
116 $content = $targetRev->getContent( SlotRecord::MAIN );
118 if ( !$currentDest || !$currentDest->equals( $this->redirTitle ) ) {
119 wfDebug( __METHOD__ .
": Redirect has changed since the job was queued" );
125 $mw = MediaWikiServices::getInstance()->getMagicWordFactory()->get(
'staticredirect' );
126 if (
$content->matchMagicWord( $mw ) ) {
127 wfDebug( __METHOD__ .
": skipping: suppressed with __STATICREDIRECT__" );
136 ": skipping: single redirect, circular redirect or invalid redirect destination" );
140 if ( $newTitle->equals( $this->redirTitle ) ) {
143 wfDebug( __METHOD__ .
" : skipping, already good" );
147 $newTitle = Title::makeTitle( $newTitle->getNamespace(), $newTitle->getDBkey(),
148 $currentDest->getFragment(), $newTitle->getInterwiki() );
151 $newContent =
$content->updateRedirect( $newTitle );
153 if ( $newContent->equals(
$content ) ) {
170 $article = WikiPage::factory( $this->title );
173 $reason =
wfMessage(
'double-redirect-fixed-' . $this->params[
'reason'],
174 $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText()
175 )->inContentLanguage()->text();
177 $article->doEditContent( $newContent, $reason, $flags,
false,
$user );
200 if ( isset( $seenTitles[$titleText] ) ) {
201 wfDebug( __METHOD__,
"Circular redirect detected, aborting" );
205 $seenTitles[$titleText] =
true;
215 $row = $dbw->selectRow(
216 [
'redirect',
'page' ],
217 [
'rd_namespace',
'rd_title',
'rd_interwiki' ],
224 # No redirect from here, chain terminates
227 $dest =
$title = Title::makeTitle(
247 if ( !self::$user ) {
248 $username =
wfMessage(
'double-redirect-fixer' )->inContentLanguage()->text();
250 # User::newFromName() can return false on a badly configured wiki.
251 if ( self::$user && !self::$user->isLoggedIn() ) {
252 self::$user->addToDatabase();
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Job to fix double redirects after moving a page.
static getFinalDestination( $title)
Get the final destination of a redirect.
getUser()
Get a user object for doing edits, from a request-lifetime cache False will be returned if the user n...
static fixRedirects( $reason, $redirTitle, $destTitle=false)
Insert jobs into the job queue to fix redirects to the given title.
__construct(Title $title, array $params)
Title $redirTitle
The title which has changed, redirects pointing to this title are fixed.
Class to both describe a background job and handle jobs.
array $params
Array of job parameters.
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getPrefixedDBkey()
Get the prefixed database key form.
isExternal()
Is this Title interwiki?
getDBkey()
Get the main part with underscores.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.