-
-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Milestone
Description
Describe the bug
Trying to programmatically delete subpage drafts within a page.changeStatus:after hook, throws the following error: SyntaxError: Unexpected token T in JSON at position 0
3/5 pages get deleted, 2/5 (identical) don’t.
Here is the config.php
'page.changeStatus:after' => function ($newPage, $oldPage) {
if($newPage->intendedTemplate() == 'project' && $newPage->status() == 'unlisted') {
foreach($newPage->drafts() as $phase) {
try {
$phase->delete();
echo 'The page has been deleted';
} catch(Exception $e) {
echo $e->getMessage();
}
}
}
}
To Reproduce
Steps to reproduce the behavior:
- Add subpages to parent page
- Change status from
listedtounlistedfor parent page through the panel - See error
Expected behavior
All pages should be deleted.
Kirby Version
3.0.0-beta-6.22
Desktop (please complete the following information):
- OS: OSX
- Browser Chrome
- Version 70
Metadata
Metadata
Assignees
Labels
No labels