Forward-port image manipulation disabling hack from wmf-deployment r53386.
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 11 Sep 2009 23:36:28 +0000 (23:36 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 11 Sep 2009 23:36:28 +0000 (23:36 +0000)
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
includes/ImagePage.php
includes/specials/SpecialUndelete.php

index dae79e0..d390da5 100644 (file)
@@ -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;
index d5f603e..40e39c4 100644 (file)
@@ -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
index d6f6d74..7a79773 100644 (file)
@@ -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" ) {