Extension:FlaggedRevs/Restricting unapproved revisions

This page describes how to only give read access to the stable versions of articles to anonymous users for MediaWiki 1.17+.

Basic idea
This approach works as follows: The details to do this are described in the next few sections.
 * (i) Make all pages unreadable and uneditable by non-users (that is, readable only for users)
 * (ii) But make the stable version of pages an exception in that they are readable to non-users

Making the site readable only by users
See Manual:Preventing_access and Manual:Preventing_access

Add these lines to your LocalSettings.php file:

Adding stable version as exemption for non-users
Add the following to LocalSettings.php:

is an array of user groups. Setting it to  will let all visitors be able to see the stable version of pages. Setting it to  will make the stable versions visible to users in the group 'supergroup'.

You also don't have to use these global variables and can just hard code whatever is needed into the efFlaggedRevsHooks_userCanView function mentioned below.

MediaWiki >= 1.19
Add the following code to LocalSettings.php (or an appropriate custom start-up config file): ...and then define the following function:

MediaWiki <= 1.18
Add the following code to localsettings.php (or an appropriate custom start-up config file): ...and then define the following function:

Caveats

 * This does not work well with img_auth.php, as non-user viewers will not be able to see images. You will probably just want to leave images public but under hashed directories to make them harder to find. This is acceptable if there are no private files and the main concern is just not to release unverified content.
 * The search index is still based on the current version of pages, but only results for pages with stable versions are displayed at Special:Search. If a stable version is out of date then unreviewed content for that page becomes theoretically discoverable by brute force searching.
 * This will probably be useless without having.
 * Make sure that  is set properly. You will at least want something like  . You may also want visible directory or category pages. Otherwise, the wiki will be hard to browse for readers.
 * You will probably want to edit MediaWiki:loginreqpagetext to make it more detailed. It will come up in various situations and thus should explain the approval system setup.

Whitelisting non-reviewed pages per namespace
Instead of using the  setting to whitelist particular non-reviewed pages that should remain readable, one can whitelist selected namespaces. With this approach, one can for example whitelist: To do the latter of these, one can modify the code for LocalSettings.php provided further above (either version), adding the below immediately above the line with the "See if there is a stable version. [...]" comment: The use of the  array in the above code can be replaced with any other array of namespace entries. In this way, one can freely configure which namespaces to whitelist.
 * Only  – the bare minimum for usability with this approach.
 * All namespaces for which FlaggedRevs is not enabled.

The above approach can also be combined with the use of the  setting – this allows whitelisting only particular unreviewed pages in certain namespaces, while also fully whitelisting other namespaces.

By whitelisting pages inside a function, it is also possible to check pages according to other criteria than their namespaces, if needed for a particular wiki. More advanced checks might use other data provided by MediaWiki, and/or by other MediaWiki extensions.