Soft deprecate QuickTemplate::msgWiki()
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 14 Jan 2019 13:43:29 +0000 (14:43 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 1 Feb 2019 21:25:18 +0000 (13:25 -0800)
This method just should not exist. It does have a bad name that does not
say much about what it does and how it is supposed to be used. And it
does horrible things: it accesses the global $wgOut, which currently
results in test failures, see
https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php70-docker/15200/console

Note how it was marked as @private, which is honorable, but doesn't
work for multiple reasons. First, an overload exists in the BaseTemplate
subclass. Second, calls from external code exist. Third, if it would be
really private, it could as well be deleted, because there is no private
caller.

Luckily the number of callers is extremely close to zero, see
https://codesearch.wmflabs.org/search/?q=>msgWiki%5C(

A patch for the Collection extension already exists.

Change-Id: I8d2c14f10fbf314735d1aa82bdc8edfb4fa9a0dd

RELEASE-NOTES-1.33
includes/skins/BaseTemplate.php
includes/skins/QuickTemplate.php

index 436d1a3..5c4832a 100644 (file)
@@ -220,6 +220,8 @@ because of Phabricator reports.
 * (T209699) The jquery.async module has been deprecated. JavaScript code that
   needs asynchronous behaviour should use Promises.
 * Password::equals() is deprecated, use verify().
+* BaseTemplate::msgWiki() and QuickTemplate::msgWiki() will be removed. Use
+  other means to fetch a properly escaped message string or Message object.
 
 === Other changes in 1.33 ===
 * (T208871) The hard-coded Google search form on the database error page was
index a71daa0..02247bd 100644 (file)
@@ -46,7 +46,7 @@ abstract class BaseTemplate extends QuickTemplate {
        /**
         * @param string $str
         * @warning You should never use this method. I18n messages should be escaped
-        * @deprecated 1.32 Use ->msg() or ->msgWiki() instead.
+        * @deprecated 1.32 Use ->msg() or ->getMsg() instead.
         * @suppress SecurityCheck-XSS
         * @return-taint exec_html
         */
@@ -55,7 +55,11 @@ abstract class BaseTemplate extends QuickTemplate {
                echo $this->getMsg( $str )->text();
        }
 
+       /**
+        * @deprecated since 1.33 Use ->msg() or ->getMsg() instead.
+        */
        function msgWiki( $str ) {
+               // TODO: Add wfDeprecated( __METHOD__, '1.33' ) after 1.33 got released
                echo $this->getMsg( $str )->parseAsBlock();
        }
 
index 06d0f7b..1e688eb 100644 (file)
@@ -129,7 +129,7 @@ abstract class QuickTemplate {
         * @private
         * @param string $msgKey
         * @warning You should never use this method. I18n messages should be escaped
-        * @deprecated 1.32 Use ->msg() or ->msgWiki() instead.
+        * @deprecated 1.32 Use ->msg() instead.
         * @suppress SecurityCheck-XSS
         * @return-taint exec_html
         */
@@ -140,10 +140,11 @@ abstract class QuickTemplate {
 
        /**
         * An ugly, ugly hack.
-        * @private
+        * @deprecated since 1.33 Use ->msg() instead.
         * @param string $msgKey
         */
        function msgWiki( $msgKey ) {
+               // TODO: Add wfDeprecated( __METHOD__, '1.33' ) after 1.33 got released
                global $wgOut;
 
                $text = wfMessage( $msgKey )->plain();