Revert for now r28986, 28987, 28992 - image redirects.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 31 Dec 2007 20:26:53 +0000 (20:26 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 31 Dec 2007 20:26:53 +0000 (20:26 +0000)
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.

RELEASE-NOTES
includes/Article.php
includes/Wiki.php
includes/filerepo/File.php
includes/filerepo/FileRepo.php
maintenance/archives/patch-image_reditects.sql
maintenance/tables.sql
maintenance/updaters.inc

index 704a9a1..5e80096 100644 (file)
@@ -112,7 +112,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Add HTML ID's mw-read-only-warning and mw-anon-edit-warning to warnings when
   editing to allow CSS styling.
 * Parser now returns list of sections
 * Add HTML ID's mw-read-only-warning and mw-anon-edit-warning to warnings when
   editing to allow CSS styling.
 * Parser now returns list of sections
-* Support images-redirects
 
 === Bug fixes in 1.12 ===
 
 
 === Bug fixes in 1.12 ===
 
index d867ce4..9a7e85b 100644 (file)
@@ -1098,27 +1098,6 @@ class Article {
                $isRedirect = !is_null($redirectTitle);
                if ($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
 
                $isRedirect = !is_null($redirectTitle);
                if ($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
 
-                       $imageResult = true;    //Result of imageredirects handling
-                       if( $this->mTitle->getNamespace() == NS_IMAGE ) {
-                               wfProfileIn( __METHOD__ . "-img" );
-
-                               $exists = $redirectTitle ? RepoGroup::singleton()->findFile( $redirectTitle->getDBkey() ) !== false : false;
-                               if( $isRedirect && $redirectTitle->getNamespace() == NS_IMAGE && $exists ) {
-                                       $set = array( 
-                                               'ir_from' => $this->mTitle->getDBkey(),
-                                               'ir_to' => $redirectTitle->getDBkey(),
-                                       );
-                                       $dbw->replace( 'imageredirects', array( 'ir_from' ), $set, __METHOD__ );
-                                       $imageResult = $dbw->affectedRows() != 0;
-                               } else {
-                                       // Non-redirect or redirect to non-image
-                                       $where = array( 'ir_from' => $this->mTitle->getDBkey() );
-                                       $dbw->delete( 'imageredirects', $where, __METHOD__ );
-                               }
-
-                               wfProfileOut( __METHOD__ . "-img" );
-                       }
-
                        wfProfileIn( __METHOD__ );
 
                        if ($isRedirect) {
                        wfProfileIn( __METHOD__ );
 
                        if ($isRedirect) {
@@ -1138,7 +1117,7 @@ class Article {
                        }
 
                        wfProfileOut( __METHOD__ );
                        }
 
                        wfProfileOut( __METHOD__ );
-                       return ( $dbw->affectedRows() != 0 ) && $imageResult;
+                       return ( $dbw->affectedRows() != 0 );
                }
 
                return true;
                }
 
                return true;
@@ -2263,7 +2242,6 @@ class Article {
                        $dbw->delete( 'externallinks', array( 'el_from' => $id ) );
                        $dbw->delete( 'langlinks', array( 'll_from' => $id ) );
                        $dbw->delete( 'redirect', array( 'rd_from' => $id ) );
                        $dbw->delete( 'externallinks', array( 'el_from' => $id ) );
                        $dbw->delete( 'langlinks', array( 'll_from' => $id ) );
                        $dbw->delete( 'redirect', array( 'rd_from' => $id ) );
-                       $dbw->delete( 'imageredirects', array( 'ir_from' => $t ) );
                }
 
                # If using cleanup triggers, we can skip some manual deletes
                }
 
                # If using cleanup triggers, we can skip some manual deletes
index 7945c7a..4920ff2 100644 (file)
@@ -219,17 +219,12 @@ class MediaWiki {
                }
 
                switch( $title->getNamespace() ) {
                }
 
                switch( $title->getNamespace() ) {
-                       case NS_IMAGE:
-                               $file = RepoGroup::singleton()->findFile( $title->getText() );
-                               if( $file && $file->getRedirectedFrom() ) {
-                                       return new Article( $title );
-                               } else {
-                                       return new ImagePage( $title );
-                               }
-                       case NS_CATEGORY:
-                               return new CategoryPage( $title );
-                       default:
-                               return new Article( $title );
+               case NS_IMAGE:
+                       return new ImagePage( $title );
+               case NS_CATEGORY:
+                       return new CategoryPage( $title );
+               default:
+                       return new Article( $title );
                }
        }
 
                }
        }
 
