Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  Fixed bug #68128
This commit is contained in:
Tjerk Meesters 2014-10-14 22:50:07 +08:00
commit fb35d7c56e
9 changed files with 185 additions and 283 deletions

3
NEWS
View file

@ -42,6 +42,9 @@ PHP NEWS
. Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by . Fixed bug #68087 (ODBC not correctly reading DATE column when preceded by
a VARCHAR column) (Keyur Govande) a VARCHAR column) (Keyur Govande)
- SPL:
. Fixed bug #68128 (Regression in RecursiveRegexIterator) (Tjerk)
02 Oct 2014, PHP 5.6.1 02 Oct 2014, PHP 5.6.1
- Core: - Core:

View file

@ -49,6 +49,41 @@ static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval **retval,
} }
/* }}} */ /* }}} */
/* {{{ spl_instantiate_arg_n */
static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval **retval, int argc, zval ***argv TSRMLS_DC)
{
zend_function *func = pce->constructor;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval *dummy;
zval z_name;
spl_instantiate(pce, retval, 0 TSRMLS_CC);
ZVAL_STRING(&z_name, func->common.function_name, 0);
fci.size = sizeof(zend_fcall_info);
fci.function_table = &pce->function_table;
fci.function_name = &z_name;
fci.object_ptr = *retval;
fci.symbol_table = NULL;
fci.retval_ptr_ptr = &dummy;
fci.param_count = argc;
fci.params = argv;
fci.no_separation = 1;
fcc.initialized = 1;
fcc.function_handler = func;
fcc.calling_scope = EG(scope);
fcc.called_scope = pce;
fcc.object_ptr = *retval;
zend_call_function(&fci, &fcc TSRMLS_CC);
zval_ptr_dtor(&dummy);
}
/* }}} */
#endif /* SPL_ENGINE_H */ #endif /* SPL_ENGINE_H */
/* /*

View file

@ -2045,6 +2045,8 @@ SPL_METHOD(RegexIterator, accept)
if (intern->current.data == NULL) { if (intern->current.data == NULL) {
RETURN_FALSE; RETURN_FALSE;
} else if (Z_TYPE_P(intern->current.data) == IS_ARRAY) {
RETURN_FALSE;
} }
if (intern->u.regex.flags & REGIT_USE_KEY) { if (intern->u.regex.flags & REGIT_USE_KEY) {
@ -2080,8 +2082,7 @@ SPL_METHOD(RegexIterator, accept)
ALLOC_INIT_ZVAL(intern->current.data); ALLOC_INIT_ZVAL(intern->current.data);
php_pcre_match_impl(intern->u.regex.pce, subject, subject_len, &zcount, php_pcre_match_impl(intern->u.regex.pce, subject, subject_len, &zcount,
intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0 TSRMLS_CC); intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0 TSRMLS_CC);
count = zend_hash_num_elements(Z_ARRVAL_P(intern->current.data)); RETVAL_BOOL(Z_LVAL(zcount) > 0);
RETVAL_BOOL(count > 0);
break; break;
case REGIT_MODE_SPLIT: case REGIT_MODE_SPLIT:
@ -2259,7 +2260,7 @@ SPL_METHOD(RecursiveRegexIterator, __construct)
SPL_METHOD(RecursiveRegexIterator, getChildren) SPL_METHOD(RecursiveRegexIterator, getChildren)
{ {
spl_dual_it_object *intern; spl_dual_it_object *intern;
zval *retval, *regex; zval *retval;
if (zend_parse_parameters_none() == FAILURE) { if (zend_parse_parameters_none() == FAILURE) {
return; return;
@ -2269,16 +2270,61 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval); zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) { if (!EG(exception)) {
zval **args[5], *object, *regex, *mode, *flags, *preg_flags;
MAKE_STD_ZVAL(object);
MAKE_STD_ZVAL(regex); MAKE_STD_ZVAL(regex);
MAKE_STD_ZVAL(mode);
MAKE_STD_ZVAL(flags);
MAKE_STD_ZVAL(preg_flags);
MAKE_COPY_ZVAL(&retval, object);
ZVAL_STRING(regex, intern->u.regex.regex, 1); ZVAL_STRING(regex, intern->u.regex.regex, 1);
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, retval, regex TSRMLS_CC); ZVAL_LONG(mode, intern->u.regex.mode);
ZVAL_LONG(flags, intern->u.regex.flags);
ZVAL_LONG(preg_flags, intern->u.regex.preg_flags);
args[0] = &object;
args[1] = &regex;
args[2] = &mode;
args[3] = &flags;
args[4] = &preg_flags;
spl_instantiate_arg_n(Z_OBJCE_P(getThis()), &return_value, 5, args TSRMLS_CC);
zval_ptr_dtor(&object);
zval_ptr_dtor(&regex); zval_ptr_dtor(&regex);
zval_ptr_dtor(&mode);
zval_ptr_dtor(&flags);
zval_ptr_dtor(&preg_flags);
} }
if (retval) { if (retval) {
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
} }
} /* }}} */ } /* }}} */
SPL_METHOD(RecursiveRegexIterator, accept)
{
spl_dual_it_object *intern;
zval *rv;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (intern->current.data == NULL) {
RETURN_FALSE;
} else if (Z_TYPE_P(intern->current.data) == IS_ARRAY) {
RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL_P(intern->current.data)) > 0);
}
zend_call_method_with_0_params(&(getThis()), spl_ce_RegexIterator, NULL, "accept", &rv);
RETURN_ZVAL(rv, 1, 1);
}
#endif #endif
/* {{{ spl_dual_it_dtor */ /* {{{ spl_dual_it_dtor */
@ -2469,6 +2515,7 @@ ZEND_END_ARG_INFO();
static const zend_function_entry spl_funcs_RecursiveRegexIterator[] = { static const zend_function_entry spl_funcs_RecursiveRegexIterator[] = {
SPL_ME(RecursiveRegexIterator, __construct, arginfo_rec_regex_it___construct, ZEND_ACC_PUBLIC) SPL_ME(RecursiveRegexIterator, __construct, arginfo_rec_regex_it___construct, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveRegexIterator, accept, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveFilterIterator, hasChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(RecursiveFilterIterator, hasChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveRegexIterator, getChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(RecursiveRegexIterator, getChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
PHP_FE_END PHP_FE_END

View file

@ -0,0 +1,91 @@
--TEST--
Bug #68128 - RecursiveRegexIterator raises "Array to string conversion" notice
--FILE--
<?php
$array = new ArrayIterator(array('a', array('b', 'c')));
$regex = new RegexIterator($array, '/Array/');
foreach ($regex as $match) {
var_dump($match);
}
$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^(t)est(\d*)/',
RecursiveRegexIterator::ALL_MATCHES, 0, PREG_PATTERN_ORDER);
foreach ($rRegexIterator as $key1 => $value1) {
if ($rRegexIterator->hasChildren()) {
// print all children
echo "Children: ";
foreach ($rRegexIterator->getChildren() as $key => $value) {
print_r($value);
}
echo "\n";
} else {
echo "No children ";
print_r($value1);
echo "\n";
}
}
?>
--EXPECT--
No children Array
(
[0] => Array
(
[0] => test1
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 1
)
)
Children: Array
(
[0] => Array
(
[0] => test4
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 4
)
)
Array
(
[0] => Array
(
[0] => test5
)
[1] => Array
(
[0] => t
)
[2] => Array
(
[0] => 5
)
)

View file

@ -13,11 +13,6 @@ class MyRecursiveRegexIterator extends RecursiveRegexIterator
var_dump($v); var_dump($v);
} }
} }
function accept()
{
return $this->hasChildren() || parent::accept();
}
} }
$ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz')); $ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz'));

