-
Notifications
You must be signed in to change notification settings - Fork 132
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
fix: Call to a member function getErrors() on null in CheckQueryReturnTrait #1088
fix: Call to a member function getErrors() on null in CheckQueryReturnTrait #1088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kenjis How about this?
protected function checkValidationError(): void
{
$validationErrors = $this->validation?->getErrors();
if ($validationErrors !== [] && $validationErrors !== null) {
$message = 'Validation error:';
foreach ($validationErrors as $field => $error) {
$message .= ' [' . $field . '] ' . $error;
}
throw new ValidationException($message);
}
}
01d781b
to
27a017d
Compare
@datamweb Ah, if |
Line 28 in 0894a16
|
Since CI 4.5.0, $this->validation may be null.
bb27508
to
35bbb77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the code is more readable.
Wait for a new version of Shield to be released, or temporarily use the develop branch: composer require codeigniter4/shield:dev-develop |
Thanks for this! |
Description
Fixes #1087
Since CI 4.5.0,
$this->validation
may be null.Checklist: