From 8ec90547df35a1f3386d8b12f3c22d6c3d8da33f Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Mon, 14 Jan 2019 14:43:29 +0100 Subject: [PATCH] Soft deprecate QuickTemplate::msgWiki() 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 | 2 ++ includes/skins/BaseTemplate.php | 6 +++++- includes/skins/QuickTemplate.php | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 436d1a31b5..5c4832a750 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -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 diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php index a71daa0980..02247bd0e0 100644 --- a/includes/skins/BaseTemplate.php +++ b/includes/skins/BaseTemplate.php @@ -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(); } diff --git a/includes/skins/QuickTemplate.php b/includes/skins/QuickTemplate.php index 06d0f7b5e8..1e688ebf06 100644 --- a/includes/skins/QuickTemplate.php +++ b/includes/skins/QuickTemplate.php @@ -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(); -- 2.20.1