User:Subfader/ProtectSource

Description
This Extension blocks access to the source code of pages that are protected against editing. It only applies for users who can't delete pages. This default user right is customizable (see below). Viewing the plain page source is blocked as well as comparing different versions in the history of a page. Still the user can see the history list and view previous page versions in parsed mode (as in preview).

If restriction criteria fit; it disables the following (from all manual or system links and by manual URL parameter access):
 * source view (admins / sysops who are not allowed by the set userright still can edit cos of page protection restriction)
 * comparing diff in history
 * raw access
 * source view of deleted pages ("view / restore" links are suppressed)

It does not remove the (diff) on certain pages links or the [view source] page tab. Instead, the following error message is returned if a non-privileged user tries to access the protected page source: "Sorry, this is a protected page. You do not have the proper permissions to view the source." Links to error messages are not user friendly, but the site-wide conditional clauses could be expensive. If wanted, the [view source] page tab can be hidden (see here).


 * The extension makes no sense without
 * disabled API
 * disabled Special:Export (Disabling it only for protected pages would be nice, atm it's safer to disable it completely manually.)

Warning
This may not be safe against all ways to access the source of a protected page. But the most obvious ones have been blocked.

If you have any other extensions installed that use the MediaWiki::performAction hook it is possible that they will not be processed; therefore, a custom hook called AlternatePerformAction is added to replace MediaWiki::performAction. You will need to change any hook references in other extensions from "MediaWikiPerformAction" to "AlternatePerformAction". To find out if one of your extension may be affected grep "MediaWikiPerformAction" in your extension folder.

Download & Installation
Download and extract it into your extensions folder: Add this to 'LocalSettings.php' in your wiki installation folder.
 * ProtectSource0.1.tar
 * ProtectSource0.1.zip

Configuration
You can customize the user right to which the blocked access applies by using. Example: This would apply to users who are not allowed to move pages.

Authors
The extension was written by Lisa Ridley with little influences by Subfader who now maintains it more or less.

Contribution

 * Please test it for any backdoors to access the source code of protected pages or snippets of it.
 * Please report bugs on the discussion page.
 * Translations can be posted here. Please sign your posts.