Skip to content

Commit

Permalink
Restore changes made by #3023
Browse files Browse the repository at this point in the history
  • Loading branch information
andris-sevcenko committed Aug 31, 2018
1 parent fc7cc49 commit 191473d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/services/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,16 @@ public function handleDeletedSection(ParseConfigEvent $event)
}

// Delete the entries
$entries = Entry::find()
$entryQuery = Entry::find()
->status(null)
->enabledForSite(false)
->sectionId($sectionRecord->id)
->all();
->sectionId($sectionRecord->id);

foreach ($entries as $entry) {
Craft::$app->getElements()->deleteElement($entry);
$elementsService = Craft::$app->getElements();
foreach (Craft::$app->getSites()->getAllSiteIds() as $siteId) {
foreach ($entryQuery->siteId($siteId)->each() as $entry) {
$elementsService->deleteElement($entry);
}
}

// Delete the structure, if there is one
Expand Down Expand Up @@ -1369,14 +1371,17 @@ public function handleDeletedEntryType(ParseConfigEvent $event)
}

// Delete the entries
$entries = Entry::find()
$entryQuery = Entry::find()
->status(null)
->enabledForSite(false)
->typeId($entryTypeRecord->id)
->all();
->typeId($entryTypeRecord->id);

foreach ($entries as $entry) {
Craft::$app->getElements()->deleteElement($entry);

$elementsService = Craft::$app->getElements();
foreach (Craft::$app->getSites()->getAllSiteIds() as $siteId) {
foreach ($entryQuery->siteId($siteId)->each() as $entry) {
$elementsService->deleteElement($entry);
}
}

// Delete the entry type.
Expand Down

0 comments on commit 191473d

Please sign in to comment.