Moved view count from WikiPage to Title; avoids an extra DB query when showing the...
[lhc/web/wiklou.git] / includes / Exception.php
index c5bb056..08a63ee 100644 (file)
@@ -181,6 +181,7 @@ class MWException extends Exception {
 
                        $wgOut->output();
                } else {
+                       header( "Content-Type: text/html; charset=utf-8" );
                        $hookResult = $this->runHooks( get_class( $this ) . "Raw" );
                        if ( $hookResult ) {
                                die( $hookResult );
@@ -276,33 +277,34 @@ class ErrorPageError extends MWException {
  * @ingroup Exception
  */
 class PermissionsError extends ErrorPageError {
-       public $permission;
+       public $permission, $errors;
 
-       function __construct( $permission ) {
+       function __construct( $permission, $errors = array() ) {
                global $wgLang;
 
                $this->permission = $permission;
 
-               $groups = array_map(
-                       array( 'User', 'makeGroupLinkWiki' ),
-                       User::getGroupsWithPermission( $this->permission )
-               );
-
-               if( $groups ) {
-                       parent::__construct(
-                               'badaccess',
-                               'badaccess-groups',
-                               array(
-                                       $wgLang->commaList( $groups ),
-                                       count( $groups )
-                               )
-                       );
-               } else {
-                       parent::__construct(
-                               'badaccess',
-                               'badaccess-group0'
+               if ( !count( $errors ) ) {
+                       $groups = array_map(
+                               array( 'User', 'makeGroupLinkWiki' ),
+                               User::getGroupsWithPermission( $this->permission )
                        );
+
+                       if ( $groups ) {
+                               $errors[] = array( 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) );
+                       } else {
+                               $errors[] = array( 'badaccess-group0' );
+                       }
                }
+
+               $this->errors = $errors;
+       }
+
+       function report() {
+               global $wgOut;
+
+               $wgOut->showPermissionsErrorPage( $this->errors, $this->permission );
+               $wgOut->output();
        }
 }