From 98207004f214e20989f06e0e396ba632322988f0 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 7 Mar 2014 10:32:28 +0400 Subject: [PATCH 1/2] Quick fix for "Incompatibility with old versions of PHP from 5.2.17 (inclusively)" issue. --- noutrace.class.php | 13 ++++++------- trace.config.php | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/noutrace.class.php b/noutrace.class.php index 39e5baa..c6aff68 100644 --- a/noutrace.class.php +++ b/noutrace.class.php @@ -74,13 +74,12 @@ public function usortByArrayKey(&$array, $key, $asc=SORT_ASC) $sort_flags = array(SORT_ASC, SORT_DESC); if (!in_array($asc, $sort_flags)) throw new InvalidArgumentException('sort flag only accepts SORT_ASC or SORT_DESC'); - $cmp = function(array $a, array $b) use ($key, $asc, $sort_flags) - { + $cmp = create_function('array $a, array $b use $key, $asc, $sort_flags',' if (!is_array($key)) { //just one key and sort direction if (!isset($a[$key]) || !isset($b[$key])) { - throw new Exception('attempting to sort on non-existent keys'); + throw new Exception(\'attempting to sort on non-existent keys\'); } if ($a[$key] == $b[$key]) return 0; @@ -89,16 +88,16 @@ public function usortByArrayKey(&$array, $key, $asc=SORT_ASC) { //using multiple keys for sort and sub-sort foreach ($key as $sub_key => $sub_asc) { - //array can come as 'sort_key'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which + //array can come as \'sort_key\'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which if (!in_array($sub_asc, $sort_flags)) { $sub_key = $sub_asc; $sub_asc = $asc; } - //just like above, except 'continue' in place of return 0 + //just like above, except \'continue\' in place of return 0 if (!isset($a[$sub_key]) || !isset($b[$sub_key])) { - throw new Exception('attempting to sort on non-existent keys'); + throw new Exception(\'attempting to sort on non-existent keys\'); } if ($a[$sub_key] == $b[$sub_key]) continue; @@ -106,7 +105,7 @@ public function usortByArrayKey(&$array, $key, $asc=SORT_ASC) } return 0; } - }; + '); usort($array, $cmp); } diff --git a/trace.config.php b/trace.config.php index 4f69061..90d56f4 100644 --- a/trace.config.php +++ b/trace.config.php @@ -31,26 +31,26 @@ function aryComp($a, $b) function usortByArrayKey(&$array, $key, $asc=SORT_ASC) { $sort_flags = array(SORT_ASC, SORT_DESC); if(!in_array($asc, $sort_flags)) throw new InvalidArgumentException('sort flag only accepts SORT_ASC or SORT_DESC'); - $cmp = function(array $a, array $b) use ($key, $asc, $sort_flags) { + $cmp = create_function('array $a, array $b use $key, $asc, $sort_flags',' if(!is_array($key)) { //just one key and sort direction if(!isset($a[$key]) || !isset($b[$key])) { - throw new Exception('attempting to sort on non-existent keys'); + throw new Exception(\'attempting to sort on non-existent keys\'); } if($a[$key] == $b[$key]) return 0; return ($asc==SORT_ASC xor $a[$key] < $b[$key]) ? 1 : -1; } else { //using multiple keys for sort and sub-sort foreach($key as $sub_key => $sub_asc) { - //array can come as 'sort_key'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which + //array can come as \'sort_key\'=>SORT_ASC|SORT_DESC or just \'sort_key\', so need to detect which if(!in_array($sub_asc, $sort_flags)) { $sub_key = $sub_asc; $sub_asc = $asc; } - //just like above, except 'continue' in place of return 0 + //just like above, except \'continue\' in place of return 0 if(!isset($a[$sub_key]) || !isset($b[$sub_key])) { - throw new Exception('attempting to sort on non-existent keys'); + throw new Exception(\'attempting to sort on non-existent keys\'); } if($a[$sub_key] == $b[$sub_key]) continue; return ($sub_asc==SORT_ASC xor $a[$sub_key] < $b[$sub_key]) ? 1 : -1; } return 0; } - }; + ')}; usort($array, $cmp); } From 7b2be3fb9f63ac200b03ae4b7ba065dca806a7cd Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 7 Mar 2014 12:14:43 +0400 Subject: [PATCH 2/2] The Fix for situation: if appeared tag "