php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68004 SplTempFileObject and LimitIterator don't come along
Submitted: 2014-09-11 09:41 UTC Modified: 2014-09-11 09:46 UTC
From: doldev at snowgarden dot ch Assigned:
Status: Open Package: SPL related
PHP Version: 5.6.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-09-11 09:41 UTC] doldev at snowgarden dot ch
Description:
------------
If SplTempFileObject used with the LimitIterator in some cases it behave wrong.

This might be related to #65600 . Even though if switching to an SplFileObject fixes the problem with the same input.

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

$content = <<<'EOF'
Line 1
Line 2
Line 3
Line 4
EOF;

$tmpCsvFile = new SplTempFileObject();
$tmpCsvFile->fwrite($content);

$iterator = new CallbackFilterIterator($tmpCsvFile, function ($row) {
    return true;
});

echo 'Limit 1: ', iterator_count(new LimitIterator($iterator, 2)), ' ', iterator_count(new LimitIterator($tmpCsvFile, 2)), "\n";
echo 'Limit 2: ', iterator_count(new LimitIterator($iterator, 3)), ' ', iterator_count(new LimitIterator($tmpCsvFile, 3)), "\n";

Expected result:
----------------
Limit 2: 2 2
Limit 3: 1 1

Actual result:
--------------
Limit 2: 2 2
Limit 3: 1 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-11 09:46 UTC] doldev at snowgarden dot ch
Example: http://3v4l.org/AJBR9

Don't worry about the output of HHVM -> it has been fixed recently https://github.com/facebook/hhvm/issues/2993
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 04:01:26 2019 UTC