View file

@ -46,8 +46,6 @@ array(3) {
[2]=> [2]=>
%s(1) "2" %s(1) "2"
} }
Notice: Array to string conversion in %siterator_050.php on line %d
int(0) int(0)
array(2) { array(2) {
[0]=> [0]=>
@ -69,8 +67,6 @@ array(2) {
[1]=> [1]=>
%s(1) "1" %s(1) "1"
} }
Notice: Array to string conversion in %siterator_050.php on line %d
object(ArrayIterator)#%d (1) { object(ArrayIterator)#%d (1) {
%s"storage"%s"ArrayIterator":private]=> %s"storage"%s"ArrayIterator":private]=>
array(9) { array(9) {

View file

@ -46,18 +46,6 @@ var_dump($ar);
<?php exit(0); ?> <?php exit(0); ?>
--EXPECTF-- --EXPECTF--
bool(true) bool(true)
int(0)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(1) int(1)
array(3) { array(3) {
@ -97,85 +85,11 @@ array(3) {
} }
} }
bool(true) bool(true)
int(3)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(4) bool(false)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
Notice: Array to string conversion in %siterator_052.php on line %d
bool(true) bool(true)
int(5)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(6)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(7)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(8)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(0) int(0)
array(2) { array(2) {
@ -231,67 +145,11 @@ array(2) {
} }
} }
bool(true) bool(true)
int(3)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true) bool(true)
int(4) bool(false)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
Notice: Array to string conversion in %siterator_052.php on line %d
bool(true) bool(true)
int(5)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true) bool(true)
int(6)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true) bool(true)
int(7)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
bool(true)
int(8)
array(2) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
}
object(ArrayIterator)#%d (1) { object(ArrayIterator)#%d (1) {
["storage":"ArrayIterator":private]=> ["storage":"ArrayIterator":private]=>
array(9) { array(9) {

View file

@ -46,122 +46,14 @@ var_dump($ar);
<?php exit(0); ?> <?php exit(0); ?>
--EXPECTF-- --EXPECTF--
bool(true) bool(true)
int(0)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(1)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(2)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(3)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(4) bool(false)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(5)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(6)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(7)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true)
int(8)
array(3) {
[0]=>
array(0) {
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
}
bool(true) bool(true)
int(0) int(0)
array(2) { array(2) {
@ -232,20 +124,7 @@ array(2) {
string(1) "4" string(1) "4"
} }
} }
bool(true) bool(false)
int(5)
array(2) {
[0]=>
array(1) {
[0]=>
string(1) "5"
}
[1]=>
array(1) {
[0]=>
string(1) "5"
}
}
bool(true) bool(true)
int(6) int(6)
array(2) { array(2) {

View file

@ -42,8 +42,6 @@ array(3) {
[2]=> [2]=>
string(1) "3" string(1) "3"
} }
Notice: Array to string conversion in %siterator_054.php on line %d
int(7) int(7)
array(2) { array(2) {
[0]=> [0]=>