Umherirrender has uploaded a new change for review.

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

Change subject: Replace wfMsgReplaceArgs by RawMessage
......................................................................

Replace wfMsgReplaceArgs by RawMessage

The replace of $n params can also be done using the Message class. In
case there are no message keys, the RawMessage class is used.

Deprecated wfMsgReplaceArgs, but added no warning, because it is used in
some extensions and from deprecated functions

Change-Id: I62091b09e4490e59ed7258566e0ddf2f8ee799d2
---
M includes/GlobalFunctions.php
M includes/api/ApiBase.php
M includes/api/ApiMain.php
M includes/db/DatabaseError.php
M includes/exception/MWException.php
M includes/page/WikiPage.php
6 files changed, 18 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/13/163613/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 3306acd..a2160fb 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1602,6 +1602,7 @@
  * @param string $message
  * @param array $args
  * @return string
+ * @deprecated since 1.25 Use the RawMessage class
  * @private
  */
 function wfMsgReplaceArgs( $message, $args ) {
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 7bc3f71..c80d903 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -1791,9 +1791,11 @@
                }
 
                if ( isset( self::$messageMap[$key] ) ) {
+                       $codeMsg = new RawMessage( 
self::$messageMap[$key]['code'] );
+                       $infoMsg = new RawMessage( 
self::$messageMap[$key]['info'] );
                        return array(
-                               'code' => wfMsgReplaceArgs( 
self::$messageMap[$key]['code'], $error ),
-                               'info' => wfMsgReplaceArgs( 
self::$messageMap[$key]['info'], $error )
+                               'code' => $codeMsg->params( $error )->text(),
+                               'info' => $infoMsg->params( $error )->text()
                        );
                }
 
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index bd20b14..d5c1c47 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1306,7 +1306,8 @@
                $msg .= "\n$astriks Permissions $astriks\n\n";
                foreach ( self::$mRights as $right => $rightMsg ) {
                        $groups = User::getGroupsWithPermission( $right );
-                       $msg .= "* " . $right . " *\n  " . wfMsgReplaceArgs( 
$rightMsg['msg'], $rightMsg['params'] ) .
+                       $rightRawMsg = new RawMessage( $rightMsg['msg'] );
+                       $msg .= "* " . $right . " *\n  " . 
$rightRawMsg->params( $rightMsg['params'] )->text() .
                                "\nGranted to:\n  " . str_replace( '*', 'all', 
implode( ', ', $groups ) ) . "\n\n";
                }
 
diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php
index 2dfec41..f48458a 100644
--- a/includes/db/DatabaseError.php
+++ b/includes/db/DatabaseError.php
@@ -136,10 +136,12 @@
                $args = array_slice( func_get_args(), 2 );
 
                if ( $this->useMessageCache() ) {
-                       return wfMessage( $key, $args )->useDatabase( false 
)->text();
+                       $msg = wfMessage( $key )->useDatabase( false );
                } else {
-                       return wfMsgReplaceArgs( $fallback, $args );
+                       $msg = new RawMessage( $fallback );
                }
+
+               return $msg->params( $args )->text();
        }
 
        /**
diff --git a/includes/exception/MWException.php 
b/includes/exception/MWException.php
index 074128f..0528d69 100644
--- a/includes/exception/MWException.php
+++ b/includes/exception/MWException.php
@@ -117,10 +117,12 @@
                $args = array_slice( func_get_args(), 2 );
 
                if ( $this->useMessageCache() ) {
-                       return wfMessage( $key, $args )->text();
+                       $msg = wfMessage( $key );
                } else {
-                       return wfMsgReplaceArgs( $fallback, $args );
+                       $msg = new RawMessage( $fallback );
                }
+
+               return $msg->params( $args )->text();
        }
 
        /**
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 9ade16e..f27c27a 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -3090,11 +3090,10 @@
                        $wgContLang->timeanddate( wfTimestamp( TS_MW, 
$s->rev_timestamp ) ),
                        $current->getId(), $wgContLang->timeanddate( 
$current->getTimestamp() )
                );
-               if ( $summary instanceof Message ) {
-                       $summary = $summary->params( $args 
)->inContentLanguage()->text();
-               } else {
-                       $summary = wfMsgReplaceArgs( $summary, $args );
+               if ( !$summary instanceof Message ) {
+                       $summary = new RawMessage( $summary );
                }
+               $summary = $summary->params( $args 
)->inContentLanguage()->text();
 
                // Trim spaces on user supplied text
                $summary = trim( $summary );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62091b09e4490e59ed7258566e0ddf2f8ee799d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to