Topic on Project:Support desk

87.148.88.60 (talkcontribs)

Hello, i recently upgraded from 1.17.0 to 1.27.0 and now experience issues with a custom extension hook i wrote for 1.17 using the userCan hook.

Basicly i want to restrict read access overall (using $wgGroupPermissions['*']['read'] = false;) but (re-)grant it for anonymous users based on categorys. The extension hooks in the userCan hook and lists the categorys of the article. If one of the category names match a regular expression defined in LocalSettings.php, read access should be granted.

The issue seems not to be directly code related as debug output reveals, that the userCan is called correctly and the extension also returns the right result in the $result variable. Mediawiki 1.20.0 just seems to ignore the "true" result in the userCan hook: the login prompt is shown.


My LocalSettings.php looks like this: $wgGroupPermissions['*']['read'] = false; ... $wgWhitelistRead = array(some_static_pagenames); ... require_once("$IP/extensions/CategoryWhitelist.php"); $wgCategoryWhitelist = array('public', 'Bar.*'); //any article in category "public" or in a category starting with "Bar"


The Extension code is here: http://beni.hallinger.org/caving/CategoryWhitelist.php.txt


What am i doing wrong?

87.148.88.60 (talkcontribs)

Hello, i cant say why this does not work. An alternative simple approach would involve some programming: - LocalSettings.php restricts read access generally, - The whitelist variable is enhanced with article names from a file -this very file is generated using a simple handwritten bot

Thi would however only work for smaller wikis due to API constraints.

Reply to "Hook:userCan (read)"