From a6e268086bca9dee57673ab38e7700915b6a811b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 11 Sep 2009 23:36:28 +0000 Subject: [PATCH] Forward-port image manipulation disabling hack from wmf-deployment r53386. Turning on $wgUploadMaintenance will disable deletion and undeletion of images; useful when performing maintenance on file servers to ensure that nobody's messing with your data while you work. Note that $wgEnableUploads really should be disabled too or it'll be a bit silly. ;) Could use localization and other polishing. --- includes/DefaultSettings.php | 3 +++ includes/ImagePage.php | 7 +++++++ includes/specials/SpecialUndelete.php | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index dae79e003f..d390da5462 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4222,3 +4222,6 @@ $wgMemoryLimit = "50M"; * Note that this requires JS2 and the script loader. */ $wgUseAJAXCategories = false; + +// to disable image delete/restore temporarily +$wgUploadMaintenance = false; diff --git a/includes/ImagePage.php b/includes/ImagePage.php index d5f603eb5c..40e39c4960 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -720,6 +720,13 @@ EOT * Delete the file, or an earlier version of it */ public function delete() { + global $wgUploadMaintenance; + if( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) { + global $wgOut; + $wgOut->addWikiText('Deletion and restoration of images temporarily disabled during maintenance.' ); + return; + } + $this->loadFile(); if( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) { // Standard article deletion diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index d6f6d74631..7a797737d3 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -646,6 +646,11 @@ class UndeleteForm { } } if( $this->mRestore && $this->mAction == "submit" ) { + global $wgUploadMaintenance; + if( $wgUploadMaintenance && $this->mTargetObj && $this->mTargetObj->getNamespace() == NS_FILE ) { + $wgOut->addWikiText('Deletion and restoration of images temporarily disabled during maintenance.' ); + return; + } return $this->undelete(); } if( $this->mInvert && $this->mAction == "submit" ) { -- 2.20.1