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

PHP8 READ_AHEAD fix #7

Closed
wants to merge 1 commit into from
Closed

PHP8 READ_AHEAD fix #7

wants to merge 1 commit into from

Conversation

czoIg
Copy link

@czoIg czoIg commented Aug 25, 2021

When $i > 0, $this->file->seek($i) returns false and foreach is never executed.

When $i > 0, $this->file->seek($i) returns false and foreach is never executed.
@@ -200,7 +200,9 @@ public function rewind()
{
$this->file->rewind();
if (null !== $this->headerRowNumber) {
$this->file->seek($this->headerRowNumber + 1);
for ($i = 0; $i <= $this->headerRowNumber; $i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand we could simplify the code here based on the PHP issue here: php/php-src#6434

the following should work too:

$this->file->seek($this->headerRowNumber);
$this->file->next();

What do you think @czoIg and @ddeboer ?

I have also created once a patch here: https://github.com/Comvation/csv/tree/fix-php8-csvreader-seek

@ddeboer
Copy link
Member

ddeboer commented Mar 6, 2022

Closing this because it seems this bug was fixed in PHP 8.0.1, so making the change here shouldn’t be necessary. Thanks for your effort!

@ddeboer ddeboer closed this Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants