r29128 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29127‎ | r29128 | r29129 >
Date:20:26, 31 December 2007
Author:brion
Status:old
Tags:
Comment:
Revert for now r28986, 28987, 28992 - image redirects.
Would prefer to properly review how this works and how it interacts with current and future image behavior, rather than being surprised by it in the middle of ten other things being reviewed.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /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)
  • /trunk/phase3/maintenance/archives/patch-image_reditects.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-image_reditects.sql
@@ -1,6 +0,0 @@
2 -CREATE TABLE /*$wgDBprefix*/imageredirects (
3 - ir_from varchar(255) binary NOT NULL default '',
4 - ir_to varchar(255) binary NOT NULL default '',
5 - PRIMARY KEY ir_from (ir_from)
6 -) /*$wgDBTableOptions*/;
\ No newline at end of file
Index: trunk/phase3/maintenance/updaters.inc
@@ -23,23 +23,22 @@
2424
2525 $wgNewTables = array(
2626 # table patch file (in maintenance/archives)
27 - array( 'hitcounter', 'patch-hitcounter.sql' ),
28 - array( 'querycache', 'patch-querycache.sql' ),
29 - array( 'objectcache', 'patch-objectcache.sql' ),
30 - array( 'categorylinks', 'patch-categorylinks.sql' ),
31 - array( 'logging', 'patch-logging.sql' ),
32 - array( 'user_newtalk', 'patch-usernewtalk2.sql' ),
33 - array( 'transcache', 'patch-transcache.sql' ),
34 - array( 'trackbacks', 'patch-trackbacks.sql' ),
35 - array( 'externallinks', 'patch-externallinks.sql' ),
36 - array( 'job', 'patch-job.sql' ),
37 - array( 'langlinks', 'patch-langlinks.sql' ),
38 - array( 'querycache_info', 'patch-querycacheinfo.sql' ),
39 - array( 'filearchive', 'patch-filearchive.sql' ),
40 - array( 'querycachetwo', 'patch-querycachetwo.sql' ),
41 - array( 'redirect', 'patch-redirect.sql' ),
 27+ array( 'hitcounter', 'patch-hitcounter.sql' ),
 28+ array( 'querycache', 'patch-querycache.sql' ),
 29+ array( 'objectcache', 'patch-objectcache.sql' ),
 30+ array( 'categorylinks', 'patch-categorylinks.sql' ),
 31+ array( 'logging', 'patch-logging.sql' ),
 32+ array( 'user_newtalk', 'patch-usernewtalk2.sql' ),
 33+ array( 'transcache', 'patch-transcache.sql' ),
 34+ array( 'trackbacks', 'patch-trackbacks.sql' ),
 35+ array( 'externallinks', 'patch-externallinks.sql' ),
 36+ array( 'job', 'patch-job.sql' ),
 37+ array( 'langlinks', 'patch-langlinks.sql' ),
 38+ array( 'querycache_info', 'patch-querycacheinfo.sql' ),
 39+ array( 'filearchive', 'patch-filearchive.sql' ),
 40+ array( 'querycachetwo', 'patch-querycachetwo.sql' ),
 41+ array( 'redirect', 'patch-redirect.sql' ),
4242 array( 'protected_titles', 'patch-protected_titles.sql' ),
43 - array( 'imageredirects', 'patch-image_reditects.sql' ),
4443 );
4544
4645 $wgNewFields = array(
Index: trunk/phase3/maintenance/tables.sql
@@ -711,17 +711,6 @@
712712 ) /*$wgDBTableOptions*/;
713713
714714 --
715 -CREATE TABLE /*$wgDBprefix*/imageredirects (
716 - -- Source image name
717 - ir_from varchar(255) binary NOT NULL default '',
718 - -- Destination image name
719 - ir_to varchar(255) binary NOT NULL default '',
720 -
721 - PRIMARY KEY ir_from (ir_from)
722 -) /*$wgDBTableOptions*/;
723715 -- Previous revisions of uploaded files.
724716 -- Awkwardly, image rows have to be moved into
725717 -- this table at re-upload time.
Index: trunk/phase3/includes/Article.php
@@ -1098,27 +1098,6 @@
10991099 $isRedirect = !is_null($redirectTitle);
11001100 if ($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
11011101
1102 - $imageResult = true; //Result of imageredirects handling
1103 - if( $this->mTitle->getNamespace() == NS_IMAGE ) {
1104 - wfProfileIn( __METHOD__ . "-img" );
1105 -
1106 - $exists = $redirectTitle ? RepoGroup::singleton()->findFile( $redirectTitle->getDBkey() ) !== false : false;
1107 - if( $isRedirect && $redirectTitle->getNamespace() == NS_IMAGE && $exists ) {
1108 - $set = array(
1109 - 'ir_from' => $this->mTitle->getDBkey(),
1110 - 'ir_to' => $redirectTitle->getDBkey(),
1111 - );
1112 - $dbw->replace( 'imageredirects', array( 'ir_from' ), $set, __METHOD__ );
1113 - $imageResult = $dbw->affectedRows() != 0;
1114 - } else {
1115 - // Non-redirect or redirect to non-image
1116 - $where = array( 'ir_from' => $this->mTitle->getDBkey() );
1117 - $dbw->delete( 'imageredirects', $where, __METHOD__ );
1118 - }
1119 -
1120 - wfProfileOut( __METHOD__ . "-img" );
1121 - }
1122 -
11231102 wfProfileIn( __METHOD__ );
11241103
11251104 if ($isRedirect) {
@@ -1138,7 +1117,7 @@
11391118 }
11401119
11411120 wfProfileOut( __METHOD__ );
1142 - return ( $dbw->affectedRows() != 0 ) && $imageResult;
 1121+ return ( $dbw->affectedRows() != 0 );
11431122 }
11441123
11451124 return true;
@@ -2263,7 +2242,6 @@
22642243 $dbw->delete( 'externallinks', array( 'el_from' => $id ) );
22652244 $dbw->delete( 'langlinks', array( 'll_from' => $id ) );
22662245 $dbw->delete( 'redirect', array( 'rd_from' => $id ) );
2267 - $dbw->delete( 'imageredirects', array( 'ir_from' => $t ) );
22682246 }
22692247
22702248 # 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, $redirected;
 50+ var $repo, $title, $lastError;
