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
Possible bug on model Accessors on new release #43735
Comments
@caiokawasaki What is the value of |
@morloderex the relation is being eagger loadded, isn't it strange that I can access the relation only inside the Attribute function? |
I think we need more context here. Like a full route example that is broken. |
@driesvints pointed out this PR: #43554 But, it's not clear to me atm how that PR would cause the behavior you describe. |
I wonder if this is related #42537 in my testing there is something funny going with with object caching |
@serpentblade any ideas here? If we can't figure this one out it's probably best that we revert your PR. |
@caiokawasaki could you dump your WHOLE model in a gist, please? |
My PR was related to casts. The major change was the inclusion of the new casts cache to reduce repeated calls to cast type name conversions. However, that's not to say it can't somehow be involved. A stack trace for the error would be helpful to understand the full context of when the accessor is being called in the model's lifecycle. There are a number of places where the accessor method is called and getting a full trace would help identify which path is the problem. IMO, the "working" code identified in the original post is the correct way to implement attribute accessors, as you want the evaluation of the accessor to occur when Attribute::get() is called and NOT when the Attribute accessor is first defined. @caiokawasaki were any other packages besides laravel/framework updated at the same time? |
I also fail to see how the casts PR would have any effect on this, I'm also enclined to say that it may be another package update. Where is this It does seem to be a similar issue as #42537 because OP is using |
@caiokawasaki can you please provide a repo that reproduces this? laravel new bug-report --github="--public" |
Sorry for the delay, I ended up running out of internet in the last few days, I'll provide a repository with the problem described, in a few minutes I'll send the repository here. |
https://github.com/caiokawasaki/laravel-bug-report I recreated the code in a new repository, added all the dependencies from the original project and still didn't get the problem, I'll dig deeper to try to find out what might be going on in my project. |
Feel free to provide a repo once you managed to recreate it 👍 |
Description:
Today I ran
composer update
in my application, the Framework version got updated to9.25.1
, the previous version was9.23.0
.This was working before on version
9.23.0
:I got this in the log after the update:
I didn't understand why this was happening and it took me a while to find the problem.
However, if I change the accessor to the following everything works normally:
On version
9.25.1
this accessor is not working, looks like the acessor can't access relations outside thereturn new Attribute
function, is this right? Or is it a bug?The text was updated successfully, but these errors were encountered: