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:

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:

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.