r32846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32845‎ | r32846 | r32847 >
Date:10:18, 6 April 2008
Author:tstarling
Status:old
Tags:
Comment:
* File redirects are slow: 2 queries per image per repository on parse. We previously found one query per image on parse to be prohibitively slow, that's why we introduced the image cache. Thus, reintroduced $wgFileRedirects.
* Fixed bug due to checkRedirect() not accepting a string title like findFile()
* Use protected instead of private. Private should not be used ever.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -46,7 +46,7 @@
4747 /**
4848 * Create a new File object from the local repository
4949 * @param mixed $title Title object or string
50 - * @param mixed $time Time at which the image is supposed to have existed.
 50+ * @param mixed $time Time at which the image was uploaded.
5151 * If this is specified, the returned object will be an
5252 * instance of the repository's old file class instead of
5353 * a current file. Repositories not supporting version
@@ -72,12 +72,19 @@
7373
7474 /**
7575 * Find an instance of the named file created at the specified time
76 - * Returns false if the file did not exist. Repositories not supporting
 76+ * Returns false if the file does not exist. Repositories not supporting
7777 * version control should return false if the time is specified.
7878 *
 79+ * @param mixed $title Title object or string
7980 * @param mixed $time 14-character timestamp, or false for the current version
8081 */
8182 function findFile( $title, $time = false, $flags = 0 ) {
 83+ if ( !($title instanceof Title) ) {
 84+ $title = Title::makeTitleSafe( NS_IMAGE, $title );
 85+ if ( !is_object( $title ) ) {
 86+ return false;
 87+ }
 88+ }
8289 # First try the current version of the file to see if it precedes the timestamp
8390 $img = $this->newFile( $title );
8491 if ( !$img ) {
Index: trunk/phase3/includes/filerepo/LocalRepo.php
@@ -74,7 +74,7 @@
7575 * Function link Title::getArticleID().
7676 * We can't say Title object, what database it should use, so we duplicate that function here.
7777 */
78 - private function getArticleID( $title ) {
 78+ protected function getArticleID( $title ) {
7979 if( !$title instanceof Title ) {
8080 return 0;
8181 }
@@ -92,6 +92,11 @@
9393 }
9494
9595 function checkRedirect( $title ) {
 96+ global $wgFileRedirects;
 97+ if( !$wgFileRedirects ) {
 98+ return false;
 99+ }
 100+
96101 if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
97102 $title = Title::makeTitle( NS_IMAGE, $title->getText() );
98103 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -461,6 +461,11 @@
462462 */
463463 $wgRepositoryBaseUrl = "http://commons.wikimedia.org/wiki/Image:";
464464
 465+/**
 466+ * File redirects
 467+ * If enabled, MediaWiki checks redirects in Image: namespace.
 468+ */
 469+$wgFileRedirects = false;
465470
466471 #
467472 # Email settings

Status & tagging log