[Mediawiki-l] Possible PHP bug causes page blanking in 1.9.3

Ian Smith ismith at good.com
Fri Mar 16 20:11:07 UTC 2007


Hi,

 

I’m trying to figure out a nasty bug in 1.9.3, which I think may actually be a PHP bug.  I’d welcome your thoughts.

 

The symptom is that since upgrading from 1.6.3 to 1.9.3, some pages in my wiki display as blank.  “Some” seems to refer to pages which include certain extended characters, such as the fancy close double quote (but not the open).  The historical versions of the same page display as blank too.  The page text in the database is still OK, as editing and saving the page fixes it – but where the close quote was, I now have “�?”.

 

This seems to be a parser bug.  Dumping debug statements into the code, and setting $wgEnableParserCache = false, I found that the text was being set to null in the parser at the point where it does this:

 

            $mw = MagicWord::get( 'notoc' );

            if( $mw->matchAndRemove( $text ) ) {

 

Looking into MagicWord.php, at function matchAndRemove, it seems that the text gets blanked by the call to preg_replace_callback, even though there are no matches in this case (the article doesn’t have “__NOTOC__”).

 

The regular expression being used for this was:

 

            /__NOTOC__/iu

 

The workaround I found was to remove the “u”; ie. in function initRegex():

 

<               $case = $this->mCaseSensitive ? '' : 'iu';

---

>               $case = $this->mCaseSensitive ? '' : 'i';

 

Note that we don’t use UTF8 much, but some people have pasted the fancy quotes from Windows into some pages.

 

Any thoughts?



Ian Smith





More information about the MediaWiki-l mailing list