From: Priyanka Dhanda Date: Mon, 1 Nov 2010 23:00:53 +0000 (+0000) Subject: Using getDateFormat instead of mDateFormat in ParserOptions::optionsHash. This was... X-Git-Tag: 1.31.0-rc.0~34132 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=3d0db4ad13ee0e35a1fe785832b025f8f8870630;p=lhc%2Fweb%2Fwiklou.git Using getDateFormat instead of mDateFormat in ParserOptions::optionsHash. This was causing parser cache misses when using ApiParse --- diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index dcd0bad669..40ee6cf00a 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -284,7 +284,7 @@ class ParserOptions { $confstr .= '!*' ; if ( in_array( 'dateformat', $forOptions ) ) - $confstr .= '!' . $this->mDateFormat; + $confstr .= '!' . $this->getDateFormat(); if ( in_array( 'numberheadings', $forOptions ) ) $confstr .= '!' . ( $this->mNumberHeadings ? '1' : '' ); diff --git a/maintenance/tests/phpunit/includes/ParserOptionsTest.php b/maintenance/tests/phpunit/includes/ParserOptionsTest.php new file mode 100644 index 0000000000..0b11f1004f --- /dev/null +++ b/maintenance/tests/phpunit/includes/ParserOptionsTest.php @@ -0,0 +1,35 @@ +popts = new ParserOptions( $wgUser ); + $this->pcache = ParserCache::singleton(); + } + + function tearDown() { + parent::tearDown(); + } + + /* + * ParserOptions::optionsHash was not giving consistent results when $wgUseDynamicDates was set + */ + function testGetParserCacheKeyWithDynamicDates() { + global $wgUseDynamicDates; + $wgUseDynamicDates = true; + + $title = Title::newFromText( "Some test article" ); + $article = new Article( $title ); + + $pcacheKeyBefore = $this->pcache->getKey( $article, $this->popts ); + $this->assertNotNull( $this->popts->getDateFormat() ); + $pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts ); + $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter ); + } +}