-
Notifications
You must be signed in to change notification settings - Fork 116
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
fix: getPage returning the wrong page #1082
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.
Changing the key used in cacheData
could break customisations in subclasses which fetch or set data into cacheData
, since it's not a private property.
Is there a sensible way to bust the cache instead? e.g. in onBeforeWrite()
, or - if you want to call getPage()
before writing for some reason, check if $this->isChanged('PageID')
and don't use the cached data if it has been changed?
This also seems like a good candidate for a unit test to avoid regressions.
@GuySartorelli Updated to use isChanged() now and added a unit test. |
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.
Ideally the unit test would also test the caching functionality - but given that functionality was already there it wouldn't be reasonable to ask for this PR to introduce that test coverage. I'm okay with this as is.
Looks good, will merge when CI goes green. Thanks for submitting this.
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.
CI is unhappy - please fix the test.
CI is still unhappy here. Can you please resolve that? |
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.
There are, again, a lot of unrelated changes in this PR related to formatting.
I am going to ask you, again, that in future pull requests you either don't commit those changes, or you include them in a separate commit. I'm going to start asking you to make those changes before merging PRs if you continue to ignore that request. You can leave it as is for this one though.
Updated to use isChanged() now and added a unit test.
This doesn't seem to be the case... did you change it again since then? If so, can you please explain why? Using isChanged()
seems like the perfect solution here instead of adding more info into cacheData.
Hi @GuySartorelli isChanged() doesn't work as it was cleared when calling onBeforeWrite() so I reverted back (but to a new value to keep your original comment in mind). What we were seeing
As $element->isChanged('ParentID') == false. We could clear the cache data onBeforeWrite but that seemed like leaking things outside of that method. Sorry! Editor being all auto-magic fix. I'll turn it off |
Thanks for that context. In that case, I think this is good as is. Once CI has gone green on this latest push I'll approve and merge.
You can keep it on if you like, so long as any changes it makes are in a separate commit (e.g. save the page without making your changes, and if there's a change caused by your IDE, commit that result first and then make your PR changes) - though I could see that workflow being a pain to remember to do, especially if it differs from your regular workflow. |
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.
Looks great, thanks!
Hi @GuySartorelli. Hi @wilr. This issue also exists v4. Is it possible to backport this patch commit to this version as well? Thanks |
@rasstislav Absolutely. |
@GuySartorelli ready, thanks :) |
If you programaticaly update the ParentID of an element, getPage() still returns the outdated page.