Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
be0895b
Match generate and purge actions to CMS behaviours
chrispenny Apr 3, 2023
f557ede
Add test for parent change
chrispenny Apr 3, 2023
db03620
Fix for ParentID being (string)
chrispenny Apr 3, 2023
2e9a93b
Update tests/php/Extension/Engine/SiteTreePublishingEngineTest.php
chrispenny Apr 4, 2023
4520f7b
Update tests/php/Extension/Publishable/PublishableSiteTreeTest.php
chrispenny Apr 4, 2023
03cd466
Update tests/php/Extension/Engine/SiteTreePublishingEngineTest.yml
chrispenny Apr 4, 2023
e98f41f
Peer review feedback
chrispenny Apr 4, 2023
d839ad4
Linting
chrispenny Apr 4, 2023
543af36
Remove public API changes from changeset
chrispenny May 1, 2023
a40d406
Update default config for recaching parent (match BC)
chrispenny May 1, 2023
28653bd
Update README.md
chrispenny May 1, 2023
9963dfa
Add correct deprecation notices
chrispenny May 1, 2023
fca606d
Update method visibility to private
chrispenny Jul 23, 2023
ce16f1b
Update some code comments
chrispenny Aug 1, 2023
f691555
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 6, 2023
7c7bb0f
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 6, 2023
1aa7fd7
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 6, 2023
ab115e7
Update config values from int to descriptive strings
chrispenny Aug 6, 2023
d29637a
Add new configuration to docs
chrispenny Aug 6, 2023
07de868
added ability for collectChanges to run in DRAFT or LIVE stage
chrispenny Aug 6, 2023
d9e2848
Update collectChanges to maintain BC
chrispenny Aug 6, 2023
74cde55
Update src/Service/UrlBundleService.php
chrispenny Aug 10, 2023
902ee22
Update src/Job/DeleteStaticCacheJob.php
chrispenny Aug 10, 2023
aa84f4c
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 10, 2023
657c721
Update src/Extension/Engine/SiteTreePublishingEngine.php
chrispenny Aug 10, 2023
dc64e8d
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 10, 2023
dca9eb9
Update src/Extension/Publishable/PublishableSiteTree.php
chrispenny Aug 10, 2023
e5d596b
Update const and variable names. strip_stage_param default to false
chrispenny Aug 10, 2023
03e39be
Update docs/en/basic_configuration.md
chrispenny Aug 10, 2023
855b70f
Update documentation
chrispenny Aug 14, 2023
90a22ff
Add config to exclude certain response codes (broken unit test)
chrispenny Aug 15, 2023
f4afd32
Revert "Add config to exclude certain response codes (broken unit test)"
chrispenny Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ It generates the cache files using the [QueuedJobs module](https://github.com/sy

[Docs](docs/en/index.md)


## Unit-testing with StaticPublisherState to disable queuedjobs for unit-tests

You can use `StaticPublisherState` to disable queuejobs job queueing and logging in unit-testing to improve performance.
Expand All @@ -26,15 +27,15 @@ Add the following yml to your project:

```yml
----
-Name: staticpublishqueue-tests
-Only:
- classexists:
- - 'Symbiote\QueuedJobs\Tests\QueuedJobsTest\QueuedJobsTest_Handler'
- - 'SilverStripe\StaticPublishQueue\Test\QueuedJobsTestService'
Name: staticpublishqueue-tests
Only:
classexists:
- 'Symbiote\QueuedJobs\Tests\QueuedJobsTest\QueuedJobsTest_Handler'
- 'SilverStripe\StaticPublishQueue\Test\QueuedJobsTestService'
----
-SilverStripe\Core\Injector\Injector:
- SilverStripe\Dev\State\SapphireTestState:
- properties:
- States:
- staticPublisherState: '%$SilverStripe\StaticPublishQueue\Dev\StaticPublisherState'
SilverStripe\Core\Injector\Injector:
SilverStripe\Dev\State\SapphireTestState:
properties:
States:
staticPublisherState: '%$SilverStripe\StaticPublishQueue\Dev\StaticPublisherState'
```
1 change: 1 addition & 0 deletions _config/staticpublishqueue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SilverStripe\Core\Injector\Injector:
class: SilverStripe\StaticPublishQueue\Publisher\FilesystemPublisher
SilverStripe\StaticPublishQueue\Service\UrlBundleInterface:
class: SilverStripe\StaticPublishQueue\Service\UrlBundleService

SilverStripe\CMS\Model\SiteTree:
extensions:
- SilverStripe\StaticPublishQueue\Extension\Engine\SiteTreePublishingEngine
Expand Down
26 changes: 23 additions & 3 deletions docs/en/basic_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ class MyFormPage extends Page
}
```

## Control when child/parent pages are included in cache actions

There are two configurations available, and they can both be set to one of three available values:

* `regenerate_children`
chrispenny marked this conversation as resolved.
Show resolved Hide resolved
* `none`: Do not include any children
* `direct`: Include only one level below (direct children, but not grandchildren, etc)
* `recursive`: Include all children recursively (grandchildren, great-gc, etc)
* `regenerate_parents`
* `none`: Do not include any parents
* `direct`: Include only one level above (the direct parent)
* `recursive`: Include all parents recursively (up to the top of the SiteTree)
chrispenny marked this conversation as resolved.
Show resolved Hide resolved

**Please note:** There are times when these configurations are ignored. For example, if you use Silverstripe's default
behaviour and have `SiteTree::enforce_strict_hierarchy = true`, then this means that parent pages must be published for
anyone to be able to view child pages. If you were to unpublish a parent page in the CMS, then default CMS behaviour
would be for all child pages to also become unavailable to your users. As such, if you unpublish a page, then regardless
of what your `regenerate_children` configuration is, we will always remove the cache of all of the child pages - as this
matches the behaviour that the CMS follows.

## Available interfaces

This module comes with two essential interfaces: `StaticPublishingTrigger` and `StaticallyPublishable`. This interfaces
Expand Down Expand Up @@ -89,15 +109,15 @@ use Page;
use SilverStripe\ORM\DataObject;
use SilverStripe\StaticPublishQueue\Contract\StaticPublishingTrigger;

class YourDataObject extends DataObject implements StaticPublishingTrigger
class YourDataObject extends DataObject implements StaticPublishingTrigger
{

public function objectsToUpdate($context)
public function objectsToUpdate($context)
{
return Page::get()->First(); // return 1 or an array of multiple publishable objects you would like to regenerate the static cache for
}

public function objectsToDelete($context)
public function objectsToDelete($context)
{
// Return 1 or an array of of publishable objects for which you would like to purge the statically cached variant
}
Expand Down
6 changes: 2 additions & 4 deletions src/Contract/StaticPublishingTrigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ interface StaticPublishingTrigger
* Provides an SS_List of StaticallyPublishable objects which need to be regenerated.
*
* @param array $context An associative array with extra engine-specific information.
*
* @return SS_List
* @return array|SS_List
*/
public function objectsToUpdate($context);

/**
* Provides a SS_list of objects that need to be deleted.
*
* @param array $context An associative array with extra engine-specific information.
*
* @return SS_List
* @return array|SS_List
*/
public function objectsToDelete($context);
}
Loading