silverstripe-blog
silverstripe-blog copied to clipboard
FIX BlogPost::onBeforePublish() should also trigger parent::onBeforePublish() if exists
e.g. if Page::onBeforePublish() exists.
This won't work if the parent class has the method added via an extension.
@dhensby Versioned::publishSingle()
calls invokeWithExtensions()
so if onBeforePublish()
is added via a DataExtension
this should still be triggered, no?
Would it? It would see that it exists on BlogPost
and so will invoke it there and that would be it... right? If you also added an extension to the parent or to BlogPost
would that not be ignored?
Not as far as I understand and have tested
Setup as follows:
- Page has onBeforePublish() method + DataExtension with onBeforePublish method
- SubPage has onBeforePublish() method + DataExtension with onBeforePublish method
results in the following execution order
- Page::onBeforePublish()
- SubPage::onBeforePublish()
- DataExtension::onBeforePublish() (SubPage as $owner)
Prior to this change:
- SubPage::onBeforePublish()
- DataExtension::onBeforePublish() (SubPage as $owner)
Note: DataExtension::onBeforePublish()
only triggers on SubPage
even though it's applied to both SubPage
and Page
. Is that supposed to be the case?
Edit: here's a link through to invokeWithExtensions incase you want to take a look through too - https://github.com/silverstripe/silverstripe-framework/blob/dcdc25500be729f4340d42f8a4fc797461f862f3/src/Core/Extensible.php#L401-L427