r101488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101487‎ | r101488 | r101489 >
Date:15:55, 1 November 2011
Author:catrope
Status:reverted (Comments)
Tags:
Comment:
Cache the result of User::getDefaultOptions(), so the UserGetDefaultOptions hook (introduced in r97365) is run only once rather than on every call. Discovered this issue after seeing an insane number of memcached fetches in my RL2 code, caused by a UserGetDefaultOptions hook accessing the Gadgets storage backend (which has a memc layer) and being called a zillion times due to this bug.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1207,6 +1207,10 @@
12081208 */
12091209 public static function getDefaultOptions() {
12101210 global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
 1211+ static $defOpt = null;
 1212+ if ( $defOpt !== null ) {
 1213+ return $defOpt;
 1214+ }
12111215
12121216 $defOpt = $wgDefaultUserOptions;
12131217 # default language setting

Follow-up revisions

RevisionCommit summaryAuthorDate
r101495Revert r101488, breaks parser test. Add a comment explaining why there is no ...catrope16:25, 1 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97365(bug 30940) Add a hook in User:getDefaultOptions....krinkle02:42, 17 September 2011

Comments

#Comment by Hashar (talk | contribs)   16:04, 1 November 2011

breaks some parser tests :-)

#Comment by Catrope (talk | contribs)   16:04, 1 November 2011

It seems I broke the way parser tests change the user language. Four tests are now broken and all the diffs have English texts instead of Catalan or Turkish or whichever language is being tested by that test. http://integration.mediawiki.org/ci/job/MediaWiki-phpunit/1114/

#Comment by Catrope (talk | contribs)   16:27, 1 November 2011

For future reference, the parser test failures were these:

Internal link with ca linktrail with apostrophes ([https://bugzilla.wikimedia.org/show_bug.cgi?id=27473 bug 27473])
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p><a href="https://www.mediawiki.org/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
+<p><a href="https://www.mediawiki.org/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (page does not exist)">Something'nice</a>
 </p>

Internal link with kaa linktrail with apostrophes ([https://bugzilla.wikimedia.org/show_bug.cgi?id=27473 bug 27473])
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p><a href="https://www.mediawiki.org/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
+<p><a href="https://www.mediawiki.org/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (page does not exist)">Something'nice</a>
 </p>

-{}- tags within headlines (within html for parserConvert())
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Уредите одељак „Naslov“">уреди</a>]</span> <span class="mw-headline" id="-.7BNaslov.7D-"> Naslov </span></h2>
+<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Naslov">edit</a>]</span> <span class="mw-headline" id="-.7BNaslov.7D-"> Naslov </span></h2>

[https://bugzilla.wikimedia.org/show_bug.cgi?id=31490 Bug31490] Turkish: ucfırst (with a dotless i)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p><a href="https://www.mediawiki.org/index.php?title=%C5%9Eablon:Ucf%C4%B1rst:blah&action=edit&redlink=1" class="new" title="Şablon:Ucfırst:blah (sayfa mevcut değil)">Şablon:Ucfırst:blah</a>
+<p><a href="https://www.mediawiki.org/index.php?title=%C5%9Eablon:Ucf%C4%B1rst:blah&action=edit&redlink=1" class="new" title="Şablon:Ucfırst:blah (page does not exist)">Şablon:Ucfırst:blah</a>
 </p>

Status & tagging log