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

[9.x] Adds handlers for silently discarded and missing attribute violations #44664

Merged
merged 3 commits into from
Oct 20, 2022

Conversation

aarondfrancis
Copy link
Contributor

This PR adds the ability to register handlers for two of the strict mode violations: silently discarded and missing attributes.

This ability is currently available for only the lazy load violations, this PR basically replicates that behavior for the other 2/3rds of Eloquent's new strict mode.

I think this will make it easier to adopt strict mode, as people can enable strict mode in production, but instead of throwing violations, they can log them.

@deKuddus
Copy link

@aarondfrancis, maybe this is going to be a good feature but did you see that a lots of changes are showing just due to changes of a single space. I think it was happened due to IDE configuration, so that this type of unnecessary changes are showing. Could you please recheck the changes again please??

@aarondfrancis
Copy link
Contributor Author

Fixed. I kinda thought that would happen automatically, which is why I left it. Thanks @deKuddus.

And thanks to @timacdonald for this incredible tip on how to fix this!

* @param callable|null $callback
* @return void
*/
public static function handleDiscardedAttributeViolationUsing(?callable $callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey
What scenario users might be required to call handleDiscardedAttributeViolationUsing(null); ?
Same for handleMissingAttributeViolationUsing(null) case.

Copy link
Contributor

Choose a reason for hiding this comment

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

My first thought would be during tests, to either enable or disable it dynamically. Not sure if that was the intended use-case.

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.

5 participants