Hi guys. After this commit you no longer need to patch PHP. This is though a total hack, imo, and we need some kind of array seeking functions in PHP :]
-Hannes ---------- Forwarded message ---------- From: Hannes Magnusson <[EMAIL PROTECTED]> Date: Aug 19, 2007 3:19 PM Subject: [PHP-DOC] cvs: phd / build.php /themes/php phpweb.php To: phpdoc@lists.php.net bjori Sun Aug 19 13:19:48 2007 UTC Modified files: /phd build.php /phd/themes/php phpweb.php Log: Add a array-seeking-fallback, removing the need to patch PHP http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.23&r2=1.24&diff_format=u Index: phd/build.php diff -u phd/build.php:1.23 phd/build.php:1.24 --- phd/build.php:1.23 Sun Aug 19 12:09:55 2007 +++ phd/build.php Sun Aug 19 13:19:47 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: build.php,v 1.23 2007/08/19 12:09:55 bjori Exp $ */ +/* $Id: build.php,v 1.24 2007/08/19 13:19:47 bjori Exp $ */ function err($no, $str, $file, $line) { global $notify; @@ -49,6 +49,9 @@ /* FIXME: Load from sqlite db? */ } +$rf = new ReflectionFunction("in_array"); +define("HAS_ARRAY_SEEK", $rf->getNumberOfParameters() == 4); + foreach($OPTIONS["output_format"] as $output_format) { switch($output_format) { case "xhtml": http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.8&r2=1.9&diff_format=u Index: phd/themes/php/phpweb.php diff -u phd/themes/php/phpweb.php:1.8 phd/themes/php/phpweb.php:1.9 --- phd/themes/php/phpweb.php:1.8 Sat Aug 18 23:49:34 2007 +++ phd/themes/php/phpweb.php Sun Aug 19 13:19:48 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: phpweb.php,v 1.8 2007/08/18 23:49:34 bjori Exp $ */ +/* $Id: phpweb.php,v 1.9 2007/08/19 13:19:48 bjori Exp $ */ class phpweb extends phpdotnet implements PhDTheme { protected $streams = array(); @@ -112,7 +112,18 @@ } // Seek to $id + if (HAS_ARRAY_SEEK) { in_array($siblings[$id], $siblings, false, true); + } else { + /* Workaround PHPs incapability of seeking into array */ + while(list($tmp,) = each($siblings)) { + if ($tmp == $id) { + // Set the internal pointer back to $id + prev($siblings); + break; + } + } + } $tmp = prev($siblings); if ($tmp) { while (!empty($tmp["children"])) { @@ -138,7 +149,19 @@ } // Seek to $id + if (HAS_ARRAY_SEEK) { in_array($siblings[$id], $siblings, false, true) or die(var_export(debug_backtrace(), true) ."\n$id\n$parent"); // This should *never* happen + } else { + /* Workaround PHPs incapability of seeking into array */ + while(list($tmp,) = each($siblings)) { + if ($tmp == $id) { + // Set the internal pointer back to $id + prev($siblings); + break; + } + } + } + $tmp = next($siblings); prev($siblings); // Reset the internal pointer to previous pos if ($tmp) {