Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / exception / BadTitleError.php
index e62f8bd..3f4c213 100644 (file)
  */
 class BadTitleError extends ErrorPageError {
        /**
-        * @param string|Message $msg A message key (default: 'badtitletext')
+        * @param string|Message|MalformedTitleException $msg A message key (default: 'badtitletext'), or
+        *     a MalformedTitleException to figure out things from
         * @param array $params Parameter to wfMessage()
         */
-       public function __construct( $msg = 'badtitletext', $params = array() ) {
-               parent::__construct( 'badtitle', $msg, $params );
+       public function __construct( $msg = 'badtitletext', $params = [] ) {
+               if ( $msg instanceof MalformedTitleException ) {
+                       $errorMessage = $msg->getErrorMessage();
+                       if ( !$errorMessage ) {
+                               parent::__construct( 'badtitle', 'badtitletext', [] );
+                       } else {
+                               $errorMessageParams = $msg->getErrorMessageParameters();
+                               parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
+                       }
+               } else {
+                       parent::__construct( 'badtitle', $msg, $params );
+               }
        }
 
        /**
@@ -47,5 +58,4 @@ class BadTitleError extends ErrorPageError {
                $wgOut->setStatusCode( 400 );
                parent::report();
        }
-
 }