Skip to content

Conversation

@atm-lucasmantegari
Copy link
Contributor

FIX - $error is never set

The error variable is never set, so if it is filled during recursive creation, the error always remains set.

$this->output = trim($this->output);

return $error ? $error : 0;
return count($this->errors);
Copy link
Member

Choose a reason for hiding this comment

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

this->errors may not be always set, sometimes it is ->error that is set only.

If you move $error = 0; before the loop, is it ok ?

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Apr 9, 2025
@frederic34
Copy link
Member

image
it is already set ?

@eldy
Copy link
Member

eldy commented Apr 10, 2025

image it is already set ?

True, so i don't see in which case this change fix something.
If this->errors is set, $error should also be set.

@atm-lucasmantegari
Copy link
Contributor Author

The problem is that it's outside the loop. Because it's never reset when I loop, so if I have 50 invoices and an error occurs at invoice 2, the other 48 invoices will have the same $error.

@eldy
Copy link
Member

eldy commented Apr 12, 2025

The problem is that it's outside the loop. Because it's never reset when I loop, so if I have 50 invoices and an error occurs at invoice 2, the other 48 invoices will have the same $error.

Because, there is only 1 error code return, for 50 invoices, the error code is global and mean "there is ate least one error".
So currently the return is the number of invoice in error only.

The problem is that we used it also inside the loop to track error on the current processed invoice. 2 need but 1 variable. This is the trouble. So inside the loop, we should use another error code for the given current processed invoice. On other part of code, we are using a variable $errorforline or $errorforinvoice. So i pushed a fix using this method.

@eldy eldy closed this in 0b8324f Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Discussion Some questions or discussions are opened and wait answers of author or other people to be processed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants