r40008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40007‎ | r40008 | r40009 >
Date:06:25, 26 August 2008
Author:nad
Status:old
Tags:
Comment:
Bug fix: anonymous users getting denied access regardless of page protection
Modified paths:
  • /trunk/extensions/SimpleSecurity/SimpleSecurity.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SimpleSecurity/SimpleSecurity.php
@@ -18,7 +18,7 @@
1919
2020 if (!defined('MEDIAWIKI')) die('Not an entry point.');
2121
22 -define('SIMPLESECURITY_VERSION', '4.2.1, 2008-08-26');
 22+define('SIMPLESECURITY_VERSION', '4.2.2, 2008-08-26');
2323
2424 # Global security settings
2525 $wgSecurityMagicIf = "ifusercan"; # the name for doing a permission-based conditional
@@ -142,9 +142,9 @@
143143 */
144144 public function onOutputPageBeforeHTML(&$out, &$text) {
145145 global $wgTitle, $wgUser;
146 -
 146+
147147 # Render security info if any
148 - if (count($this->info)) {
 148+ if (is_object($wgTitle) && $wgTitle->exists() && count($this->info['LS'])+count($this->info['PR'])) {
149149
150150 $rights = $wgUser->getRights();
151151 $wgTitle->getRestrictions(false);
@@ -216,8 +216,15 @@
217217 elseif ($wgRequest->getVal('oldtitle')) $title = Title::newFromText($wgRequest->getVal('oldtitle'));
218218 } else $title = $wgTitle;
219219 if (!is_object($title)) return true; # If still no usable title bail
220 -
221 - # Process $wgPageRestrictions
 220+
 221+ # Validate the title and then put anonymous read right back (see constructor above for details)
 222+ $valid = $this->validateTitle($user, $title, $error);
 223+ if ($this->default_read) {
 224+ $wgGroupPermissions['*']['read'] = true;
 225+ $rights[] = 'read';
 226+ }
 227+
 228+ # Filter rights by processing $wgPageRestrictions
222229 # - also adds LS (rules from local settings) items to info array
223230 $this->pageRestrictions($rights, $groups, $title);
224231
@@ -230,11 +237,9 @@
231238 }
232239
233240 # If title is not readable by user, remove the read and move rights
234 - if (!in_array('sysop', $groups)) {
235 - if (!$this->validateTitle($user, $title, $error)) {
236 - foreach ($rights as $i => $right) if ($right === 'read' || $right === 'move') unset($rights[$i]);
237 - #$this->info['CR'] = array('read', '', '');
238 - } elseif ($this->default_read) $wgGroupPermissions['*']['read'] = $this->default_read; # see constructor
 241+ if (!in_array('sysop', $groups) && !$valid) {
 242+ foreach ($rights as $i => $right) if ($right === 'read' || $right === 'move') unset($rights[$i]);
 243+ #$this->info['CR'] = array('read', '', '');
239244 }
240245
241246 return true;
@@ -405,7 +410,7 @@
406411 if ($wgSecurityUseDBHook) {
407412 global $wgDBtype, $wgLoadBalancer;
408413
409 - # Swicth DB type to new class
 414+ # Switch DB type to new class
410415 $wgDBtype = ucfirst($wgDBtype);
411416 $oldType = $wgDBtype;
412417 $wgDBtype = "Secure$wgDBtype";

Status & tagging log