Page MenuHomePhabricator

Loading a special page fails when the option read is set to false for anonymous users.
Closed, ResolvedPublic

Description

Author: a.steffan

Description:
Hello, there occurs a grave error when I try to open a special page like "Letzte Änderungen" (Recent changes) or "Zufällige Seite" (Random article) and the setting $wgGroupPermissions['*']['read'] is set to false ($wgGroupPermissions['*']['read'] = false;).

The page loading fails and throw following error:

Invalid special page name ""

Backtrace:

#0 /services/www/wwwroot/mscwiki/current/current/includes/Title.php(1307): SpecialPage::getTitleFor(false)
#1 /services/www/wwwroot/mscwiki/current/current/includes/Wiki.php(133): Title->userCanRead()
#2 /services/www/wwwroot/mscwiki/current/current/includes/Wiki.php(43): MediaWiki->preliminaryChecks(Object(Title), Object(StubObject), Object(WebRequest))
#3 /services/www/wwwroot/mscwiki/current/current/index.php(89): MediaWiki->initialize(Object(Title), Object(StubObject), Object(User), Object(WebRequest))
#4 {main}

To get the mediawiki running I had to modify the Title.php:

I modified the includes/Title.php
I added this line
$name = str_replace(" ",'_',$name);
above this one.
list( $name, /* $subpage */) = SpecialPage::resolveAliasWithSubpage( $name );


Version: 1.11.x
Severity: critical
OS: Linux

Details

Reference
bz11668

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 10:00 PM
bzimport set Reference to bz11668.
bzimport added a subscriber: Unknown Object (MLST).

Were you logged in when this happened? is Special:Recentchanges in $wgWhitelistRead?

a.steffan wrote:

I didn't logged in, I tried to open the page as an anonymous user. $wgWhitelistRead is empty.

The target is to prevent the access for anonymous users.

(In reply to comment #2)

I didn't logged in, I tried to open the page as an anonymous user.
$wgWhitelistRead is empty.

The target is to prevent the access for anonymous users.

You will at the very least need to have [[Special:Userlogin]] in your whitelist, or you won't be able to log in. Ever. Still, this behavior is weird and shouldn't happen.

a.steffan wrote:

In version 1.11.0 you don't need to define the userlogin page in the whitelist-array. Have a look at the Title.php, line 1274 and further:

/**

  • Always grant access to the login page.
  • Even anons need to be able to log in.

*/
if( $this->isSpecial( 'Userlogin' ) || $this->isSpecial( 'Resetpass' ) ) {
return true;
}

Ugh, this whole thing seems a mess...

This works:
$wgWhitelistRead = array('Spezial:Letzte Änderungen');

This causes the fatal error:
$wgWhitelistRead = array('Spezial:Letzte_Änderungen');

Errrrrp? :P

Normalizing ' ' to '_' in SpecialPage::resolveAlias() seems to make both cases work, but I'm a little vague on what's going on in the first place... or how this makes a difference in the described behavior at all. :) The whitelist code is pretty darn awful.

bugzilla wrote:

I seem to have the same problem in mediawiki-1.11.0.

If I put "$wgGroupPermissions['*']['read'] = false;" in LocalSettings.php and then try to view any of the special pages, I get the following error message:

Invalid special page name ""

Backtrace:

#0 /www/(hidden)/html/includes/Title.php(1305): SpecialPage::getTitleFor(false)
#1 /www/(hidden)/html/includes/Wiki.php(133): Title->userCanRead()
#2 /www/(hidden)/html/includes/Wiki.php(43): MediaWiki->preliminaryChecks(Object(Title), Object(StubObject), Object(WebRequest))
#3 /www/(hidden)/html/index.php(89): MediaWiki->initialize(Object(Title), Object(StubObject), Object(User), Object(WebRequest))
#4 {main}

I tried to do the same as you said, placing the following line in includes/Title.php
$name = str_replace(" ",'_',$name);
like this:

$name = $this->getText();
$name = str_replace(" ",'_',$name); // this is the new line (line number 1304).
list( $name, /* $subpage */) = SpecialPage::resolveAliasWithSubpage( $name );

It seem to work fine now. Thanks!

I hope they include a fix this in the new version;)

Current trunk (as of r28609) doesn't crash, but it does fail to recognize the version with underscore. (That is, you get a permission failure instead of the expected special page.)

  • Bug 12418 has been marked as a duplicate of this bug. ***