From 3e2965d7796e36c22357bc40dbeacf9a3dc1df07 Mon Sep 17 00:00:00 2001 From: andi Date: Mon, 7 Feb 2005 18:19:20 +0100 Subject: PCRE limit workaround for old PHP versions (#119) darcs-hash:20050207171920-9977f-2ad8f85cf4e4488e93cd686fec99b6c10ecbad73.gz --- inc/common.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'inc/common.php') 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){ -- cgit v1.2.3