RepoGroup::singleton()->getLocalRepo(), $archiveName );
} else {
$file = wfLocalFile( $this->getTitle() );
+ $file->load( File::READ_LATEST );
wfDebug( __METHOD__ . 'Importing new file as ' . $file->getName() . "\n" );
if ( $file->exists() && $file->getTimestamp() > $this->getTimestamp() ) {
$archiveName = $file->getTimestamp() . '!' . $file->getName();
protected function isValidFileMove() {
$status = new Status();
$file = wfLocalFile( $this->oldTitle );
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
if ( $this->newTitle->getText() != wfStripIllegalFilenameChars( $this->newTitle->getText() ) ) {
$status->fatal( 'imageinvalidfilename' );
# Is it an existing file?
if ( $this->newTitle->inNamespace( NS_FILE ) ) {
$file = wfLocalFile( $this->newTitle );
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
wfDebug( __METHOD__ . ": file exists\n" );
return false;
$dbw = wfGetDB( DB_MASTER );
if ( $this->oldTitle->getNamespace() == NS_FILE ) {
$file = wfLocalFile( $this->oldTitle );
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
$status = $file->move( $this->newTitle );
if ( !$status->isOk() ) {
$errors = array();
$destFile = wfLocalFile( $nt );
- if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destFile->exists() && wfFindFile( $nt ) ) {
+ $destFile->load( File::READ_LATEST );
+ if ( !$wgUser->isAllowed( 'reupload-shared' )
+ && !$destFile->exists() && wfFindFile( $nt )
+ ) {
$errors[] = array( 'file-exists-sharedrepo' );
}
# Is it an existing file?
if ( $nt->getNamespace() == NS_FILE ) {
$file = wfLocalFile( $nt );
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
wfDebug( __METHOD__ . ": file exists\n" );
return false;
$r['missing'] = '';
}
- $file = wfFindFile( $title );
+ $file = wfFindFile( $title, array( 'latest' => true ) );
if ( !$file ) {
$r['result'] = 'Failure';
$r['errormessage'] = 'File does not exist';
* private: If true, return restricted (deleted) files if the current
* user is allowed to view them. Otherwise, such files will not
* be found. If a User object, use that user instead of the current.
- * bypassCache: If true, do not use the process/persistent cache of File objects
+ * latest: If true, load from the latest available data into File objects
* @return File|bool False on failure
*/
public function findFile( $title, $options = array() ) {
if ( !$title ) {
return false;
}
+ if ( isset( $options['bypassCache'] ) ) {
+ $options['latest'] = $options['bypassCache']; // b/c
+ }
$time = isset( $options['time'] ) ? $options['time'] : false;
- $flags = !empty( $options['bypassCache'] ) ? File::READ_LATEST : 0;
+ $flags = !empty( $options['latest'] ) ? File::READ_LATEST : 0;
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
if ( !$img ) {
* private: If true, return restricted (deleted) files if the current
* user is allowed to view them. Otherwise, such files will not
* be found.
- * bypassCache: If true, do not use the process/persistent cache of File objects
+ * latest: If true, load from the latest available data into File objects
* @return File|bool False if title is not found
*/
function findFile( $title, $options = array() ) {
// MW 1.15 compat
$options = array( 'time' => $options );
}
+ if ( isset( $options['bypassCache'] ) ) {
+ $options['latest'] = $options['bypassCache']; // b/c
+ }
+
if ( !$this->reposInitialised ) {
$this->initialiseRepos();
}
$transformParams = $this->params['transformParams'];
$file = wfLocalFile( $this->title );
+ $file->load( File::READ_LATEST );
if ( $file && $file->exists() ) {
if ( $wgUploadThumbnailRenderMethod === 'jobqueue' ) {
wfDebug( __METHOD__ . ": hitting url {$thumbUrl}\n" );
- $request = MWHttpRequest::factory( $thumbUrl,
+ $request = MWHttpRequest::factory( $thumbUrl,
array( 'method' => 'HEAD', 'followRedirects' => true ),
__METHOD__
);
// Delete an associated image if there is
if ( $nt->getNamespace() == NS_FILE ) {
$file = wfLocalFile( $nt );
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
$file->delete( $reason, false, $user );
}
if ( $restoreFiles && $this->title->getNamespace() == NS_FILE ) {
$img = wfLocalFile( $this->title );
+ $img->load( File::READ_LATEST );
$this->fileStatus = $img->restore( $fileVersions, $unsuppress );
if ( !$this->fileStatus->isOK() ) {
return false;
$warnings = array();
$localFile = $this->getLocalFile();
+ $localFile->load( File::READ_LATEST );
$filename = $localFile->getName();
/**
* @return Status Indicating the whether the upload succeeded.
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
+ $this->getLocalFile()->load( File::READ_LATEST );
$status = $this->getLocalFile()->upload(
$this->mTempPath,
private function checkOverwrite( $user ) {
// First check whether the local file can be overwritten
$file = $this->getLocalFile();
+ $file->load( File::READ_LATEST );
if ( $file->exists() ) {
if ( !self::userCanReUpload( $user, $file ) ) {
return array( 'fileexists-forbidden', $file->getName() );
/* Check shared conflicts: if the local file does not exist, but
* wfFindFile finds a file, it exists in a shared repository.
*/
- $file = wfFindFile( $this->getTitle() );
+ $file = wfFindFile( $this->getTitle(), array( 'latest' => true ) );
if ( $file && !$user->isAllowed( 'reupload-shared' ) ) {
return array( 'fileexists-shared-forbidden', $file->getName() );
}
return false;
}
+ $img->load( File::READ_LATEST );
+
return $user->getId() == $img->getUser( 'id' );
}
return $status;
}
- /**
- * Perform the upload, then remove the temp copy afterward
- * @param string $comment
- * @param string $pageText
- * @param bool $watch
- * @param User $user
- * @return Status
- */
- public function performUpload( $comment, $pageText, $watch, $user ) {
- $rv = parent::performUpload( $comment, $pageText, $watch, $user );
-
- return $rv;
- }
-
/**
* Returns the virtual chunk location:
* @param int $index