From: Operating system: Windows 7 PHP version: 5.2.14RC1 Package: SPL related Bug Type: Bug Bug description:fails due to parameter that can't be set
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 bug report at http://bugs.php.net/bug.php?id=52163&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52163&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52163&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52163&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52163&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52163&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52163&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52163&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52163&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52163&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52163&r=support Expected behavior: http://bugs.php.net/fix.php?id=52163&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52163&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52163&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52163&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52163&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52163&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52163&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52163&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52163&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52163&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52163&r=mysqlcfg