colder Wed Jul 9 21:29:53 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/standard array.c
Log:
MFH: Fix resolution rule of count vs. handler
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.37.2.34&r2=1.308.2.21.2.37.2.35&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.37.2.34
php-src/ext/standard/array.c:1.308.2.21.2.37.2.35
--- php-src/ext/standard/array.c:1.308.2.21.2.37.2.34 Mon Jun 2 11:20:59 2008
+++ php-src/ext/standard/array.c Wed Jul 9 21:29:52 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.308.2.21.2.37.2.34 2008/06/02 11:20:59 mattwil Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.37.2.35 2008/07/09 21:29:52 colder Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -319,9 +319,17 @@
break;
case IS_OBJECT: {
#ifdef HAVE_SPL
- /* it the object implements Countable we call its
count() method */
zval *retval;
-
+#endif
+ /* first, we check if the handler is defined */
+ if (Z_OBJ_HT_P(array)->count_elements) {
+ RETVAL_LONG(1);
+ if (SUCCESS ==
Z_OBJ_HT(*array)->count_elements(array, &Z_LVAL_P(return_value) TSRMLS_CC)) {
+ return;
+ }
+ }
+#ifdef HAVE_SPL
+ /* if not and the object implements Countable we call
its count() method */
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) {
@@ -332,13 +340,6 @@
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);
- if (SUCCESS ==
Z_OBJ_HT(*array)->count_elements(array, &Z_LVAL_P(return_value) TSRMLS_CC)) {
- return;
- }
- }
}
default:
RETURN_LONG(1);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php