-
Notifications
You must be signed in to change notification settings - Fork 57
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
Match generate and purge actions to CMS behaviours #168
Match generate and purge actions to CMS behaviours #168
Conversation
56b3883
to
1601021
Compare
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 work 👍 Love the cleanup. Left some comments and some nitpicks as well. Noting that some of these are related to existing code which ended up in the change-set due to renaming of files.
e0a589f
to
9dd92ab
Compare
Hi @mfendeksilverstripe hopefully all of your feedback has been actioned. I've also added some docs about migrating from 4. Edited: As per Slack convo, I have undone the removal of the Changes are here: |
9dd92ab
to
0b66f71
Compare
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.
This seems to be a lot of substantial breaking changes to make the day we are schedule to tag a release candidate.
Could we find a way to do them in a backwards compatible way? e.g.: By keeping these methods backwards compatible but marking them as @deprecated
:
getToUpdate()
setToUpdate()
getToDelete()
setToDelete()
Otherwise, could we provide alternative implementations of SiteTreePublishEngine
/PublishableSiteTree
and let people opt-in to using the newer/better behaviour?
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.
This seems to be a lot of substantial breaking changes to make the day we are schedule to tag a release candidate.
Could we find a way to do them in a backwards compatible way? e.g.: By keeping these methods backwards compatible but marking them as @deprecated
:
getToUpdate()
setToUpdate()
getToDelete()
setToDelete()
Otherwise, could we provide alternative implementations of SiteTreePublishEngine
/PublishableSiteTree
and let people opt-in to using the newer/better behaviour?
@chrispenny I think that this PR should be split into smaller chunks. I see several areas that can be actioned separately:
|
@chrispenny Is this something we should also consider for this change? |
@maxime-rainville I think the issue with keeping Before: They would be accessed as part of |
Co-authored-by: Mojmir Fendek <[email protected]>
Co-authored-by: Mojmir Fendek <[email protected]>
Co-authored-by: Mojmir Fendek <[email protected]>
647f49d
to
8ba38e3
Compare
8ba38e3
to
543af36
Compare
@emteknetnz I've resolved the issue you mentioned. Before: After: Arguably - this is actually the "correct" URL for the page, according to Silverstripe, but it's inconsistent with the current behaviour of the module. Solution
Another potential solutionI think this is out of scope for this change set (since it's another change in behaviour), but arguably we probably shouldn't even try to publish a page if Or, perhaps the |
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.
Main thing is changing the word 'include' to 'regenerate' - I found it made the code far more intuitive to read
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Co-authored-by: Steve Boyd <[email protected]>
Thanks for all the feedback, @emteknetnz :) Actioned here (plus many of your commits): |
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.
I'm really not sure what to do here since it's simply not working for me doing manual testing. Possibly and hopefully I'm just doing something very wrong?
My setup is using an install of CMS 5.x-dev silverstripe/recipe-cms + silverstripe/recipe-content-blocks along with this branch of silverstripe/staticpublishqueue
Additional project config is:
---
Name: mystaticpublishqueue
After: '#staticpublishqueue'
---
SilverStripe\StaticPublishQueue\Extension\Publishable\PublishableSiteTree:
regenerate_children: recursive
regenerate_parents: recursive
The following things are not working right:
vendor/bin/sake dev/tasks/SilverStripe-StaticPublishQueue-Task-StaticCacheFullBuildTask
- this create a queuedjob, though when I try and run it via the QueuedJobsAdmin it times out after 30 seconds and logs me out. It did create files in thepublic/cache
directory though. Also experienced this same timeout issue running this on the 6.0.0 branch though?[2023-08-14 13:31:03][ALERT] Fatal Error (E_ERROR): Maximum execution time of 30 seconds exceeded {"code":1,"message":"Maximum execution time of 30 seconds exceeded","file":"/var/www/vendor/silverstripe/framework/src/ORM/FieldType /DBDate.php","line":87,"trace":null} []
Tried reverting framework to 5.0.0, same issue.- Made a child page. Modified URLSegment of parent page. Ran
vendor/bin/sake dev/tasks/ProcessJobQueueChildTask
to process the automatically created jobs. Names of files inpublic/cache
didn't change - Creating StaticCacheFullBuildTask as above though instead this time running
vendor/bin/sake dev/tasks/ProcessJobQueueChildTask
meant it didn't time out, though this time didn't seem to alter anything inpublic/cache
Like I say it seems like I'm doing something very wrong here since I find it hard to believe that things are actually this broken. Am I missing something obvious here?
|
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.
OK got things working at my end. I did some a little testing and found a few bugs, they are sort of existing bugs so possibly we just raise them as new cards and merge this as is, though maybe it makes sense to fix these now
Fresh install of silverstripe/installer 5 + silverstripe/recipe-content-blocks with this PR branch of staticpublishqueue
Using config
SilverStripe\CMS\Model\SiteTree:
regenerate_children: recursive
regenerate_parents: recursive
Scenario 1 (less bad version of existing bug)
- Create page "My page". Publish it. Run queue.
- Add child page to it "My child page". Publish it. Run queue.
- Unpublish "My page". It will also unpublished "My child page". Run queue.
- Error 1 - there is an empty "my-page" folder there (not the end of the word
- (existing behaviour is worse as it still has a cached "my-page/my-child-page)
- Publish "My page". (My child page remains unpublished). Run queue.
- Error 2 - public/cache has "my-page" folder with child "my-child-page" in it (that's a much bigger issue)
Scenario 2 (same as existing behaviour)
- Create page "My page". Publish it. Run queue.
- Add child page to it "My child page". Publish it. Run queue.
- Unpublish "My page". It will also unpublished "My child page". Run queue.
- Publish "My child page", Run queue
- (both /my-page?stage=Live and /my-page?stage=Live and not available on the website)
- Error 3 - public/cache has both "my-page" and "my-page/my-child-page" cached i.e. cache state doesn't match normal website behaviour
@emteknetnz yup, I agree with those bugs - it sounds like you're experiencing what I described here. The behaviour I saw with child pages getting cached (when the parent is unpublished) was at least a cache of a 404 page, and not a cache of the actual content. Here are my thoughts on how we can fix this while maintaining BC: TL;DR: Let's add a config that allows devs to specify response codes that won't have static files generated for them. Everything works as expected with manual testing, the only issue I'm having is with the unit test. I can't figure out why, but no matter how I set the config value in the unit test here, when it gets to the Could you please lend a hand? |
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.
Rather than adding in new config options to exclude 404's in this PR, do this is a separate PR
Revert to 855b70f which was the last green build and we'll just merge this PR with known bugs
Could you please raise new issues cards to fix the observed bugs
This reverts commit 90a22ff.
@emteknetnz reverted the commit and raised an improvement Issue here: I definitely won't argue if we want to call this a bug, but I've initially left that wording out, since caching a |
Steve's review is the up-to-date one
Match generate and purge actions to CMS behaviours
Closes #165, #166, #167
One global change here is that previously we were running
collectChanges()
without forcing any specificVersionedMode
. This causes issues because we are specifically expecting to work withLIVE
records (especially as it relates to finding the URL for pages).Parent page is unpublished
Parent and child page created:
Parent page is unpublished, and so is the child page (automatically by the CMS):
A
DeleteStaticCacheJob
is queued with both the parent and child URLs represented:Page URL has changed
When a page URL changes, that affects the page itself and all of its children. All affected pages must purge the cache records for their old URLs and generate new cache records for their new URLs.
Parent page with original URL Segment:
Updated parent page with new URL Segment:
DeleteStaticCacheJob
created with the old URLs of the parent and child page:GenerateStaticCacheJob
created with the new URLs of the parent and child page:New configuration to control re-cache of parents and children
regenerate_parents
regenerate_children
Both are disabled by default. This is a new major which hasn't had a stable tag yet, so hopefully that's fine.
regenerate_parents
Closes #167
This configuration is valid for both
publish
andunpublish
actions.regenerate_children
Closes #166
Context is import, because sometimes we have to regenerate children regardless of what this configuration says.
Unit tests
A fair few unit tests were using deprecated methods from
getMockBuilder()
. Practically speaking, I think these tests were not actually working.I have revisited a bunch of the tests, and re-written them in a way that I believe is now testing functionality correcty.
Migrating from v4
SiteTreePublishingEngine
changesThe following methods have been removed:
getToUpdate()
setToUpdate()
getToDelete()
setToDelete()
These methods used to deal with
DataObjects
. We are now collecting URLs instead ofDataObjects
, and these URLs arebeing stored and manipulated by the following methods.
getUrlsToUpdate()
addUrlsToUpdate()
setUrlsToUpdate()
getUrlsToDelete()
addUrlsToDelete()
setUrlsToDelete()
Why did this change happen? TL;DR: We realised that purging URLs for pages that change their URL (EG: their parent page
changes, or their
URLSegment
changes) was not functioning as expected. This was really the only way to enable thisfunctionality to work correctly while maintaining cache integrety.