summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2021-12-21 08:11:12 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2021-12-21 08:11:12 +0000
commite96c43e5d0592d14a07d7b765ee19dd4cdc72dec (patch)
tree0dba9f1bc894ae2a4ca8e2f520188c9e865965e0
parent8a5d31745dba569c5ec7bb27ec211602b7a8a927 (diff)
parent35849a3f0d6295cee1569f4e568778f451e5be76 (diff)
Merge "Hard deprecate QuickTemplate template key"
-rw-r--r--RELEASE-NOTES-1.382
-rw-r--r--includes/skins/QuickTemplate.php33
-rw-r--r--includes/skins/SkinTemplate.php4
3 files changed, 38 insertions, 1 deletions
diff --git a/RELEASE-NOTES-1.38 b/RELEASE-NOTES-1.38
index 2636c579d0df..cec7043219c4 100644
--- a/RELEASE-NOTES-1.38
+++ b/RELEASE-NOTES-1.38
@@ -295,6 +295,8 @@ because of Phabricator reports.
should be used instead.
- SkinTemplate::getPersonalToolsList(), deprecated since 1.35, now emits
deprecation warnings.
+* Usage of several template data keys in QuickTemplate are now deprecated:
+ - searchaction, poweredbyico, copyrightico
* DatabaseBlock::purgeExpired(), deprecated since 1.36, now emits
deprecation warnings.
* The following methods from the User class now trigger deprecation warnings:
diff --git a/includes/skins/QuickTemplate.php b/includes/skins/QuickTemplate.php
index 3d1d8ae62786..2077f5a64232 100644
--- a/includes/skins/QuickTemplate.php
+++ b/includes/skins/QuickTemplate.php
@@ -68,6 +68,9 @@ abstract class QuickTemplate {
/** @var Config */
protected $config;
+ /** @var array */
+ private $deprecated = [];
+
/**
* @param Config|null $config
*/
@@ -81,6 +84,17 @@ abstract class QuickTemplate {
}
/**
+ * Sets a template key as deprecated.
+ *
+ * @internal only for usage inside Skin and SkinTemplate class.
+ * @param string $name
+ * @param string $version When it was deprecated e.g. 1.38
+ */
+ public function deprecate( string $name, string $version ) {
+ $this->deprecated[$name] = $version;
+ }
+
+ /**
* Sets the value $value to $name
* @param string $name
* @param mixed $value
@@ -104,6 +118,21 @@ abstract class QuickTemplate {
}
/**
+ * Checks if the template key is deprecated
+ *
+ * @param string $name
+ */
+ private function checkDeprecationStatus( string $name ) {
+ $deprecated = $this->deprecated[ $name ] ?? false;
+ if ( $deprecated ) {
+ wfDeprecated(
+ 'QuickTemplate::(get/html/text/haveData) with parameter `' . $name . '`',
+ $deprecated
+ );
+ }
+ }
+
+ /**
* Gets the template data requested
* @since 1.22
* @param string $name Key for the data
@@ -112,6 +141,7 @@ abstract class QuickTemplate {
* @return-taint onlysafefor_htmlnoent
*/
public function get( $name, $default = null ) {
+ $this->checkDeprecationStatus( $name );
return $this->data[$name] ?? $default;
}
@@ -126,6 +156,7 @@ abstract class QuickTemplate {
* @suppress SecurityCheck-DoubleEscaped $this->data can be either
*/
protected function text( $str ) {
+ $this->checkDeprecationStatus( $str );
echo htmlspecialchars( $this->data[$str] );
}
@@ -134,6 +165,7 @@ abstract class QuickTemplate {
* @suppress SecurityCheck-XSS phan-taint-check cannot tell if $str is pre-escaped
*/
public function html( $str ) {
+ $this->checkDeprecationStatus( $str );
echo $this->data[$str];
}
@@ -149,6 +181,7 @@ abstract class QuickTemplate {
* @return bool
*/
private function haveData( $str ) {
+ $this->checkDeprecationStatus( $str );
return isset( $this->data[$str] );
}
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php
index 6ad28196d1d5..d05473ac821d 100644
--- a/includes/skins/SkinTemplate.php
+++ b/includes/skins/SkinTemplate.php
@@ -236,10 +236,10 @@ class SkinTemplate extends Skin {
$tpl->set( 'loggedin', $this->loggedin );
$tpl->set( 'notspecialpage', !$title->isSpecialPage() );
- // The template variable `searchaction` is deprecated since 1.36
$searchTitle = SpecialPage::newSearchPage( $this->getUser() );
$searchLink = $searchTitle->getLocalURL();
$tpl->set( 'searchaction', $searchLink );
+ $tpl->deprecate( 'searchaction', '1.36' );
$tpl->set( 'searchtitle', $searchTitle->getPrefixedDBkey() );
$tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
@@ -286,10 +286,12 @@ class SkinTemplate extends Skin {
$tpl->set( 'numberofwatchingusers', false );
$tpl->set( 'copyrightico', BaseTemplate::getCopyrightIconHTML( $config, $this ) );
+ $tpl->deprecate( 'copyrightico', '1.37' ); // [[phab:T290583]]
$poweredBy = BaseTemplate::getPoweredByHTML( $config );
// Run deprecated hook.
$this->getHookRunner()->onSkinGetPoweredBy( $poweredBy, $this );
$tpl->set( 'poweredbyico', $poweredBy );
+ $tpl->deprecate( 'poweredbyico', '1.37' ); // [[phab:T290583]]
$tpl->set( 'disclaimer', $footerData['places']['disclaimer'] ?? false );
$tpl->set( 'privacy', $footerData['places']['privacy'] ?? false );