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

Failing test for prepareForValidation not called with SkipsEmptyRows #3573

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Failing test for prepareForValidation not called with SkipsEmptyRows #3573

merged 3 commits into from
Mar 10, 2022

Conversation

VFAndrew
Copy link
Contributor

@VFAndrew VFAndrew commented Mar 8, 2022

1️⃣ Why should it be added? What are the benefits of this change?
Failing test requested so bug may be fixed. #3324 (comment)

2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No

3️⃣ Does it include tests, if possible?
Yes

4️⃣ Any drawbacks? Possible breaking changes?
No

5️⃣ Mark the following tasks as done:

  • [ x ] Checked the codebase to ensure that your feature doesn't already exist.
  • [ x ] Take note of the contributing guidelines.
  • [ x ] Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • [ x ] Added tests to ensure against regression.
  • [ x ] Updated the changelog

6️⃣ Thanks for contributing! 🙌

@VFAndrew
Copy link
Contributor Author

VFAndrew commented Mar 9, 2022

It appears the issue is with line 294 of Sheet.php.

if (!$import instanceof SkipsEmptyRows || ($import instanceof SkipsEmptyRows && !$sheetRow->isEmpty($calculatesFormulas)))

when it checks if the row is empty the row toArray() sets the row->rowCache then on line 298 when toArray() is called again for validation preparation.

$toValidate = [$sheetRow->getIndex() => $sheetRow->toArray(null, $import instanceof WithCalculatedFormulas, $import instanceof WithFormatData, $endColumn)];

the row toArray() checks for the rowCache and returns immediately on line 75 of Row.php without preparingForValidation on line 94

@VFAndrew
Copy link
Contributor Author

VFAndrew commented Mar 9, 2022

In my opinion the best solution would be to set the preparationCallback on the sheetRow before the empty row is checked for on line 294

I have a branch I can PR if desired. https://github.com/VFAndrew/Laravel-Excel/tree/bug-fix/preparevalidation-not-called-with-skips-empty-rows

@patrickbrouwers
Copy link
Member

@VFAndrew this setPreparationCallback was PR'd by someone else, so I'm not 100% sure, but it seems logical as you suggest. You can PR it.

@VFAndrew
Copy link
Contributor Author

VFAndrew commented Mar 9, 2022

@VFAndrew this setPreparationCallback was PR'd by someone else, so I'm not 100% sure, but it seems logical as you suggest. You can PR it.

@patrickbrouwers Should I just update this PR with the fix?

@patrickbrouwers
Copy link
Member

@VFAndrew yes that is fine!

@patrickbrouwers patrickbrouwers merged commit 215595d into SpartnerNL:3.1 Mar 10, 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
Development

Successfully merging this pull request may close these issues.

2 participants