ID:               49686
 User updated by:  galaxy4public+php at gmail dot com
 Reported By:      galaxy4public+php at gmail dot com
 Status:           Open
 Bug Type:         Dynamic loading
 Operating System: Linux
 PHP Version:      5.2.11
 New Comment:

Well, I made the directory world-readable:

ftp://ftp.ru.openwall.com/pvt/galaxy/php-spl-shared/

I'll place any updates to the patch there (if there are any).


Previous Comments:
------------------------------------------------------------------------

[2009-09-27 10:37:23] galaxy4public+php at gmail dot com

Ouch, this line-wrapping feature really hurts! :(  In the comment above
the link should be manually concatenated to get a correct URL.

------------------------------------------------------------------------

[2009-09-27 10:34:46] galaxy4public+php at gmail dot com

Since the patch was broken by line-wrapping I've uploaded it here:
ftp://ftp.ru.openwall.com/pvt/galaxy/php-spl-shared/php-5.2.11-gm-spl-shared.diff

------------------------------------------------------------------------

[2009-09-27 10:26:04] galaxy4public+php at gmail dot com

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 this bug report at http://bugs.php.net/?id=49686&edit=1

Reply via email to