Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179597

Change subject: Add context to HTMLForm::formatErrors
......................................................................

Add context to HTMLForm::formatErrors

Also call the method always static

Avoid:
[GlobalTitleFail] MessageCache::parse called by
Message::toString/Message::parseText/MessageCache::parse with no title
set

Change-Id: Ic91e715177c0a4578825640a31ec68ecba3176e0
---
M includes/htmlform/HTMLForm.php
M includes/specials/SpecialBlock.php
2 files changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/179597/1

diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 62345b8..58a2ee8 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -997,7 +997,7 @@
                                $errorstr = $this->getOutput()->parse( 
$errors->getWikiText() );
                        }
                } elseif ( is_array( $errors ) ) {
-                       $errorstr = $this->formatErrors( $errors );
+                       $errorstr = self::formatErrors( $errors, 
$this->getContext() );
                } else {
                        $errorstr = $errors;
                }
@@ -1011,11 +1011,15 @@
         * Format a stack of error messages into a single HTML string
         *
         * @param array $errors Array of message keys/values
-        *
+        * @param IContextSource|null $context
         * @return string HTML, a "<ul>" list of errors
         */
-       public static function formatErrors( $errors ) {
+       public static function formatErrors( $errors, IContextSource $context = 
null ) {
                $errorstr = '';
+
+               if ( $context === null ) {
+                       $context = RequestContext::getMainAndWarn( __METHOD__ );
+               }
 
                foreach ( $errors as $error ) {
                        if ( is_array( $error ) ) {
@@ -1028,7 +1032,7 @@
                        $errorstr .= Html::rawElement(
                                'li',
                                array(),
-                               wfMessage( $msg, $error )->parse()
+                               $context->msg( $msg, $error )->parse()
                        );
                }
 
diff --git a/includes/specials/SpecialBlock.php 
b/includes/specials/SpecialBlock.php
index 14d97eb..c5e7db2 100644
--- a/includes/specials/SpecialBlock.php
+++ b/includes/specials/SpecialBlock.php
@@ -105,7 +105,7 @@
 
                # Don't need to do anything if the form has been posted
                if ( !$this->getRequest()->wasPosted() && $this->preErrors ) {
-                       $s = HTMLForm::formatErrors( $this->preErrors );
+                       $s = HTMLForm::formatErrors( $this->preErrors, 
$this->getContext() );
                        if ( $s ) {
                                $form->addHeaderText( Html::rawElement(
                                        'div',

-- 
To view, visit https://gerrit.wikimedia.org/r/179597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic91e715177c0a4578825640a31ec68ecba3176e0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to