lbarnaud Thu Jul 24 15:54:41 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/spl/tests bug45614.phpt
Modified files: /php-src NEWS /php-src/ext/spl spl_array.c Log: MFH: Fixed bug #45614 (ArrayIterator::current(), ::key() can show 1st private prop of wrapped object) http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.219&r2=1.2027.2.547.2.965.2.220&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.219 php-src/NEWS:1.2027.2.547.2.965.2.220 --- php-src/NEWS:1.2027.2.547.2.965.2.219 Thu Jul 24 14:38:37 2008 +++ php-src/NEWS Thu Jul 24 15:54:41 2008 @@ -219,6 +219,8 @@ - Fixed PECL bug #12431 (OCI8 ping functionality is broken). (Oracle Corp.) - Fixed PECL bug #12401 (Add support for ATTR_FETCH_TABLE_NAMES). (Johannes) +- Fixed bug #45614 (ArrayIterator::current(), ::key() can show 1st private + prop of wrapped object). (robin_fernandes at uk dot ibm dot com, Arnaud) - Fixed bug #45571 (ReflectionClass::export() shows superclasses' private static methods). (robin_fernandes at uk dot ibm dot com) - Fixed bug #45345 (SPLFileInfo::getPathInfo() returning dir info instead of http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.71.2.17.2.13.2.17&r2=1.71.2.17.2.13.2.18&diff_format=u Index: php-src/ext/spl/spl_array.c diff -u php-src/ext/spl/spl_array.c:1.71.2.17.2.13.2.17 php-src/ext/spl/spl_array.c:1.71.2.17.2.13.2.18 --- php-src/ext/spl/spl_array.c:1.71.2.17.2.13.2.17 Sun Jul 20 16:32:55 2008 +++ php-src/ext/spl/spl_array.c Thu Jul 24 15:54:41 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.c,v 1.71.2.17.2.13.2.17 2008/07/20 16:32:55 colder Exp $ */ +/* $Id: spl_array.c,v 1.71.2.17.2.13.2.18 2008/07/24 15:54:41 lbarnaud Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -86,6 +86,8 @@ } } /* }}} */ +static void spl_array_rewind(spl_array_object *intern TSRMLS_DC); + SPL_API int spl_hash_verify_pos(spl_array_object * intern TSRMLS_DC) /* {{{ */ { HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); @@ -102,7 +104,7 @@ p = p->pListNext; } /* HASH_UNPROTECT_RECURSION(ht); */ - zend_hash_internal_pointer_reset_ex(spl_array_get_hash_table(intern, 0 TSRMLS_CC), &intern->pos); + spl_array_rewind(intern TSRMLS_CC); return FAILURE; } /* }}} */ @@ -226,7 +228,7 @@ } } - zend_hash_internal_pointer_reset_ex(spl_array_get_hash_table(intern, 0 TSRMLS_CC), &intern->pos); + spl_array_rewind(intern TSRMLS_CC); return retval; } /* }}} */ @@ -702,8 +704,6 @@ return std_object_handlers.has_property(object, member, has_set_exists TSRMLS_CC); } /* }}} */ -static void spl_array_rewind(spl_array_object *intern TSRMLS_DC); - static void spl_array_unset_property(zval *object, zval *member TSRMLS_DC) /* {{{ */ { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); @@ -1164,7 +1164,7 @@ opos = position; if (position >= 0) { /* negative values are not supported */ - zend_hash_internal_pointer_reset_ex(aht, &intern->pos); + spl_array_rewind(intern TSRMLS_CC); result = SUCCESS; while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS); @@ -1192,7 +1192,7 @@ * we're going to call and which do not support 'pos' as parameter. */ pos = intern->pos; *count = 0; - zend_hash_internal_pointer_reset_ex(aht, &intern->pos); + spl_array_rewind(intern TSRMLS_CC); while(intern->pos && spl_array_next(intern TSRMLS_CC) == SUCCESS) { (*count)++; } http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug45614.phpt?view=markup&rev=1.1 Index: php-src/ext/spl/tests/bug45614.phpt +++ php-src/ext/spl/tests/bug45614.phpt --TEST-- SPL: Bug#45614 (ArrayIterator can show 1st private prop of wrapped object) --FILE-- <?php class C { private $priv1 = 'secret1'; private $priv2 = 'secret2'; public $pub1 = 'public1'; public $pub2 = 'public2'; public $pub3 = 'public3'; } function showFirstTwoItems($it) { echo str_replace("\0", '\0', $it->key()) . " => " . $it->current() . "\n"; $it->next(); echo str_replace("\0", '\0', $it->key()) . " => " . $it->current() . "\n"; } $ao = new ArrayObject(new C); $ai = $ao->getIterator(); echo "--> Show the first two items:\n"; showFirstTwoItems($ai); echo "\n--> Rewind and show the first two items:\n"; $ai->rewind(); showFirstTwoItems($ai); echo "\n--> Invalidate current position and show the first two items:\n"; unset($ai[$ai->key()]); $ai->current(); showFirstTwoItems($ai); echo "\n--> Rewind, seek and show the first two items:\n"; $ai->rewind(); $ai->seek(0); showFirstTwoItems($ai); ?> --EXPECT-- --> Show the first two items: pub1 => public1 pub2 => public2 --> Rewind and show the first two items: pub1 => public1 pub2 => public2 --> Invalidate current position and show the first two items: pub1 => public1 pub3 => public3 --> Rewind, seek and show the first two items: pub1 => public1 pub3 => public3 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php