Hello!
I have a strange problem with the "delete" method of the "pages" API-variable: When I insert a parent- and a child-page, and then immediately try to delete first the child- and then the parent-page, an exception is thrown telling me that the parent cannot be deleted, because it still contains a child-page.
You can reproduce this behaviour using the following code:
<?php
require 'index.php';
$parentPage = new ProcessWire\Page;
$parentPage->name = 'parent';
$parentPage->template = 'basic-page';
$parentPage->title = 'parent';
$parentPage->parent = $pages->get('/');
$parentPage->save();
$childPage = new ProcessWire\Page;
$childPage->name = 'child';
$childPage->template = 'basic-page';
$childPage->title = 'child';
$childPage->parent = $pages->get('/parent');
$childPage->save();
$pages->delete($pages->get('/parent/child'));
$pages->delete($pages->get('/parent'));
(I put this code into a file called "experiments.php" in the root directory of the site, because I do not know of any better way for quickly testing out code in ProcessWire yet)
Can you tell me why this code throws an exception?
What am I missing?
I am using ProcessWire 3.
Thanks for your help!
PS: Yes, I know about the second parameter in the "$pages->delete" method, but it should not be necessary to be set in this scenario if I`m correct.