-
-
Notifications
You must be signed in to change notification settings - Fork 540
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
[4.x] Add isDirty
/ isClean
#5502
[4.x] Add isDirty
/ isClean
#5502
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.
Nice. Although the toCacheableArray
method is never used, I think that's a leftover relic from v2. I'm going to sneak the removal of it into 3.3, and you can make your own dedicated method in this PR.
No problem - I've updated that method to be called Also separated out a separate |
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.
In other classes, for example, Asset
, we already have the concept of "original" data. I'd want to use that here. There's a trait, etc.
Yep I can see the syncOriginal function - see how I've updated to look for |
That would need to go in the Stache where it initially makes an instance from the file. Right about here: |
Thank you! Thats updated now - let me know what you think. |
Not sure why tests are failing on this (and they seem unrelated to the changes made). They are all passing for me locally. |
@jasonvarga Struggling a bit with the tests on this one. On the two asset failures, do I just update the tests to expect the .meta files? Or do I handle it some other way? |
Make sure .meta is not generated by calling ->data() before it exists
I've got all tests passing locally now, but I cant get them working here in GitHub actions. If you can see why that would be really helpful. |
0dbbf73
to
ca783d6
Compare
Thanks for this PR. Another banger. And sorry for the delay, it's pretty substantial. I made a handful of changes:
Some additional notes:
|
Thanks for all the changes. As always you’ve made it much better. |
…tchell/cms into feature/is-dirty-is-clean
isDirty
/ isClean
isDirty
/ isClean
❤️ |
KA |
Thanks for this PR, it will be massively helpful. Not sure where to ask so I'll try here! This breaks some tests for an addon of mine and I am struggling to understand why. For example this test: https://github.com/reachweb/locale-lander/blob/main/tests/Feature/LocaleLanderTest.php#L61 works fine if I remove the It seems that when using the trait, when checking for the translation here: https://github.com/reachweb/locale-lander/blob/main/src/Support/LocaleHelper.php#L63 it will return null. To make matters even worse, if I run the test 10 times, it will find the Entry 2 times out of 10 (or something like that). Any ideas on what causes this and how to fix the tests? Note that this only affects the test environment, the addon works fine in the actually Statamic install. |
@afonic I haven't dug into it but could your issue be related to #9651? If not, maybe start a new Discussion? (to avoid everyone in this PR being notified of any comments 😄 ) |
This PR adds a trait for isDirty() / isClean() support on Entries through the use of a trait. I set it up this way to allow it to be extended to other stores if the approach is felt to be correct.
Tests are failing as the test environment doesn't seem to like using
$entry->fresh()
- not sure how to get around that!You can use the functions as follows:
Closes statamic/ideas#7