}
$this->fileExists = true;
- $this->maybeUpgradeRow();
}
/**
/**
* Upgrade a row if it needs it
*/
- function maybeUpgradeRow() {
+ protected function maybeUpgradeRow() {
global $wgUpdateCompatibleMetadata;
if ( wfReadOnly() || $this->upgrading ) {
/** isVisible inherited */
/**
+ * Checks if this file exists in its parent repo, as referenced by its
+ * virtual URL.
+ *
* @return bool
*/
function isMissing() {
if ( $this->missing === null ) {
- list( $fileExists ) = $this->repo->fileExists( $this->getVirtualUrl() );
+ $fileExists = $this->repo->fileExists( $this->getVirtualUrl() );
$this->missing = !$fileExists;
}
*/
function purgeCache( $options = [] ) {
// Refresh metadata cache
+ $this->maybeUpgradeRow();
$this->purgeMetadataCache();
// Delete thumbnails
* (This doesn't check $user's permissions.)
* @param bool $createNullRevision Set to false to avoid creation of a null revision on file
* upload, see T193621
+ * @param bool $revert If this file upload is a revert
* @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $src, $comment, $pageText, $flags = 0, $props = false,
$timestamp = false, $user = null, $tags = [],
- $createNullRevision = true
+ $createNullRevision = true, $revert = false
) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
$timestamp,
$user,
$tags,
- $createNullRevision
+ $createNullRevision,
+ $revert
);
if ( !$uploadStatus->isOK() ) {
if ( $uploadStatus->hasMessage( 'filenotfound' ) ) {
* @param string[] $tags
* @param bool $createNullRevision Set to false to avoid creation of a null revision on file
* upload, see T193621
+ * @param bool $revert If this file upload is a revert
* @return Status
*/
function recordUpload2(
$oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [],
- $createNullRevision = true
+ $createNullRevision = true, $revert = false
) {
global $wgActorTableSchemaMigrationStage;
$wikiPage = new WikiFilePage( $descTitle );
$wikiPage->setFile( $this );
+ // Determine log action. If reupload is done by reverting, use a special log_action.
+ if ( $revert === true ) {
+ $logAction = 'revert';
+ } elseif ( $reupload === true ) {
+ $logAction = 'overwrite';
+ } else {
+ $logAction = 'upload';
+ }
// Add the log entry...
- $logEntry = new ManualLogEntry( 'upload', $reupload ? 'overwrite' : 'upload' );
+ $logEntry = new ManualLogEntry( 'upload', $logAction );
$logEntry->setTimestamp( $this->timestamp );
$logEntry->setPerformer( $user );
$logEntry->setComment( $comment );
$this->lock();
- $archiveName = wfTimestamp( TS_MW ) . '!' . $this->getName();
- $archiveRel = $this->getArchiveRel( $archiveName );
+ if ( $this->isOld() ) {
+ $archiveRel = $dstRel;
+ $archiveName = basename( $archiveRel );
+ } else {
+ $archiveName = wfTimestamp( TS_MW ) . '!' . $this->getName();
+ $archiveRel = $this->getArchiveRel( $archiveName );
+ }
if ( $repo->hasSha1Storage() ) {
$sha1 = FileRepo::isVirtualUrl( $srcPath )