(bug 36839) Use mb_check_encoding() if available.
authorlupo <lupo.bugzilla@gmail.com>
Thu, 31 May 2012 12:21:36 +0000 (14:21 +0200)
committerlupo <lupo.bugzilla@gmail.com>
Thu, 31 May 2012 12:21:36 +0000 (14:21 +0200)
commit5b9731e08ad1b373ebc329a7cf99de142a334181
tree4f38e72241b7a921418af786c1f44ff47c270063
parent73bbe9f3a2c53a10523b9e487b33ab9f82a07344
(bug 36839) Use mb_check_encoding() if available.

This is not a real fix for the cause of the bug (which is a
pcre.recursion_limit that is far too low), but I do wonder
about the efficiency of using a regexp to test for valid
UTF-8 encoding. After all the regexp has to be compiled first
into a state machine.

Patch set 2: Php unit test for Language.checkTitleEncoding
Patch set 3: benchmark
Patch set 4: add benchmark for non-capturing subgroup in regexp, and
since that's faster than a capturing subgroup, use it in
checkTitleEncoding() in the regexp branch.
Patch set 5: use Tim's suggestion (once-only pattern) in the regexp
branch. Also add to benchmark.

Change-Id: I551f096921d4c9c57cbcb091b80ab5970ca86a9b
languages/Language.php
maintenance/benchmarks/bench_utf8_title_check.php [new file with mode: 0644]
tests/phpunit/languages/LanguageTest.php