r75838 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75837‎ | r75838 | r75839 >
Date:23:00, 1 November 2010
Author:pdhanda
Status:ok (Comments)
Tags:
Comment:
Using getDateFormat instead of mDateFormat in ParserOptions::optionsHash. This was causing parser cache misses when using ApiParse
Modified paths:
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/ParserOptionsTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/ParserOptionsTest.php
@@ -0,0 +1,35 @@
 2+<?php
 3+
 4+class ParserOptionsTest extends PHPUnit_Framework_TestCase {
 5+
 6+ private $popts;
 7+ private $pcache;
 8+
 9+ function setUp() {
 10+ ParserTest::setUp(); //reuse setup from parser tests
 11+ global $wgContLang, $wgUser;
 12+ $wgContLang = new StubContLang;
 13+ $this->popts = new ParserOptions( $wgUser );
 14+ $this->pcache = ParserCache::singleton();
 15+ }
 16+
 17+ function tearDown() {
 18+ parent::tearDown();
 19+ }
 20+
 21+ /*
 22+ * ParserOptions::optionsHash was not giving consistent results when $wgUseDynamicDates was set
 23+ */
 24+ function testGetParserCacheKeyWithDynamicDates() {
 25+ global $wgUseDynamicDates;
 26+ $wgUseDynamicDates = true;
 27+
 28+ $title = Title::newFromText( "Some test article" );
 29+ $article = new Article( $title );
 30+
 31+ $pcacheKeyBefore = $this->pcache->getKey( $article, $this->popts );
 32+ $this->assertNotNull( $this->popts->getDateFormat() );
 33+ $pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts );
 34+ $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter );
 35+ }
 36+}
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -284,7 +284,7 @@
285285 $confstr .= '!*' ;
286286
287287 if ( in_array( 'dateformat', $forOptions ) )
288 - $confstr .= '!' . $this->mDateFormat;
 288+ $confstr .= '!' . $this->getDateFormat();
289289
290290 if ( in_array( 'numberheadings', $forOptions ) )
291291 $confstr .= '!' . ( $this->mNumberHeadings ? '1' : '' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r75933Follow up r75906....platonides16:42, 3 November 2010

Comments

#Comment by Platonides (talk | contribs)   23:04, 1 November 2010

You are right. While it would work in the expected case, it could access the unitialised one when forcing dateformat option.

Status & tagging log