r28992 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28991‎ | r28992 | r28993 >
Date:14:43, 29 December 2007
Author:vasilievvv
Status:old
Tags:
Comment:
* Proper redirect deletion
* Don't use ImagePage on redirects
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -2263,6 +2263,7 @@
22642264 $dbw->delete( 'externallinks', array( 'el_from' => $id ) );
22652265 $dbw->delete( 'langlinks', array( 'll_from' => $id ) );
22662266 $dbw->delete( 'redirect', array( 'rd_from' => $id ) );
 2267+ $dbw->delete( 'imageredirects', array( 'ir_from' => $t ) );
22672268 }
22682269
22692270 # If using cleanup triggers, we can skip some manual deletes
Index: trunk/phase3/includes/filerepo/File.php
@@ -46,7 +46,7 @@
4747 /**
4848 * The following member variables are not lazy-initialised
4949 */
50 - var $repo, $title, $lastError;
 50+ var $repo, $title, $lastError, $redirected;
5151
5252 /**
5353 * Call this constructor from child classes
@@ -1136,6 +1136,9 @@
11371137 return '';
11381138 }
11391139 }
 1140+
 1141+ function getRedirectedFrom() { return $this->redirected; }
 1142+ function setRedirectedFrom( $v ) { $this->redirected = $v; }
11401143 }
11411144 /**
11421145 * Aliases for backwards compatibility with 1.6
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -90,11 +90,13 @@
9191 return false;
9292 }
9393 if ( $img->exists() && ( !$time || $img->getTimestamp() <= $time ) ) {
 94+ $img->setRedirectedFrom( $redirected );
9495 return $img;
9596 }
9697 # Now try an old version of the file
9798 $img = $this->newFile( $title, $time );
9899 if ( $img->exists() ) {
 100+ $img->setRedirectedFrom( $redirected );
99101 return $img;
100102 }
101103
Index: trunk/phase3/includes/Wiki.php
@@ -219,12 +219,17 @@
220220 }
221221
222222 switch( $title->getNamespace() ) {
223 - case NS_IMAGE:
224 - return new ImagePage( $title );
225 - case NS_CATEGORY:
226 - return new CategoryPage( $title );
227 - default:
228 - return new Article( $title );
 223+ case NS_IMAGE:
 224+ $file = RepoGroup::singleton()->findFile( $title->getText() );
 225+ if( $file && $file->getRedirectedFrom() ) {
 226+ return new Article( $title );
 227+ } else {
 228+ return new ImagePage( $title );
 229+ }
 230+ case NS_CATEGORY:
 231+ return new CategoryPage( $title );
 232+ default:
 233+ return new Article( $title );
229234 }
230235 }
231236

Follow-up revisions

RevisionCommit summaryAuthorDate
r29128Revert for now r28986, 28987, 28992 - image redirects....brion20:26, 31 December 2007

Status & tagging log