From bd3be620489b17f56063b98a96ea7b78abe85f04 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Sat, 19 Mar 2011 04:24:15 +0000 Subject: [PATCH] Fix for Bug# 17463: New pages log doesn't remove/update item after suppression redirect MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Except for some whitespace changes, this is Baowolff's patch from http://bug-attachment.wikimedia.org/attachment.cgi?id=8312 which I am applying in the spirit of “apologize later”. Baowolff writes: Don't show new page entries in Special:newpage for supressed redirects. Patch to remove the new page entry from Special:RecentChange and special:newpages, if the new page gets moved with redirect supressed. I'm not a 100% sure this is a good idea. This will only suppress the initial new page line in the RC (And newpages), and won't supress any other edits to the page. Does this behaviour really make sense? (Thats not rhetorical). It seems somewhat different from deleting a page, where none of the content is relevent, but when you move a page, the edits don't go away, they're just in a new title. I suppose we could just change the new page entry in the RC to point to the other page, but that seems rather wrong too. So anyhow, not sure what the right approach is. --- includes/Title.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index d878642e8c..39ecc5f7de 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2984,7 +2984,7 @@ class Title { if ( $this->getNamespace() == NS_FILE ) { $errors = array_merge( $errors, $this->validateFileMoveOperation( $nt ) ); } - + if ( $nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE ) { $errors[] = array( 'nonfile-cannot-move-to-file' ); } @@ -3028,7 +3028,7 @@ class Title { } return $errors; } - + /** * Check if the requested move target is a valid file move target * @param Title $nt Target title @@ -3036,13 +3036,13 @@ class Title { */ protected function validateFileMoveOperation( $nt ) { global $wgUser; - + $errors = array(); - + if ( $nt->getNamespace() != NS_FILE ) { $errors[] = array( 'imagenocrossnamespace' ); } - + $file = wfLocalFile( $this ); if ( $file->exists() ) { if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) { @@ -3052,12 +3052,12 @@ class Title { $errors[] = array( 'imagetypemismatch' ); } } - + $destFile = wfLocalFile( $nt ); if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) { $errors[] = array( 'file-exists-sharedrepo' ); } - + return $errors; } @@ -3232,6 +3232,9 @@ class Title { $oldid = $this->getArticleID(); $latest = $this->getLatestRevID(); + $oldns = $this->getNamespace(); + $olddbk = $this->getDBkey(); + $dbw = wfGetDB( DB_MASTER ); if ( $moveOverRedirect ) { @@ -3316,6 +3319,17 @@ class Title { __METHOD__ ); $redirectSuppressed = false; } else { + // Get rid of old new page entries in Special:NewPages and RC. + // Needs to be before $this->resetArticleUD( 0 ). + $dbw->delete( 'recentchanges', array( + 'rc_timestamp' => $dbw->timestamp( $this->getEarliestRevTime() ), + 'rc_namespace' => $oldns, + 'rc_title' => $olddbk, + 'rc_new' => 1 + ), + __METHOD__ + ); + $this->resetArticleID( 0 ); $redirectSuppressed = true; } @@ -4150,15 +4164,15 @@ class Title { } wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) ); - - wfDebug( __METHOD__ . ': applicable restriction types for ' . + + wfDebug( __METHOD__ . ': applicable restriction types for ' . $this->getPrefixedText() . ' are ' . implode( ',', $types ) . "\n" ); return $types; } /** - * Get a filtered list of all restriction types supported by this wiki. - * @param bool $exists True to get all restriction types that apply to + * Get a filtered list of all restriction types supported by this wiki. + * @param bool $exists True to get all restriction types that apply to * titles that do exist, False for all restriction types that apply to * titles that do not exist * @return array -- 2.20.1