Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplFileObject::seek broken in PHP7.2.x #279

Closed
nyamsprod opened this issue Feb 5, 2018 · 2 comments
Closed

SplFileObject::seek broken in PHP7.2.x #279

nyamsprod opened this issue Feb 5, 2018 · 2 comments
Assignees
Labels

Comments

@nyamsprod
Copy link
Member

https://3v4l.org/tL8n9

This bug is reported to PHP bug system https://bugs.php.net/bug.php?id=75917&edit=2

A workaround should be made available in the Reader class to keep setHeader work as intended

    protected function setHeader(int $offset): array
    {
        $this->document->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY);
        $this->document->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
        $this->document->seek($offset);
        //THIS NO LONGER WORKS
        if (empty($header = $this->document->current())) {
            throw new Exception(sprintf('The header record does not exist or is empty at offset: `%s`', $offset));
        }

        if (0 === $offset) {
            return $this->removeBOM($header, mb_strlen($this->getInputBOM()), $this->enclosure);
        }

        return $header;
    }
@nyamsprod nyamsprod added the bug label Feb 5, 2018
@nyamsprod nyamsprod self-assigned this Feb 5, 2018
nyamsprod added a commit that referenced this issue Feb 5, 2018
@nyamsprod
Copy link
Member Author

using LimitIterator does not work as it uses the broken seek method.

@nyamsprod
Copy link
Member Author

patch landed on master...

nyamsprod added a commit that referenced this issue Feb 5, 2018
nyamsprod added a commit that referenced this issue Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant