Page MenuHomePhabricator

Deprecate parameter $default in MediaWiki\Request\WebRequest::getRawVal
Open, Needs TriagePublic

Description

Use

$request->getRawVal( 'key' ) ?? 'default'

instead of

$request->getRawVal( 'key', 'default' )

The ?? is more flexible, avoids a wrong type detection by phan and avoids the evaluation of the default value if not needed.

Demonstration of the expensive evaluation:

function expensive() {
  for ( $i = 0; $i < 1e8; $i++ ) {}
  return $i;
}
$request = new MediaWiki\Request\WebRequest();
$request->setVal( 'foo', 'bar' );
echo $request->getRawVal( 'foo' ) ?? expensive();
echo $request->getRawVal( 'foo', expensive() );

Details

SubjectRepoBranchLines +/-
mediawiki/coremaster+4 -1
mediawiki/skins/BlueSpiceDiscoverymaster+1 -1
mediawiki/coremaster+21 -24
operations/mediawiki-configmaster+3 -3
mediawiki/skins/WikimediaApiPortalmaster+3 -3
mediawiki/extensions/CampaignEventsmaster+1 -1
mediawiki/extensions/CentralAuthmaster+1 -1
mediawiki/extensions/DiscussionToolsmaster+2 -2
mediawiki/extensions/MobileFrontendmaster+4 -4
mediawiki/extensions/AdvancedSearchmaster+1 -1
mediawiki/extensions/ContentTranslationmaster+1 -1
mediawiki/skins/Splashmaster+2 -2
mediawiki/skins/BlueSpiceDiscoveryREL1_39+1 -1
mediawiki/extensions/UniversalLanguageSelectormaster+1 -1
mediawiki/extensions/Wikibasemaster+3 -7
mediawiki/extensions/RelatedArticlesmaster+1 -1
mediawiki/extensions/FileImportermaster+3 -3
mediawiki/extensions/Thememaster+5 -5
Show related patches Customize query in gerrit

Event Timeline

Change #1076971 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/core@master] WebRequest: Deprecate parameter $default in getRawVal

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

Change #1077146 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/Theme@master] Use ?? instead of replacing default values

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

Change #1077313 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/MobileFrontend@master] Use ?? instead of default value in getRawVal

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

Change #1077314 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/FileImporter@master] Use ?? instead of default value in getRawVal

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

Change #1077332 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Use ?? instead of default value in getRawVal()

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

Change #1077314 merged by jenkins-bot:

[mediawiki/extensions/FileImporter@master] Use ?? instead of default value in getRawVal

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

Change #1077146 merged by jenkins-bot:

[mediawiki/extensions/Theme@master] Use ?? instead of replacing default values

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

Change #1077343 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/RelatedArticles@master] Use ?? instead of default value in getRawVal()

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

Change #1077346 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/skins/BlueSpiceDiscovery@master] Use ?? instead of default value in getRawVal()

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

Change #1077347 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/DiscussionTools@master] Use ?? instead of default value in getRawVal()

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

Change #1077356 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/UniversalLanguageSelector@master] Use ?? instead of default value in getRawVal()

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

Change #1077332 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Use ?? instead of default value in getRawVal()

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

Change #1077343 merged by jenkins-bot:

[mediawiki/extensions/RelatedArticles@master] Use ?? instead of default value in getRawVal()

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

Change #1077356 merged by jenkins-bot:

[mediawiki/extensions/UniversalLanguageSelector@master] Use ?? instead of default value in getRawVal()

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

Change #1077381 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/skins/Splash@master] Use ?? instead of default value in getRawVal()

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

Change #1077382 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/ContentTranslation@master] Use ?? instead of default value in getRawVal()

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

Change #1077383 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/AdvancedSearch@master] Use ?? instead of default value in getRawVal()

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

Change #1077384 had a related patch set uploaded (by Robert Vogel; author: Fomafix):

[mediawiki/skins/BlueSpiceDiscovery@REL1_39] Use ?? instead of default value in getRawVal()

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

Change #1077384 merged by jenkins-bot:

[mediawiki/skins/BlueSpiceDiscovery@REL1_39] Use ?? instead of default value in getRawVal()

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

Change #1077382 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] Use ?? instead of default value in getRawVal()

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

Change #1077383 merged by jenkins-bot:

[mediawiki/extensions/AdvancedSearch@master] Use ?? instead of default value in getRawVal()

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

Change #1077381 merged by jenkins-bot:

[mediawiki/skins/Splash@master] Use ?? instead of default value in getRawVal()

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

Change #1077313 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Use ?? instead of default value in getRawVal

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

Change #1077347 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Use ?? instead of default value in getRawVal()

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

Change #1077413 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/skins/WikimediaApiPortal@master] Use ?? instead of default value in getRawVal()

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

Change #1077414 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/CentralAuth@master] Use ?? instead of default value in getRawVal()

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

Change #1077417 had a related patch set uploaded (by Fomafix; author: Fomafix):

[operations/mediawiki-config@master] Use ?? instead of default value in getRawVal()

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

Change #1077420 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/extensions/CampaignEvents@master] Use ?? instead of default value in getRawVal()

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

Change #1077414 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Use ?? instead of default value in getRawVal()

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

Change #1077420 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Use ?? instead of default value in getRawVal()

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

Change #1077413 merged by jenkins-bot:

[mediawiki/skins/WikimediaApiPortal@master] Use ?? instead of default value in getRawVal()

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

Change #1077417 merged by jenkins-bot:

[operations/mediawiki-config@master] Use ?? instead of default value in getRawVal()

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

Mentioned in SAL (#wikimedia-operations) [2024-10-10T13:38:32Z] <lucaswerkmeister-wmde@deploy2002> Started scap sync-world: Backport for [[gerrit:1077417|Use ?? instead of default value in getRawVal() (T376245)]]

Mentioned in SAL (#wikimedia-operations) [2024-10-10T13:40:53Z] <lucaswerkmeister-wmde@deploy2002> lucaswerkmeister-wmde, fomafix: Backport for [[gerrit:1077417|Use ?? instead of default value in getRawVal() (T376245)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-10-10T13:45:49Z] <lucaswerkmeister-wmde@deploy2002> Finished scap sync-world: Backport for [[gerrit:1077417|Use ?? instead of default value in getRawVal() (T376245)]] (duration: 07m 16s)

Change #1076971 merged by jenkins-bot:

[mediawiki/core@master] WebRequest: Deprecate parameter $default in getRawVal

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

Change #1077346 merged by Robert Vogel:

[mediawiki/skins/BlueSpiceDiscovery@master] Use ?? instead of default value in getRawVal()

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

Change #1082217 had a related patch set uploaded (by Fomafix; author: Fomafix):

[mediawiki/core@master] WebRequest: Hard-deprecate parameter $default in getRawVal

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