Bug #52163 [Opn->Csd]: SplFileObject::fgetss() fails due to parameter that can't be set
Edit report at http://bugs.php.net/bug.php?id=52163&edit=1
ID: 52163
Updated by: felipe@php.net
Reported by: v-ryanbi at microsoft dot com
Summary: SplFileObject::fgetss() fails due to parameter that
can't be set
-Status: Open
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Windows 7
PHP Version: 5.2.14RC1
-Assigned To:
+Assigned To: felipe
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2010-06-25 01:10:42] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=300741
Log: - Fixed bug #52163 (SplFileObject::fgetss() fails due to parameter
that can't be set) [already fixed on other branches]
------------------------------------------------------------------------
[2010-06-23 21:18:44] v-ryanbi at microsoft dot com
Argh. typo. In the description it should be SplFileObject::fgetss().
------------------------------------------------------------------------
[2010-06-23 21:16:20] v-ryanbi at microsoft dot com
Description:
------------
When calling SplFileObject::ffgetss() in 5.2.x (including the 5.2.14
RC1), a
warning is thrown and the cursor is *not* advanced. Since this would
typically be
used in a while(!$fileObj->eof()) loop, it can result in an infinite
loop.
The complaint thrown in the warning is that the Length parameter must be
greater
than 0. While Length is a valid parameter in the global fgetss function,
the SPL
version of this function only accepts one parameter, and that is for
accepted
tags.
Test script:
---------------
<?php
$str = <<<EOD
<html><body>
<p>Welcome! Today is the <?php echo(date('jS')); ?> of <?=
date('F');
?>.</p>
</body></html>
Text outside of the HTML block.
EOD;
$filePath="filename.php";
file_put_contents($filePath, $str);
$fileObject = new SplFileObject($filePath);
while (!$fileObject->eof()) {
echo $fileObject->fgetss('body');
}
?>
Expected result:
----------------
Welcome! Today is the of .
Text outside of the HTML block.
Actual result:
--------------
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
Warning: fgetss(): Length parameter must be greater than 0 in
C:\fgetssBug\fgetss_basic.php on line 13
... and on to infinity.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52163&edit=1
Thread (3 messages)