How to disable temporarily the deletion and restoration of uploaded files in MediaWiki

If for whatever reason you need to disable the options for deleting and restoring uploaded files in MediaWiki, there's a option with which you can do that. The option for doing that is $wgUploadMaintenance.

Note that only users who belong to a user group with the delete and undelete permissions are allowed to delete and restore files. And so it's also possible to disable the options for deleting and restoring files by removing these permissions from the group(s) that have them. By default, only the sysop/admin group has them. However, doing this will also make it impossible for these users to delete and restore pages.

So in case you need to disable the functions only for deleting and undeleting files, you can do this by adding the option $wgUploadMaintenance to the LocalSettings.php file and enabling it. The option is intended for temporarily disabling the deletion of files, but you can keep it enabled for as long as you need. To do this add the following at the end of LocalSettings.php:

$wgUploadMaintenance = true;

This will disable the options for deleting and restoring uploaded files for all users who have the rights to perform these actions. Note that the buttons on the frontend for deleting and restoring files will not be removed, but when a customer clicks on them a page will be shown informing them the function is temporarily disabled.

Keep in mind that users will still be able to upload and reupload/overwrite files.

To enable the deletion and restoration of files again either delete the line from LocalSettings.php or set it to false.

If you haven't edited the LocalSettings.php file, you can find it in the root MediaWiki folder on your MediaWiki hosting account. Assuming the application is installed directly in the public_html directory on the account (making the frontend accessible at, then the path to the file in relation to that directory will be public_html/LocalSettings.php. One way for HostKnox customers to edit files is with the file manager of the Pixie control panel. Another way is to download the file on your local computer, edit it with a text editor (e.g. Notepad ++) and upload it back replacing the old file.

Other articles in our knowledge base related to file uploads and images:

Was this answer helpful?

 Print this Article

Also Read