*/
function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null ) {
global $wgContLang;
+
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
// truncate nicely or the DB will do it for us
- // non-nicely (dangling multi-byte chars, non-truncated
- // version in cache).
+ // non-nicely (dangling multi-byte chars, non-truncated version in cache).
$comment = $wgContLang->truncate( $comment, 255 );
$this->lock(); // begin
$status = $this->publish( $srcPath, $flags );
* archive name, or an empty string if it was a new file.
*/
function publishTo( $srcPath, $dstRel, $flags = 0 ) {
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
$this->lock(); // begin
$archiveName = wfTimestamp( TS_MW ) . '!'. $this->getName();
* @return FileRepoStatus object.
*/
function move( $target ) {
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
wfDebugLog( 'imagemove', "Got request to move {$this->name} to " . $target->getText() );
$this->lock(); // begin
* @return FileRepoStatus object.
*/
function delete( $reason, $suppress = false ) {
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
$this->lock(); // begin
$batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
}
$status = $batch->execute();
- if ( $status->ok ) {
+ if ( $status->isOK() ) {
// Update site_stats
$site_stats = $dbw->tableName( 'site_stats' );
$dbw->query( "UPDATE $site_stats SET ss_images=ss_images-1", __METHOD__ );
* @return FileRepoStatus object.
*/
function deleteOld( $archiveName, $reason, $suppress = false ) {
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
$this->lock(); // begin
$batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
$this->unlock(); // done
- if ( $status->ok ) {
+ if ( $status->isOK() ) {
$this->purgeDescription();
$this->purgeHistory();
}
* @return FileRepoStatus
*/
function restore( $versions = array(), $unsuppress = false ) {
+ if ( $this->getRepo()->getReadOnlyReason() !== false ) {
+ return $this->readOnlyFatalStatus();
+ }
+
+ $this->lock(); // begin
+
$batch = new LocalFileRestoreBatch( $this, $unsuppress );
if ( !$versions ) {
$status = $batch->execute();
- if ( !$status->isGood() ) {
- return $status;
+ if ( $status->isGood() ) {
+ $cleanupStatus = $batch->cleanup();
+ $cleanupStatus->successCount = 0;
+ $cleanupStatus->failCount = 0;
+ $status->merge( $cleanupStatus );
}
- $cleanupStatus = $batch->cleanup();
- $cleanupStatus->successCount = 0;
- $cleanupStatus->failCount = 0;
- $status->merge( $cleanupStatus );
+ $this->unlock(); // done
return $status;
}
$dbw = $this->repo->getMasterDB();
$dbw->rollback( __METHOD__ );
}
+
+ /**
+ * @return Status
+ */
+ protected function readOnlyFatalStatus() {
+ return $this->getRepo()->newFatal( 'filereadonlyerror', $this->getName(),
+ $this->getRepo()->getName(), $this->getRepo()->getReadOnlyReason() );
+ }
} // LocalFile class
# ------------------------------------------------------------------------------
$this->status->merge( $status );
}
- if ( !$this->status->ok ) {
+ if ( !$this->status->isOK() ) {
// Critical file deletion error
// Roll back inserts, release lock and abort
// TODO: delete the defunct filearchive rows if we are using a non-transactional DB