From 7c1170dcbf2d946f2cd6a5f56a9adb5161e9dad2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 31 Dec 2007 20:26:53 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 1 - includes/Article.php | 24 +------------- includes/Wiki.php | 17 ++++------ includes/filerepo/File.php | 5 +-- includes/filerepo/FileRepo.php | 33 +------------------ .../archives/patch-image_reditects.sql | 6 ---- maintenance/tables.sql | 11 ------- maintenance/updaters.inc | 31 +++++++++-------- 8 files changed, 24 insertions(+), 104 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 704a9a10bf..5e80096150 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 -* Support images-redirects === Bug fixes in 1.12 === diff --git a/includes/Article.php b/includes/Article.php index d867ce4825..9a7e85bd6d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1098,27 +1098,6 @@ class Article { $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) { @@ -1138,7 +1117,7 @@ class Article { } wfProfileOut( __METHOD__ ); - return ( $dbw->affectedRows() != 0 ) && $imageResult; + return ( $dbw->affectedRows() != 0 ); } 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( 'imageredirects', array( 'ir_from' => $t ) ); } # If using cleanup triggers, we can skip some manual deletes diff --git a/includes/Wiki.php b/includes/Wiki.php index 7945c7ad3a..4920ff2b21 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -219,17 +219,12 @@ class MediaWiki { } 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 ); } } diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 36729e13b5..7e222a0846 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -46,7 +46,7 @@ abstract class File { /** * The following member variables are not lazy-initialised */ - var $repo, $title, $lastError, $redirected; + var $repo, $title, $lastError; /** * Call this constructor from child classes @@ -1136,9 +1136,6 @@ abstract class File { return ''; } } - - function getRedirectedFrom() { return $this->redirected; } - function setRedirectedFrom( $v ) { $this->redirected = $v; } } /** * Aliases for backwards compatibility with 1.6 diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 648acf08a5..cf6d65c2ce 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -76,36 +76,20 @@ abstract class FileRepo { * * @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 ) ) { - $img->setRedirectedFrom( $redirected ); return $img; } # Now try an old version of the file $img = $this->newFile( $title, $time ); if ( $img->exists() ) { - $img->setRedirectedFrom( $redirected ); 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 ) {} - - /** - * 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; - } } diff --git a/maintenance/archives/patch-image_reditects.sql b/maintenance/archives/patch-image_reditects.sql index 66c9b7ffb4..e69de29bb2 100644 --- a/maintenance/archives/patch-image_reditects.sql +++ b/maintenance/archives/patch-image_reditects.sql @@ -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 diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 52b0ec5dfc..6282f52287 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -710,17 +710,6 @@ CREATE TABLE /*$wgDBprefix*/image ( ) /*$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 diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 4ec57351e1..9f7ce2a29f 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -23,23 +23,22 @@ $wgRenamedTables = array( $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( 'imageredirects', 'patch-image_reditects.sql' ), ); $wgNewFields = array( -- 2.20.1