com php-src: Fix bug #67064 in a BC safe way You can use an optional parameter now when implementing the Countable interface to get the $mode passed
to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
From: Bob Weinand Date: Sun, 13 Apr 2014 17:24:12 +0000 Subject: com php-src: Fix bug #67064 in a BC safe way You can use an optional parameter now when implementing the Countable interface to get the $mode passed
to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phptGroups: php.cvs Request: Send a blank email to php-cvs+get-76824@lists.php.net to get a copy of this message
Commit: 1a4a9eede59b853f11e8e8b965e5f715f53da8f7
Author: Bob Weinand <bobwei9@hotmail.com> Sun, 13 Apr 2014 19:19:24 +0200
Parents: 5a0da281e5a9fa02db18b4822d8b103c65849fa9
Branches: PHP-5.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1a4a9eede59b853f11e8e8b965e5f715f53da8f7
Log:
Fix bug #67064 in a BC safe way
You can use an optional parameter now when implementing the Countable interface
to get the $mode passed to count().
Bugs:
https://bugs.php.net/67064
Changed paths:
M ext/standard/array.c
A ext/standard/tests/array/bug67064.phpt
Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index c2efca5..f807bb5 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -333,7 +333,10 @@ PHP_FUNCTION(count)
#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);
+ zval *mode_zv;
+ MAKE_STD_ZVAL(mode_zv);
+ Z_LVAL_P(mode_zv) = mode;
+ zend_call_method_with_1_params(&array, NULL, NULL, "count", &retval,
mode_zv);
if (retval) {
convert_to_long_ex(&retval);
RETVAL_LONG(Z_LVAL_P(retval));
diff --git a/ext/standard/tests/array/bug67064.phpt b/ext/standard/tests/array/bug67064.phpt
new file mode 100644
index 0000000..e1996e3
--- /dev/null
+++ b/ext/standard/tests/array/bug67064.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #67064 ()
+--FILE--
+<?php
+class Counter implements Countable {
+ public function count($mode = COUNT_NORMAL) {
+ var_dump($mode == COUNT_RECURSIVE);
+ return 1;
+ }
+}
+
+$counter = new Counter;
+var_dump(count($counter, COUNT_RECURSIVE));
+?>
+--EXPECTF--
+bool(true)
+int(1)
Thread (10 messages)
- Re: com php-src: Fix bug #67064 in a BC safe way You canuse an optional parameter now when implementing the Countable interface toget the $mode passed
to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
- Re: com php-src: Fix bug #67064 in a BC safe way You can use an optional parameter now when implementing the Countable interface to get the $mode
passed to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
- Re: com php-src: Fix bug #67064 in a BC safe way You canuse an optional parameter now when implementing the Countable interface toget the $mode passed
to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
- Re: com php-src: Fix bug #67064 in a BC safe way You can use an optional parameter now when implementing the Countable interface to get the $mode
passed to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
- Re: com php-src: Fix bug #67064 in a BC safe way You canuse an optional parameter now when implementing the Countable interface toget the $mode passed
to count().: ext/standard/array.c ext/standard/tests/array/bug67064.phpt
| « previous | php.cvs (#76824) | next » |
|---|