Using getDateFormat instead of mDateFormat in ParserOptions::optionsHash. This was...
authorPriyanka Dhanda <pdhanda@users.mediawiki.org>
Mon, 1 Nov 2010 23:00:53 +0000 (23:00 +0000)
committerPriyanka Dhanda <pdhanda@users.mediawiki.org>
Mon, 1 Nov 2010 23:00:53 +0000 (23:00 +0000)
includes/parser/ParserOptions.php
maintenance/tests/phpunit/includes/ParserOptionsTest.php [new file with mode: 0644]

index dcd0bad..40ee6cf 100644 (file)
@@ -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 (file)
index 0000000..0b11f10
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+class ParserOptionsTest extends PHPUnit_Framework_TestCase {
+
+       private $popts;
+       private $pcache;
+       
+       function setUp() {
+               ParserTest::setUp(); //reuse setup from parser tests
+               global $wgContLang, $wgUser;
+               $wgContLang = new StubContLang;
+               $this->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 );       
+       }
+}