index 36729e1..7e222a0 100644 (file)
@@ -46,7 +46,7 @@ abstract class File {
        /**
         * The following member variables are not lazy-initialised
         */
        /**
         * The following member variables are not lazy-initialised
         */
-       var $repo, $title, $lastError, $redirected;
+       var $repo, $title, $lastError;
 
        /**
         * Call this constructor from child classes
 
        /**
         * Call this constructor from child classes
@@ -1136,9 +1136,6 @@ abstract class File {
                        return '';
                }
        }
                        return '';
                }
        }
-       
-       function getRedirectedFrom()   { return $this->redirected; }
-       function setRedirectedFrom( $v ) { $this->redirected = $v; }
 }
 /**
  * Aliases for backwards compatibility with 1.6
 }
 /**
  * Aliases for backwards compatibility with 1.6
index 648acf0..cf6d65c 100644 (file)
@@ -76,36 +76,20 @@ abstract class FileRepo {
         *
         * @param mixed $time 14-character timestamp, or false for the current version
         */
         *
         * @param mixed $time 14-character timestamp, or false for the current version
         */
-       function findFile( $title, $time = false, $redirected = false ) {
-               if ( !($title instanceof Title) ) {
-                       $title = Title::makeTitleSafe( NS_IMAGE, $title );
-                       if ( !is_object( $title ) ) {
-                               return null;
-                       }
-               }
-       
+       function findFile( $title, $time = false ) {
                # First try the current version of the file to see if it precedes the timestamp
                $img = $this->newFile( $title );
                if ( !$img ) {
                        return false;
                }
                if ( $img->exists() && ( !$time || $img->getTimestamp() <= $time ) ) {
                # First try the current version of the file to see if it precedes the timestamp
                $img = $this->newFile( $title );
                if ( !$img ) {
                        return false;
                }
                if ( $img->exists() && ( !$time || $img->getTimestamp() <= $time ) ) {
-                       $img->setRedirectedFrom( $redirected );
                        return $img;
                }
                # Now try an old version of the file
                $img = $this->newFile( $title, $time );
                if ( $img->exists() ) {
                        return $img;
                }
                # Now try an old version of the file
                $img = $this->newFile( $title, $time );
                if ( $img->exists() ) {
-                       $img->setRedirectedFrom( $redirected );
                        return $img;
                }
                        return $img;
                }
-
-               #Try redirects
-               if( !$redirected ) {    // Prevent redirect loops
-                       $redir = $this->checkRedirects( $title->getDBkey() );
-                       if( $redir )
-                               return $this->findFile( $redir, $time, $title );
-               }
        }
 
        /**
        }
 
        /**
@@ -416,20 +400,5 @@ abstract class FileRepo {
         * STUB
         */
        function cleanupDeletedBatch( $storageKeys ) {}
         * STUB
         */
        function cleanupDeletedBatch( $storageKeys ) {}
-       
-       /**
-        * Check for redirects.
-        */
-       function checkRedirects( $filename ) {
-               $dbr = $this->getSlaveDB();
-               $res = $dbr->selectRow(
-                       'imageredirects',
-                       array( 'ir_from', 'ir_to' ),
-                       array( 'ir_from' => $filename ),
-                       __METHOD__
-               );
-               if( !$res ) return false;
-               return $res->ir_to;
-       }
 }
 
 }
 
