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

[Bug]: SkipsFailures doesn't seem to work with WithChunkReading #4150

Open
1 task done
jargoud opened this issue Jun 14, 2024 · 0 comments
Open
1 task done

[Bug]: SkipsFailures doesn't seem to work with WithChunkReading #4150

jargoud opened this issue Jun 14, 2024 · 0 comments
Labels

Comments

@jargoud
Copy link

jargoud commented Jun 14, 2024

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.55

What version of Laravel are you using?

10.48.7

What version of PHP are you using?

8.3.8

Describe your issue

When using both SkipsFailures trait and WithChunkReading interface, it seems that only the chunk import instance failures collection is populated, not the original import one, which means it isn't possible to execute a code similar to the one from the documentation:

$import = new UsersImport();
$import->import('users.xlsx');

foreach ($import->failures() as $failure) {
     $failure->row(); // row that went wrong
     $failure->attribute(); // either heading key (if using heading row concern) or column index
     $failure->errors(); // Actual error messages from Laravel validator
     $failure->values(); // The values of the row that has failed.
}

In the above example, $import->failures() will always be empty.

How can the issue be reproduced?

class MyImport implements SkipsOnFailure, WithChunkReading, WithValidation
{
    use SkipsFailures;

    public function rules(): array
    {
        return [
            ['required', 'numeric'],
        ];
    }

    public function chunkSize(): int
    {
        return 100;
    }
}

What should be the expected behaviour?

It'd be great to have a way to populate failures in the import instance.

@jargoud jargoud added the bug label Jun 14, 2024
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