'TitleReadWhitelist': called at the end of read permissions checks, just before
adding the default error message if nothing allows the user to read the page.
- Return false will prevent core from adding its error message, but you need
- to removed extensions' error messages from $errors yourself.
+ If a handler wants a title to *not* be whitelisted, it should also return false.
$title: Title object being checked against
$user: Current user object
-&$errors: errors
+&$whitelisted: Boolean value of whether this title is whitelisted
'UndeleteForm::showHistory': called in UndeleteForm::showHistory, after a
PageArchive object has been created but before any further processing is done.
*
* @param $event String: event name
* @param $args Array: parameters passed to hook functions
- * @return Boolean
+ * @return Boolean True if no handler aborted the hook
*/
function wfRunHooks( $event, $args = array() ) {
return Hooks::run( $event, $args );
*
* @param $event String: event name
* @param $args Array: parameters passed to hook functions
- * @return Boolean
+ * @return Boolean True if no handler aborted the hook
*/
public static function run( $event, $args = array() ) {
global $wgHooks;
* @return Array list of errors
*/
private function checkReadPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
- global $wgWhitelistRead;
+ global $wgWhitelistRead, $wgGroupPermissions, $wgRevokePermissions;;
static $useShortcut = null;
# Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below
if ( is_null( $useShortcut ) ) {
- global $wgGroupPermissions, $wgRevokePermissions;
$useShortcut = true;
if ( empty( $wgGroupPermissions['*']['read'] ) ) {
# Not a public wiki, so no shortcut
}
$whitelisted = false;
-
if ( $useShortcut ) {
# Shortcut for public wikis, allows skipping quite a bit of code
$whitelisted = true;
}
}
- # If the user is allowed to read tge page; don't call the hook
- if ( $whitelisted && !count( $errors ) ) {
- return array();
- } elseif ( wfRunHooks( 'TitleReadWhitelist', array( $this, $user, &$errors ) ) && !$whitelisted ) {
- $errors[] = $this->missingPermissionError( $action, $short );
+ if ( !$whitelisted ) {
+ # If the title is not whitelisted, give extensions a chance to do so...
+ wfRunHooks( 'TitleReadWhitelist', array( $this, $user, &$whitelisted ) );
+ if ( !$whitelisted ) {
+ $errors[] = $this->missingPermissionError( $action, $short );
+ }
}
return $errors;