index 66c9b7f..e69de29 100644 (file)
@@ -1,6 +0,0 @@
--- Image redirects. Only existent images are put in this table.
-CREATE TABLE /*$wgDBprefix*/imageredirects (
-       ir_from varchar(255) binary NOT NULL default '',
-       ir_to   varchar(255) binary NOT NULL default '',
-       PRIMARY KEY ir_from (ir_from)
-) /*$wgDBTableOptions*/;
\ No newline at end of file
index 52b0ec5..6282f52 100644 (file)
@@ -710,17 +710,6 @@ CREATE TABLE /*$wgDBprefix*/image (
 
 ) /*$wgDBTableOptions*/;
 
 
 ) /*$wgDBTableOptions*/;
 
---
--- Image redirects. Only existent images are put in this table.
---
-CREATE TABLE /*$wgDBprefix*/imageredirects (
-       -- Source image name
-       ir_from varchar(255) binary NOT NULL default '',
-       -- Destination image name
-       ir_to   varchar(255) binary NOT NULL default '',
-
-       PRIMARY KEY ir_from (ir_from)
-) /*$wgDBTableOptions*/;
 --
 -- Previous revisions of uploaded files.
 -- Awkwardly, image rows have to be moved into
 --
 -- Previous revisions of uploaded files.
 -- Awkwardly, image rows have to be moved into
index 4ec5735..9f7ce2a 100644 (file)
@@ -23,23 +23,22 @@ $wgRenamedTables = array(
 
 $wgNewTables = array(
 #            table          patch file (in maintenance/archives)
 
 $wgNewTables = array(
 #            table          patch file (in maintenance/archives)
-       array( 'hitcounter',       'patch-hitcounter.sql' ),
-       array( 'querycache',       'patch-querycache.sql' ),
-       array( 'objectcache',      'patch-objectcache.sql' ),
-       array( 'categorylinks',    'patch-categorylinks.sql' ),
-       array( 'logging',          'patch-logging.sql' ),
-       array( 'user_newtalk',     'patch-usernewtalk2.sql' ),
-       array( 'transcache',       'patch-transcache.sql' ),
-       array( 'trackbacks',       'patch-trackbacks.sql' ),
-       array( 'externallinks',    'patch-externallinks.sql' ),
-       array( 'job',              'patch-job.sql' ),
-       array( 'langlinks',        'patch-langlinks.sql' ),
-       array( 'querycache_info',  'patch-querycacheinfo.sql' ),
-       array( 'filearchive',      'patch-filearchive.sql' ),
-       array( 'querycachetwo',    'patch-querycachetwo.sql' ),
-       array( 'redirect',         'patch-redirect.sql' ),
+       array( 'hitcounter',    'patch-hitcounter.sql' ),
+       array( 'querycache',    'patch-querycache.sql' ),
+       array( 'objectcache',   'patch-objectcache.sql' ),
+       array( 'categorylinks', 'patch-categorylinks.sql' ),
+       array( 'logging',       'patch-logging.sql' ),
+       array( 'user_newtalk',  'patch-usernewtalk2.sql' ),
+       array( 'transcache',    'patch-transcache.sql' ),
+       array( 'trackbacks',    'patch-trackbacks.sql' ),
+       array( 'externallinks', 'patch-externallinks.sql' ),
+       array( 'job',           'patch-job.sql' ),
+       array( 'langlinks',     'patch-langlinks.sql' ),
+       array( 'querycache_info', 'patch-querycacheinfo.sql' ),
+       array( 'filearchive',   'patch-filearchive.sql' ),
+       array( 'querycachetwo', 'patch-querycachetwo.sql' ),
+       array( 'redirect', 'patch-redirect.sql' ),
        array( 'protected_titles', 'patch-protected_titles.sql' ),
        array( 'protected_titles', 'patch-protected_titles.sql' ),
-       array( 'imageredirects',   'patch-image_reditects.sql' ),
 );
 
 $wgNewFields = array(
 );
 
 $wgNewFields = array(