* 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
+ file_put_contents( "C:\\err.txt", strval( $this->mTitle->getNamespace() == NS_IMAGE ) );
+ 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 );
+ return ( $dbw->affectedRows() != 0 ) && $imageResult;
}
return true;
*
* @param mixed $time 14-character timestamp, or false for the current version
*/
- function findFile( $title, $time = false ) {
+ function findFile( $title, $time = false, $redirected = false ) {
+ if ( !($title instanceof Title) ) {
+ $title = Title::makeTitleSafe( NS_IMAGE, $title );
+ if ( !is_object( $title ) ) {
+ return null;
+ }
+ }
+
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
if ( !$img ) {
if ( $img->exists() ) {
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;
+ }
}
--- /dev/null
+-- 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(