Page MenuHomePhabricator

mediawiki-1.22.0, pcre-8.34 (using php-5.5.7): Pages with content displayed as blank/empty when $regex groups start with digit
Closed, ResolvedPublic

Description

Author: timo.gurr

Description:
php-5.5.7-with-pcre-8.34.jpg

After upgrading pcre from version 8.33 to 8.34 mediawiki-1.22.0 shows some undesired/broken behaviour.

  • descriptive text when editing a page is missing (see attached screenshots)
  • pages with content displayed as blank/empty

Apache error.log shows the following:

[Wed Dec 18 11:40:32.819810 2013] [:error] [pid 20885] [client 127.0.0.1:57571] PHP Warning: Invalid argument supplied for foreach() in /var/www/wiki/htdocs/includes/MagicWord.php on line 882, referer: http://wiki.domain/index.php/Hauptseite
[Wed Dec 18 11:40:32.819841 2013] [:error] [pid 20885] [client 127.0.0.1:57571] PHP Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/wiki/htdocs/includes/MagicWord.php on line 886, referer: http://wiki.domain/index.php/Hauptseite
[Wed Dec 18 11:40:32.819871 2013] [:error] [pid 20885] [client 127.0.0.1:57571] PHP Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /var/www/wiki/htdocs/includes/MagicWord.php on line 881, referer: http://wiki.domain/index.php/Hauptseite

Side note: Downgrading pcre back to 8.33 didn't solve the problem with the "emtpy" pages immediately, I had to edit and save them (without changing the content) to get the content displayed again.


Version: 1.22.0
Severity: major
OS: Linux

Attached:

php-5.5.7-with-pcre-8.34.jpg (159×811 px, 10 KB)

Details

Reference
bz58640

Related Objects

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:32 AM
bzimport set Reference to bz58640.

timo.gurr wrote:

php-5.5.7-with-pcre-8.33.jpg

Attached:

php-5.5.7-with-pcre-8.33.jpg (204×615 px, 19 KB)

The regexes used on these lines (the $regex variable) do seem to have named groups starting with a digit, e.g.

/(?P<0_notoc>__NOTOC__)|(?P<0_nogallery>__NOGALLERY__)|(?P<0_forcetoc>__FORCETOC__)|(?P<0_toc>__TOC__)|(?P<0_noeditsection>__NOEDITSECTION__)|(?P<0_notitleconvert>__NOTITLECONVERT__)|(?P<1_notitleconvert>__NOTC__)|(?P<0_nocontentconvert>__NOCONTENTCONVERT__)|(?P<1_nocontentconvert>__NOCC__)/iuS

I'm not quite sure what generates them right now, but it could probably be changed to, say, insert a '_' at the beginning of the name or something.
It's rather silly of PCRE to break compatibility like that, though…

aommundsen wrote:

I can confirm this bug in both MediaWiki 1.20.8 and 1.22.0, they do not work on servers using PCRE 8.34. I have posted about it here: http://www.mediawiki.org/w/index.php?title=Project:Support_desk#MediaWiki_don.27t_work_with_PCRE_8.34_37016

Here is from apache usage log:

[Wed Dec 18 14:07:46.351691 2013] [:error] [pid 8193] [client 12.12.12.12:53455] PHP Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/xxx/domains/xxx.com/public_html/w/includes/MagicWord.php on line 907, referer: http:// xxx.no/w/index.php/Hovedside

When I look at PCRE 8.34 changelog at http://pcre.org/news.txt it says this:

"Perl no longer allows group names to start with digits, so I have made this change also in PCRE."

Can someone please help by providing a patch that I can apply to MagicWord.php, so that I don't have to downgrade PCRE?

I am running Apache 2.4.7, PHP 5.4.23 and PCRE 8.34. No most pages on the MediaWiki site is empty without content. So I need a quick solution.

Created attachment 14128
A quick ugly hack that should make MW work with PCRE 8.34

(In reply to comment #3)

Can someone please help by providing a patch that I can apply to
MagicWord.php,
so that I don't have to downgrade PCRE?

I am running Apache 2.4.7, PHP 5.4.23 and PCRE 8.34. No most pages on the
MediaWiki site is empty without content. So I need a quick solution.

The attached patch doesn't seem to break the wiki horribly at a glance and should work with the new restrictions (although I haven't tried it). It's also definitely the wrong way to solve this problem in the long run.

