From:             
Operating system: Fedora 16
PHP version:      5.3.10
Package:          SPL related
Bug Type:         Bug
Bug description:False value for blank last line with SKIP_EMPTY 
andDROP_NEW_LINE 

Description:
------------
Suddenly, using SplFileObject::SKIP_EMPTY and SplFileObject::DROP_NEW_LINE
no longer ignores a final blank line in a file. Instead, when iterating
over the file object, the last value is boolean false. This appears to have
changed between 5.3.8 and 5.3.9 and persists in 5.3.10.

Test script:
---------------
<?php

$filename = "/tmp/test-file.txt";

file_put_contents($filename, "non-blank line1" . PHP_EOL);
file_put_contents($filename, "non-blank line2" . PHP_EOL, FILE_APPEND);

$TheFile = new SplFileObject($filename, "r");
$TheFile->setFlags( SplFileObject::SKIP_EMPTY |
SplFileObject::DROP_NEW_LINE );

foreach ($TheFile as $line) {
    print "Currently on key " . $TheFile->key() . ": " . PHP_EOL;
    var_dump($line);
}


Expected result:
----------------
Currently on key 0: 
string(15) "non-blank line1"
Currently on key 1: 
string(15) "non-blank line2"


Actual result:
--------------
Currently on key 0: 
string(15) "non-blank line1"
Currently on key 1: 
string(15) "non-blank line2"
Currently on key 2: 
bool(false)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=61032&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61032&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61032&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61032&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61032&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61032&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61032&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61032&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61032&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61032&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61032&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61032&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61032&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61032&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61032&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61032&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61032&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61032&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61032&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61032&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61032&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61032&r=mysqlcfg

Reply via email to