From: galaxy4public+php at gmail dot com Operating system: Linux PHP version: 5.2.11 PHP Bug Type: Dynamic loading Bug description: SPL as a shared ext: run-time check for SPL instead of compile-time
Description: ------------ The attached patch introduces a run-time check for the SPL extension instead of the compile-time one. This allows to build SPL as a shared extension (the corresponding changes to config.m4 are included in the patch as well). This work was sponsored by the WebEnabled (http://webenabled.com) project. Since there is no way to attach patches to bug reports I'm including it below: === --- php-5.2.5.orig/ext/spl/config.m4 2006-12-04 18:01:53 +0000 +++ php-5.2.5/ext/spl/config.m4 2008-04-07 05:53:55 +0000 @@ -26,7 +26,7 @@ CPPFLAGS=$old_CPPFLAGS AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed]) AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) - PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c, no) + PHP_NEW_EXTENSION(spl, [php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c], $ext_shared) PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_sxe.h]) PHP_ADD_EXTENSION_DEP(spl, pcre, true) fi --- php-5.2.11.orig/ext/standard/array.c 2009-08-14 06:18:47 +0000 +++ php-5.2.11/ext/standard/array.c 2009-09-27 08:46:42 +0000 @@ -324,20 +324,22 @@ PHP_FUNCTION(count) RETURN_LONG (php_count_recursive (array, mode TSRMLS_CC)); break; case IS_OBJECT: { -#ifdef HAVE_SPL - /* it the object implements Countable we call its count() method */ - zval *retval; - - if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) { - zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval); - if (retval) { - convert_to_long_ex(&retval); - RETVAL_LONG(Z_LVAL_P(retval)); - zval_ptr_dtor(&retval); + zend_class_entry **pce; + /* check whether the SPL extension available or not */ + if (zend_hash_find(EG(class_table), "countable", sizeof("Countable"), (void **) &pce) == SUCCESS) { + /* if the object implements Countable we call its count() method */ + zval *retval; + if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), *pce TSRMLS_CC)) { + zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval); + if (retval) { + convert_to_long_ex(&retval); + RETVAL_LONG(Z_LVAL_P(retval)); + zval_ptr_dtor(&retval); + } + return; } - return; } -#endif + /* if not we return the number of properties (not taking visibility into account) */ if (Z_OBJ_HT_P(array)->count_elements) { RETVAL_LONG(1); === -- Edit bug report at http://bugs.php.net/?id=49686&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49686&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49686&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49686&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49686&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49686&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49686&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49686&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49686&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49686&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49686&r=support Expected behavior: http://bugs.php.net/fix.php?id=49686&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49686&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49686&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49686&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49686&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49686&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49686&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49686&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49686&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49686&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49686&r=mysqlcfg
