Hello Krinkle, Hashar,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/289364
to review the following change.
Change subject: Permit use of User::getDefaultOptions() in-process cache in
unit tests
......................................................................
Permit use of User::getDefaultOptions() in-process cache in unit tests
MediaWiki uses an in-process cache to speed up repeat calls to
User::getDefaultOptions() -- except when the unit tests are running, in which
case the process cache is disabled, because otherwise it would be at risk of
becoming stale due to unit tests manipulating $wgContLang. Well, there's a less
aggressive option, which is to keep the cache enabled but use it only if
$wgContLang hasn't changed. Since MediaWiki's test setup code creates default
users for the unit tests, User::getDefaultOptions() ends up getting called
quite a lot, so enabling the process cache is worth the trouble.
Change-Id: I81f3ae42d356939c81e59ab12d7a9e7d1206cb40
---
M includes/user/User.php
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/64/289364/1
diff --git a/includes/user/User.php b/includes/user/User.php
index b5384bc..03e4eb4 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -1523,10 +1523,10 @@
global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions,
$wgContLang, $wgDefaultSkin;
static $defOpt = null;
- if ( !defined( 'MW_PHPUNIT_TEST' ) && $defOpt !== null ) {
- // Disabling this for the unit tests, as they rely on
being able to change $wgContLang
- // mid-request and see that change reflected in the
return value of this function.
- // Which is insane and would never happen during normal
MW operation
+ if ( $defOpt !== null && $defOpt['language'] ===
$wgContLang->getCode() ) {
+ // $wgContLang does not change (and should not change)
mid-request,
+ // but the unit tests change it anyway, and expect this
method to
+ // return values relevant to the current $wgContLang.
return $defOpt;
}
--
To view, visit https://gerrit.wikimedia.org/r/289364
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I81f3ae42d356939c81e59ab12d7a9e7d1206cb40
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits