Format multiple autocomments in edit summaries
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 9 Sep 2014 15:25:10 +0000 (11:25 -0400)
committerTim Starling <tstarling@wikimedia.org>
Tue, 30 Dec 2014 23:24:05 +0000 (10:24 +1100)
commit29951907f73e59b0fcfc43b3a2554ed77f2268d8
treec245ad8bf2ba7df0531b0fb10a484c3eda165292
parent64ade26dea51bbeb769d52cad9aa014d8b11604f
Format multiple autocomments in edit summaries

Before r39373, all autocomments in an edit summary were formatted. In
fixing a bug with page titles containing "/*" this was accidentally
broken.

To use a single preg_replace_callback call to replace multiple
autocomments, we need to make sure that the match of one autocomment
doesn't overlap the match of another, which means we can't have "(.*)"
before and after. But we do still need to detect whether there is
anything before or after. "(?=(.?))" and "(?<=(.?))" would do nicely,
except the latter isn't actually supported. "(?=(.))?" and "(?<=(.))?"
work too, but older versions of PCRE don't support that. They do,
however, support "(?:(?=(.)))?" and "(?:(?<=(.)))?", so that's what
we'll go with.

This change does change the values for $pre and $post passed to the
FormatAutocomments hook; extensions need to be updated to accept (and
not prepend/append) booleans for these parameters.

Bug: T18530
Bug: T70361
Change-Id: I36c3a9e548a4ef72f93974bb35f9add8c29e9287
RELEASE-NOTES-1.25
docs/hooks.txt
includes/Linker.php
tests/phpunit/includes/LinkerTest.php