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
Log only dirty fields doesn't behave as expected when used with scope #513
Comments
Hey, I would like to reproduce it in a unittest and after this try to solve the issue. |
I am using these settings: protected static $logOnlyDirty = true;
protected static $logUnguarded = true; I think the problem is with the |
Hey @Gummibeer, were you able to reproduce the problem? |
@istiak-tridip sorry, not yet and I have a lot of tasks for the next two weeks. I will pass the ball to @spatie team. I hope you understand it - for sure feel free to fix it yourself and send a PR. |
Please provide a steps to reproduce this error... cant manage to reproduce it! |
@istiak-tridip in best case a PR with a failing Testcase. This way we have a real goal and way to check if we've solved it. |
Thanks for the quick response and the PR. I'm currently working on solving this but since I'm kinda new to the codebase I wish that you enlighten me more about why we use DetectsCahnges.php:97 $properties['attributes'] = static::logChanges(
$processingEvent == 'retrieved'
? $this
: (
$this->exists
? $this->fresh() ?? $this
: $this
)
) @Gummibeer, if you can spare a minute it would be kind if you explained above piece of code. |
Answer: this is one of the oldest parts of this package - sometimes re-arranged but never changed. Personally I've never used attribute subsets on model queries and primary not for manipulating the model instance. The only way I could think about to solve this would be to access, if available, the attribute subset of the original |
I tend to agree more with @Gummibeer since I spent more than 5 hours across multiple days fiddling around with this issue. I tried to remove $properties['attributes'] = static::logChanges(
$processingEvent == 'retrieved'
? $this
: (
$this->exists
? $this->fresh() ?? $this
: $this
)
) and replace it with $properties['attributes'] = static::logChanges(
$this
)
) 8 test have failed, the common failure between them was that the package was relaying on I think this is an edge case that only 1% of people will fall into because local scopes isn't designed to handle filtering columns on the query. Plus Laravel doesnt support passing scopes nor selected attributes to the fresh method, based on Mohamed Said's response on this issue on laravel repo.
Based on all of the above, we may close this issue considering it an edge case that will probably wont affect users who use scopes as they intended. (no offence @istiak-tridip 😄). |
I agree with you, @nagi1. You guys can go ahead and close this at your convenience. |
@nagi1 THANKS A LOT for your work on this! 🤩🥳 You did a great job in verifying my opinion.^^ |
I'm updating a video status by using this code
In the
properties
column of theactivity_log
table I'm getting thisinstead of expected
If I remove the
scopeIdentifier
it works expectedly.I'm using:
The text was updated successfully, but these errors were encountered: