Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Fix error component by adding name check#1356

Merged
calebporzio merged 1 commit intomainfromjosh/fix-error-component
Mar 20, 2025

Conversation

joshhanley
Copy link
Member

The scenario

With the recent changes to error component to support nesting#1308, occasionally there can be an issue if$errors->first() is called in a test, as it throws anUndefined variable $errors error. This recently caused a breaking change for someone.

image

The problem

The issue is actually an underlying Laravel issue where for some reason if a view is manually rendered in a test, it has no idea that the$errors variable should exist and throws an error.https://laracasts.com/discuss/channels/testing/undefined-variable-errors-when-testing-a-view

By itself, this shouldn't cause issues for us, but with the recent change to the errors component, this error is now being throws in a users app.

The reason why it wasn't being thrown before, is because we only had the below code.

$message ??=$name ?$errors->first($name) :null;

You can see here that if no$name prop is provided, it will never call the$errors->first().

But we recently just added the below, which is causing$errors->first() to always be called, hence is throwing the error.

if ((is_null($message) ||$message ==='') &&filter_var($nested,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !==false) {$message =$errors->first($name .'.*');}

The solution

The easy win solution is to just update the conditional to also check for a name. So that's what has been done in this PR.

if ($name && (is_null($message) ||$message ==='') &&filter_var($nested,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !==false) {$message =$errors->first($name .'.*');}

Fixes#1330

@calebporziocalebporzio merged commitf5b7169 intomainMar 20, 2025
@joshhanleyjoshhanley deleted the josh/fix-error-component branchMarch 24, 2025 00:16
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
2 participants
@joshhanley@calebporzio

[8]ページ先頭

©2009-2025 Movatter.jp