#51119 [Opn]: Incorrect exception message in FilterIterator
| From: | salathe@php.net | Date: | Mon, 22 Feb 2010 21:26:36 +0000 |
| Subject: | #51119 [Opn]: Incorrect exception message in FilterIterator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-147964@lists.php.net to get a copy of this message | ||
ID: 51119
Updated by: salathe@php.net
Reported By: salathe@php.net
Status: Open
Bug Type: SPL related
Operating System: OS X
PHP Version: 5.3.2RC2
New Comment:
The tiny, tiny patch (against trunk) would be:
Index: spl_iterators.c
===================================================================
--- spl_iterators.c (revision 295379)
+++ spl_iterators.c (working copy)
@@ -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;
}
Previous Comments:
------------------------------------------------------------------------
[2010-02-22 21:24:28] salathe@php.net
Description:
------------
The lower bound of the offset parameter for the FilterIterator is zero
(no offset). When an offset less than zero is given, an
OutOfBoundsException is thrown, incorrectly stating, "Parameter offset
must be > 0".
Reproduce code:
---------------
<?php
$ait = new ArrayIterator(array('a', 'b', 'c'));
try {
$lit = new LimitIterator($ait, 0);
echo "OK\n";
} catch (OutOfRangeException $e) {
echo $e->getMessage() . "\n";
}
try {
$lit = new LimitIterator($ait, -1);
echo "OK\n";
} catch (OutOfRangeException $e) {
echo $e->getMessage() . "\n";
}
Expected result:
----------------
OK
Parameter offset must be >= 0
Actual result:
--------------
OK
Parameter offset must be > 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=51119&edit=1