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.
* 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 ===
$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) {
}
wfProfileOut( __METHOD__ );
- return ( $dbw->affectedRows() != 0 ) && $imageResult;
+ return ( $dbw->affectedRows() != 0 );
}
return true;
$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
}
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 );
}
}
/**
* The following member variables are not lazy-initialised
*/
- var $repo, $title, $lastError, $redirected;
+ var $repo, $title, $lastError;
/**
* Call this constructor from child classes
return '';
}
}
-
- function getRedirectedFrom() { return $this->redirected; }
- function setRedirectedFrom( $v ) { $this->redirected = $v; }
}
/**
* Aliases for backwards compatibility with 1.6
*
* @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 );
- }
}
/**
* 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;
- }
}
--- 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
) /*$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
$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(