r94274 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94273‎ | r94274 | r94275 >
Date:19:32, 11 August 2011
Author:mah
Status:ok
Tags:
Comment:
w/s
Modified paths:
  • /trunk/extensions/Lockdown/Lockdown.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Lockdown/Lockdown.php
@@ -11,8 +11,8 @@
1212 */
1313
1414 /*
15 -* WARNING: you can use this extension to deny read access to some namespaces. Keep in mind that this
16 -* may be circumvented in several ways. This extension doesn't try to
 15+* WARNING: you can use this extension to deny read access to some namespaces. Keep in mind that this
 16+* may be circumvented in several ways. This extension doesn't try to
1717 * plug such holes. Also note that pages that are not readable will still be shown in listings,
1818 * such as the search page, categories, etc.
1919 *
@@ -20,15 +20,15 @@
2121 * - transcluding as template (can't really be fixed without disabling inclusion for specific namespaces;
2222 * that could be done by adding a hook to Parser::fetchTemplate)
2323 * - Special:export (easily fixed using $wgSpecialPageLockdown)
24 -* - the search page may find text and show excerpts from hidden pages (should be fixed from MediaWiki 1.16).
25 -* Some search messages may reveal the page existance by producing links to it (MediaWiki:searchsubtitle,
 24+* - the search page may find text and show excerpts from hidden pages (should be fixed from MediaWiki 1.16).
 25+* Some search messages may reveal the page existance by producing links to it (MediaWiki:searchsubtitle,
2626 * MediaWiki:noexactmatch, MediaWiki:searchmenu-exists, MediaWiki:searchmenu-new...).
2727 * - supplying oldid=<revisionfromhiddenpage> may work in some versions of mediawiki. Same with diff, etc.
2828 *
2929 * NOTE: you cannot GRANT access to things forbidden by $wgGroupPermissions. You can only DENY access
3030 * granted there.
3131 */
32 -
 32+
3333 if ( !defined( 'MEDIAWIKI' ) ) {
3434 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
3535 die( 1 );
@@ -36,8 +36,8 @@
3737
3838 $wgExtensionCredits['other'][] = array(
3939 'path' => __FILE__,
40 - 'name' => 'Lockdown',
41 - 'author' => array( 'Daniel Kinzler', 'Platonides'),
 40+ 'name' => 'Lockdown',
 41+ 'author' => array( 'Daniel Kinzler', 'Platonides'),
4242 'url' => 'http://mediawiki.org/wiki/Extension:Lockdown',
4343 'descriptionmsg' => 'lockdown-desc',
4444 );
@@ -153,12 +153,12 @@
154154
155155 function lockdownSearchableNamespaces($arr) {
156156 global $wgUser, $wgNamespacePermissionLockdown;
157 -
 157+
158158 //don't continue if $wgUser's name and id are both null (bug 28842)
159159 if ( $wgUser->getId() === null && $wgUser->getName() === null ) {
160160 return true;
161161 }
162 -
 162+
163163 $ugroups = $wgUser->getEffectiveGroups();
164164
165165 foreach ( $arr as $ns => $name ) {
@@ -169,11 +169,11 @@
170170 if ( $groups === null ) {
171171 $groups = @$wgNamespacePermissionLockdown[$ns]['*'];
172172 }
173 -
 173+
174174 if ( $groups === null ) {
175175 continue;
176176 }
177 -
 177+
178178 if ( ( count( $groups ) == 0 ) || !array_intersect( $ugroups, $groups ) ) {
179179 unset( $arr[$ns] );
180180 }
@@ -185,7 +185,7 @@
186186 if ( is_object($title) ) {
187187 global $wgUser, $wgNamespacePermissionLockdown;
188188 $ugroups = $wgUser->getEffectiveGroups();
189 -
 189+
190190 $groups = @$wgNamespacePermissionLockdown[$title->getNamespace()]['read'];
191191 if ( $groups === null ) {
192192 $groups = @$wgNamespacePermissionLockdown['*']['read'];
@@ -193,17 +193,17 @@
194194 if ( $groups === null ) {
195195 $groups = @$wgNamespacePermissionLockdown[$title->getNamespace()]['*'];
196196 }
197 -
 197+
198198 if ( $groups === null ) {
199199 return false;
200200 }
201 -
 201+
202202 if ( ( count( $groups ) == 0 ) || !array_intersect($ugroups, $groups) ) {
203203 $title = null;
204204 return false;
205 - }
 205+ }
206206 }
207 - return true;
 207+ return true;
208208 }
209209
210210 #Stop a Go search for a hidden title to send you to the login required page. Will show a no such page message instead.
@@ -218,7 +218,7 @@
219219 $searchEngine->namespaces = array_keys( SearchEngine::searchableNamespaces() ); #Use the namespaces... filtered
220220 return true;
221221 }
222 -
 222+
223223 $ugroups = $wgUser->getEffectiveGroups();
224224
225225 foreach ( $searchEngine->namespaces as $key => $ns ) {
@@ -229,16 +229,16 @@
230230 if ( $groups === null ) {
231231 $groups = @$wgNamespacePermissionLockdown[$ns]['*'];
232232 }
233 -
 233+
234234 if ( $groups === null ) {
235235 continue;
236236 }
237 -
 237+
238238 if ( ( count( $groups ) == 0 ) || !array_intersect( $ugroups, $groups ) ) {
239239 unset( $searchEngine->namespaces[$key] );
240240 }
241241 }
242 -
 242+
243243 if ( count( $searchEngine->namespaces ) == 0 ) {
244244 $searchEngine->namespaces = array_keys( SearchEngine::searchableNamespaces() );
245245 }

Status & tagging log