5151
5252 /**
5353 * Call this constructor from child classes
@@ -1136,9 +1136,6 @@
11371137 return '';
11381138 }
11391139 }
1140 -
1141 - function getRedirectedFrom() { return $this->redirected; }
1142 - function setRedirectedFrom( $v ) { $this->redirected = $v; }
11431140 }
11441141 /**
11451142 * Aliases for backwards compatibility with 1.6
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -76,36 +76,20 @@
7777 *
7878 * @param mixed $time 14-character timestamp, or false for the current version
7979 */
80 - function findFile( $title, $time = false, $redirected = false ) {
81 - if ( !($title instanceof Title) ) {
82 - $title = Title::makeTitleSafe( NS_IMAGE, $title );
83 - if ( !is_object( $title ) ) {
84 - return null;
85 - }
86 - }
87 -
 80+ function findFile( $title, $time = false ) {
8881 # First try the current version of the file to see if it precedes the timestamp
8982 $img = $this->newFile( $title );
9083 if ( !$img ) {
9184 return false;
9285 }
9386 if ( $img->exists() && ( !$time || $img->getTimestamp() <= $time ) ) {
94 - $img->setRedirectedFrom( $redirected );
9587 return $img;
9688 }
9789 # Now try an old version of the file
9890 $img = $this->newFile( $title, $time );
9991 if ( $img->exists() ) {
100 - $img->setRedirectedFrom( $redirected );
10192 return $img;
10293 }
103 -
104 - #Try redirects
105 - if( !$redirected ) { // Prevent redirect loops
106 - $redir = $this->checkRedirects( $title->getDBkey() );
107 - if( $redir )
108 - return $this->findFile( $redir, $time, $title );
109 - }
11094 }
11195
11296 /**
@@ -416,20 +400,5 @@
417401 * STUB
418402 */
419403 function cleanupDeletedBatch( $storageKeys ) {}
420 -
421 - /**
422 - * Check for redirects.
423 - */
424 - function checkRedirects( $filename ) {
425 - $dbr = $this->getSlaveDB();
426 - $res = $dbr->selectRow(
427 - 'imageredirects',
428 - array( 'ir_from', 'ir_to' ),
429 - array( 'ir_from' => $filename ),
430 - __METHOD__
431 - );
432 - if( !$res ) return false;
433 - return $res->ir_to;
434 - }
435404 }
436405
Index: trunk/phase3/includes/Wiki.php
@@ -219,17 +219,12 @@
220220 }
221221
222222 switch( $title->getNamespace() ) {
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 );
 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 );
234229 }
235230 }
236231
Index: trunk/phase3/RELEASE-NOTES
@@ -112,7 +112,6 @@
113113 * Add HTML ID's mw-read-only-warning and mw-anon-edit-warning to warnings when
114114 editing to allow CSS styling.
115115 * Parser now returns list of sections
116 -* Support images-redirects
117116
118117 === Bug fixes in 1.12 ===
119118

Follow-up revisions

RevisionCommit summaryAuthorDate
r87306Remove empty files left by r16526, r29128 and r83029platonides22:36, 2 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r28986* Support images-redirects...vasilievvv09:32, 29 December 2007
r28987Oops, forgot to remove this debug stuffvasilievvv09:42, 29 December 2007
r28992* Proper redirect deletion...vasilievvv14:43, 29 December 2007

Status & tagging log