summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-02-07 18:19:20 +0100
committerandi <andi@splitbrain.org>2005-02-07 18:19:20 +0100
commit3e2965d7796e36c22357bc40dbeacf9a3dc1df07 (patch)
treea325b3c94b48da7a848db599b165c75a27be27bc
parent8037580c49641a6a445b5590dbaf25930d128c6e (diff)
downloadrpg-3e2965d7796e36c22357bc40dbeacf9a3dc1df07.tar.gz
rpg-3e2965d7796e36c22357bc40dbeacf9a3dc1df07.tar.bz2
PCRE limit workaround for old PHP versions (#119)
darcs-hash:20050207171920-9977f-2ad8f85cf4e4488e93cd686fec99b6c10ecbad73.gz
-rw-r--r--inc/common.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php
index a1325e2fc..e9c4d7406 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -330,9 +330,18 @@ function checkwordblock(){
if(!$conf['usewordblock']) return false;
$blockfile = file('conf/wordblock.conf');
- //read file in chunks of 600 - this should work around the
- //MAX_PATTERN_SIZE in PCRE
- while($blocks = array_splice($blockfile,0,600)){
+ //how many lines to read at once (to work around some PCRE limits)
+ if(version_compare(phpversion(),'4.3.0','<')){
+ //old versions of PCRE define a maximum of parenthesises even if no
+ //backreferences are used - the maximum is 99
+ //this is very bad performancewise and may even be too high still
+ $chunksize = 40;
+ }else{
+ //read file in chunks of 600 - this should work around the
+ //MAX_PATTERN_SIZE in modern PCRE
+ $chunksize = 600;
+ }
+ while($blocks = array_splice($blockfile,0,$chunksize)){
$re = array();
#build regexp from blocks
foreach($blocks as $block){