attachment magicwordpatch.txt ignored as obsolete

aommundsen wrote:

Thank you, Bartosz. However it did not work for me. I applied your change from the patch, and then I purged the cache on the front page like it says here: http://www.mediawiki.org/wiki/Manual:Purge

However the content of the page is still empty, only the title and menus etc is visible, but the content of the article is blank/empty (like it was before I applied the patch)

I also continue to get the same warning in apache error log as I posted in reply above. :(

aommundsen wrote:

It's still assigned to nobody, so I guess I am out of look and need to dowgrade pcre. This situation is no fun at all.

(In reply to comment #5)

Thank you, Bartosz. However it did not work for me.

That's because the (?P< part of the regex is built in the MagicWordArray class,
not in the MagicWord class. Both classes are in the same file.

I'll upload a new version of the patch now. All parser tests pass with PHP 5.5.7 and PCRE 8.34 on my system. Let us know if it works.

Created attachment 14135
Quick and dirty PCRE 8.34 compat patch

attachment 0001-Quick-and-dirty-PCRE-8.34-compat-patch.patch ignored as obsolete

aommundsen wrote:

Thank you, Kevin! Your patch works! I applied your patch to MediaWiki 1.20.8, and do not have any problems.

However some of the pages was cached with the old problem missing content, I solved this quickly by running the command to upgrade (without upgrading, because that command also purges the cache:

cd /home/USER/domains/DOMAIN.COM/public_html/w/maintenance
php update.php

Again, thanks! I hope this patch soon is added to a new MediaWiki version. :)

nikus0pokus wrote:

Another quick solution is to go back to PCRE 8.33 until a correction was made.

I've downgrade PCRE 8.33 too. Waiting for the fix to release now :-)

aommundsen: appending "?action=purge" can refresh the cache of indivisual pages.

Change 103215 had a related patch set uploaded by PleaseStand:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/103215

I have added this to https://www.mediawiki.org/wiki/MediaWiki_1.22/Known_issues and uploaded a new version of the patch to Gerrit so this can be fixed in the next release.

Change 103215 merged by jenkins-bot:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/103215

Fixed in master. Mark, do we want to backport this?

Change 107259 had a related patch set uploaded by MarkAHershberger:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/107259

Change 107259 merged by jenkins-bot:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/107259

[Patch merged into REL1_22 branch + available in 1.22.1 tarball; closing again]

Comment on attachment 14135
Quick and dirty PCRE 8.34 compat patch

Marking my initial patch as obsolete. Current patch (applied to master and REL1_22, and released as part of 1.22.1) is:

https://git.wikimedia.org/patch/mediawiki%2Fcore.git/b9f291e8cd5bb1450f7b1031aa17cf7775aa7e96

Not (yet?) applied to REL1_19 or REL1_21.

taraathan wrote:

Please apply this patch to the Long-Term Support Release 1.19. My webhost just upgraded PCRE and now all my wiki pages are blank.

Change 122449 had a related patch set uploaded by PleaseStand:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/122449

Change 122450 had a related patch set uploaded by PleaseStand:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/122450

Change 122449 merged by jenkins-bot:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/122449

Change 122450 merged by jenkins-bot:
Make MagicWordArray compatible with PCRE 8.34+

https://gerrit.wikimedia.org/r/122450

(In reply to Tara Athan from comment #21)

Please apply this patch to the Long-Term Support Release 1.19. My webhost
just upgraded PCRE and now all my wiki pages are blank.

It was backported to the just-released MediaWiki 1.19.15.

Barnerd confirmed on IRC that with 1.21.7 the web installer is broken in FreeBSD (message strings not shown), but the patch fixes it. Should be released with 1.21.9 on 2014-04-24 at the latest.

kevin wrote:

Forgive me for my lack of knowledge. Can someone point me to instructions for applying the patch?

Links to patches are given above, and as general patch application instructions are not MediaWiki specific, you might either use your favorite search engine or ask on https://www.mediawiki.org/wiki/Project:Support_desk :)