salathe Mon, 22 Feb 2010 23:55:30 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295391
Log: Corrected typo in LimitIterator offset exception. Fixes #51119 Bug: http://bugs.php.net/51119 (Open) Incorrect exception message in LimitIterator Changed paths: U php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c A php/php-src/branches/PHP_5_2/ext/spl/tests/bug51119.phpt U php/php-src/branches/PHP_5_2/ext/spl/tests/spl_limit_iterator_check_limits.phpt U php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c A php/php-src/branches/PHP_5_3/ext/spl/tests/bug51119.phpt U php/php-src/branches/PHP_5_3/ext/spl/tests/spl_limit_iterator_check_limits.phpt U php/php-src/trunk/ext/spl/spl_iterators.c A php/php-src/trunk/ext/spl/tests/bug51119.phpt U php/php-src/trunk/ext/spl/tests/spl_limit_iterator_check_limits.phpt Modified: php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c 2010-02-22 23:55:30 UTC (rev 295391) @@ -923,7 +923,7 @@ } if (intern->u.limit.offset < 0) { php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC); + zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0 TSRMLS_CC); return NULL; } if (intern->u.limit.count < 0 && intern->u.limit.count != -1) { Added: php/php-src/branches/PHP_5_2/ext/spl/tests/bug51119.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/spl/tests/bug51119.phpt (rev 0) +++ php/php-src/branches/PHP_5_2/ext/spl/tests/bug51119.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -0,0 +1,34 @@ +--TEST-- +SPL: LimitIterator zero is valid offset +--FILE-- +<?php + +$array = array('a', 'b', 'c'); +$arrayIterator = new ArrayIterator($array); + +try { + $limitIterator = new LimitIterator($arrayIterator, 0); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +try { + $limitIterator = new LimitIterator($arrayIterator, -1); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +?> +===DONE=== +--EXPECT-- +a +b +c +Parameter offset must be >= 0 +===DONE=== Modified: php/php-src/branches/PHP_5_2/ext/spl/tests/spl_limit_iterator_check_limits.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/branches/PHP_5_2/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -32,6 +32,6 @@ ?> ===DONE=== --EXPECTF-- -Parameter offset must be > 0 +Parameter offset must be >= 0 Parameter count must either be -1 or a value greater than or equal 0 ===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c 2010-02-22 23:55:30 UTC (rev 295391) @@ -1272,7 +1272,7 @@ return NULL; } if (intern->u.limit.offset < 0) { - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC); + zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0 TSRMLS_CC); zend_restore_error_handling(&error_handling TSRMLS_CC); return NULL; } Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug51119.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/tests/bug51119.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug51119.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -0,0 +1,34 @@ +--TEST-- +SPL: LimitIterator zero is valid offset +--FILE-- +<?php + +$array = array('a', 'b', 'c'); +$arrayIterator = new ArrayIterator($array); + +try { + $limitIterator = new LimitIterator($arrayIterator, 0); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +try { + $limitIterator = new LimitIterator($arrayIterator, -1); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +?> +===DONE=== +--EXPECT-- +a +b +c +Parameter offset must be >= 0 +===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/spl/tests/spl_limit_iterator_check_limits.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/branches/PHP_5_3/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -32,6 +32,6 @@ ?> ===DONE=== --EXPECTF-- -Parameter offset must be > 0 +Parameter offset must be >= 0 Parameter count must either be -1 or a value greater than or equal 0 ===DONE=== Modified: php/php-src/trunk/ext/spl/spl_iterators.c =================================================================== --- php/php-src/trunk/ext/spl/spl_iterators.c 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/trunk/ext/spl/spl_iterators.c 2010-02-22 23:55:30 UTC (rev 295391) @@ -1321,7 +1321,7 @@ return NULL; } if (intern->u.limit.offset < 0) { - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC); + zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0 TSRMLS_CC); zend_restore_error_handling(&error_handling TSRMLS_CC); return NULL; } Added: php/php-src/trunk/ext/spl/tests/bug51119.phpt =================================================================== --- php/php-src/trunk/ext/spl/tests/bug51119.phpt (rev 0) +++ php/php-src/trunk/ext/spl/tests/bug51119.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -0,0 +1,34 @@ +--TEST-- +SPL: LimitIterator zero is valid offset +--FILE-- +<?php + +$array = array('a', 'b', 'c'); +$arrayIterator = new ArrayIterator($array); + +try { + $limitIterator = new LimitIterator($arrayIterator, 0); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +try { + $limitIterator = new LimitIterator($arrayIterator, -1); + foreach ($limitIterator as $item) { + echo $item . "\n"; + } +} catch (OutOfRangeException $e){ + print $e->getMessage() . "\n"; +} + +?> +===DONE=== +--EXPECT-- +a +b +c +Parameter offset must be >= 0 +===DONE=== Modified: php/php-src/trunk/ext/spl/tests/spl_limit_iterator_check_limits.phpt =================================================================== --- php/php-src/trunk/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:37:47 UTC (rev 295390) +++ php/php-src/trunk/ext/spl/tests/spl_limit_iterator_check_limits.phpt 2010-02-22 23:55:30 UTC (rev 295391) @@ -32,6 +32,6 @@ ?> ===DONE=== --EXPECTF-- -Parameter offset must be > 0 +Parameter offset must be >= 0 Parameter count must either be -1 or a value greater than or equal 0 ===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php