r46838 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46837‎ | r46838 | r46839 >
Date:07:52, 5 February 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Avoid E_NOTICE for wikis that give no rights to anonymous users.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1496,7 +1496,7 @@
14971497 }
14981498
14991499 # Shortcut for public wikis, allows skipping quite a bit of code
1500 - if ($wgGroupPermissions['*']['read'])
 1500+ if ( !empty( $wgGroupPermissions['*'] ) )
15011501 return true;
15021502
15031503 if( $wgUser->isAllowed( 'read' ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r46841Fix r46838 per IAlex on Code Reviewwerdna09:07, 5 February 2009

Comments

#Comment by IAlex (talk | contribs)   08:31, 5 February 2009

This give false results, when setting

$wgGroupPermissions['*']['read'] = false;

in LocalSettings.php, anonymous users can still read the wiki.

#Comment by Werdna (talk | contribs)   08:50, 5 February 2009

Have you tested that?

http://php.net/empty

Returns FALSE if var has a non-empty and non-zero value.

The following things are considered to be empty:

  • "" (an empty string)
  • 0 (0 as an integer)
  • "0" (0 as a string)
  • NULL
  • FALSE
  • array() (an empty array)
  • var $var; (a variable declared, but without a value in a class)
#Comment by IAlex (talk | contribs)   09:00, 5 February 2009

Yes I tested it, but imho the problem is that you check empty( $wgGroupPermissions['*'] ) rather than empty( $wgGroupPermissions['*']['read'] ).

#Comment by Werdna (talk | contribs)   09:09, 5 February 2009

*headdesk*

Fixed up in r46841

Status & tagging log