public function testReport()
 {
     $mockMessage = $this->getMockMessage();
     $title = 'Foo';
     $params = array('Baz');
     global $wgOut;
     $wgOut = $this->getMockBuilder('OutputPage')->disableOriginalConstructor()->getMock();
     $wgOut->expects($this->once())->method('showErrorPage')->with($title, $mockMessage, $params);
     $wgOut->expects($this->once())->method('output');
     $e = new ErrorPageError($title, $mockMessage, $params);
     $e->report();
 }
 /**
  * Just like ErrorPageError::report() but additionally set
  * a 400 HTTP status code (bug 33646).
  */
 public function report()
 {
     global $wgOut;
     // bug 33646: a badtitle error page need to return an error code
     // to let mobile browser now that it is not a normal page.
     $wgOut->setStatusCode(400);
     parent::report();
 }
Example #3
0
 /**
  * Redirect to Special:Userlogin if the specified message is compatible. Otherwise,
  * show an error page as usual.
  */
 public function report()
 {
     // If an unsupported message is used, don't try redirecting to Special:Userlogin,
     // since the message may not be compatible.
     if (!in_array($this->msg, LoginHelper::getValidErrorMessages())) {
         parent::report();
     }
     // Message is valid. Redirec to Special:Userlogin
     $context = RequestContext::getMain();
     $output = $context->getOutput();
     $query = $context->getRequest()->getValues();
     // Title will be overridden by returnto
     unset($query['title']);
     // Redirect to Special:Userlogin
     $output->redirect(SpecialPage::getTitleFor('Userlogin')->getFullURL(['returnto' => $context->getTitle()->getFullText(), 'returntoquery' => wfArrayToCgi($query), 'warning' => $this->msg]));
     $output->output();
 }
Example #4
0
 public function __construct(Block $block)
 {
     global $wgLang, $wgRequest;
     $blocker = $block->getBlocker();
     if ($blocker instanceof User) {
         // local user
         $blockerUserpage = $block->getBlocker()->getUserPage();
         $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
     } else {
         // foreign user
         $link = $blocker;
     }
     $reason = $block->mReason;
     if ($reason == '') {
         $reason = wfMsg('blockednoreason');
     }
     /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
      * This could be a username, an IP range, or a single IP. */
     $intended = $block->getTarget();
     parent::__construct('blockedtitle', $block->mAuto ? 'autoblockedtext' : 'blockedtext', array($link, $reason, $wgRequest->getIP(), $block->getByName(), $block->getId(), $wgLang->formatExpiry($block->mExpiry), $intended, $wgLang->timeanddate(wfTimestamp(TS_MW, $block->mTimestamp), true)));
 }
 public function __construct(Block $block)
 {
     // @todo FIXME: Implement a more proper way to get context here.
     $params = $block->getPermissionsError(RequestContext::getMain());
     parent::__construct('blockedtitle', array_shift($params), $params);
 }
Example #6
0
 public function __construct()
 {
     parent::__construct('readonly', 'readonlytext', wfReadOnlyReason() ?: []);
 }
 public function report()
 {
     global $wgOut;
     $wgOut->setStatusCode(429);
     parent::report();
 }
 public function __construct()
 {
     parent::__construct('centralauth-readonly', 'centralauth-readonlytext');
 }
Example #9
0
 /**
  * @param string $reasonMsg A message key containing the reason for the error.
  *        Optional, default: 'exception-nologin-text'
  * @param string $titleMsg A message key to set the page title.
  *        Optional, default: 'exception-nologin'
  * @param array $params Parameters to wfMessage().
  *        Optional, default: array()
  */
 public function __construct($reasonMsg = 'exception-nologin-text', $titleMsg = 'exception-nologin', $params = array())
 {
     parent::__construct($titleMsg, $reasonMsg, $params);
 }
 public function __construct($message)
 {
     parent::__construct('moderation', $message);
 }