* @param mixed $time Requested time for an archived image, or false for the
* current version. An image object will be returned which
* was created at the specified time.
+ * @param mixed $flags FileRepo::FIND_ flags
* @return File, or false if the file does not exist
*/
-function wfFindFile( $title, $time = false ) {
- return RepoGroup::singleton()->findFile( $title, $time );
+function wfFindFile( $title, $time = false, $flags = 0 ) {
+ return RepoGroup::singleton()->findFile( $title, $time, $flags );
}
/**
$action = $this->getVal( 'action' );
$article = self::articleFromTitle( $title );
-
+
+ wfDebug("Article: ".$title->getPrefixedText()."\n");
+
// Namespace might change when using redirects
- if( ( $action == 'view' || $action == 'render' ) && !$request->getVal( 'oldid' ) &&
- $request->getVal( 'redirect' ) != 'no' &&
- !( $title->getNamespace() == NS_IMAGE && wfFindFile( $title->getText() ) ) ) {
+ // Check for redirects ...
+ if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
+ && !$request->getVal( 'oldid' ) && // ... and are not old revisions
+ $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
+ // ... and the article is not an image page with associated file
+ !( $title->getNamespace() == NS_IMAGE && wfFindFile( $title->getText(), false,
+ FileRepo::FIND_IGNORE_REDIRECT ) ) ) { // ... unless it is really an image redirect
$dbr = wfGetDB( DB_SLAVE );
$article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
abstract class FileRepo {
const DELETE_SOURCE = 1;
const FIND_PRIVATE = 1;
+ const FIND_IGNORE_REDIRECT = 2;
const OVERWRITE = 2;
const OVERWRITE_SAME = 4;
}
}
}
+
# Now try redirects
- $redir = $this->checkRedirect( $title );
+ if ( $flags & FileRepo::FIND_IGNORE_REDIRECT ) return false;
+ $redir = $this->checkRedirect( $title );
if( $redir && $redir->getNamespace() == NS_IMAGE) {
$img = $this->newFile( $redir );
if( !$img ) {
* @param mixed $title Title object or string
* @param mixed $time The 14-char timestamp the file should have
* been uploaded, or false for the current version
+ * @param mixed $flags FileRepo::FIND_ flags
* @return File object or false if it is not found
*/
- function findFile( $title, $time = false ) {
+ function findFile( $title, $time = false, $flags = 0 ) {
if ( !$this->reposInitialised ) {
$this->initialiseRepos();
}
- $image = $this->localRepo->findFile( $title, $time );
+ $image = $this->localRepo->findFile( $title, $time, $flags );
if ( $image ) {
return $image;
}
foreach ( $this->foreignRepos as $repo ) {
- $image = $repo->findFile( $title, $time );
+ $image = $repo->findFile( $title, $time, $flags );
if ( $image ) {
return $image;
}