diff --git a/concrete/controllers/panel/add.php b/concrete/controllers/panel/add.php index 7dc6f045088..6c2af21926c 100644 --- a/concrete/controllers/panel/add.php +++ b/concrete/controllers/panel/add.php @@ -5,6 +5,7 @@ use Concrete\Controller\Backend\UserInterface\Page as BackendInterfacePageController; use Concrete\Core\Application\EditResponse; use Concrete\Core\Application\Service\Urls; +use Concrete\Core\Area\Area; use Concrete\Core\Block\Block; use Concrete\Core\Block\BlockType\BlockType; use Concrete\Core\Block\BlockType\BlockTypeList; @@ -270,13 +271,14 @@ public function removeOrphanedBlock() if (!$orphanedBlockFound) { $errorList->add(t("The given block is not orphaned.")); } else { - $block = Block::getByID($blockId); - + $arID = $request->request->get('arId'); + $areaHandle = Area::getAreaHandleFromID($arID); + $block = Block::getByID($blockId, $this->page, $areaHandle); if (!$block instanceof Block) { //$errorList->add(t("Error while removing orphaned block.")); } else { // returns false because the area no longer exists in the theme. - $block->deleteBlock(true); + $block->deleteBlock(); } } } @@ -313,15 +315,16 @@ public function removeOrphanedBlocks() if (count($arrOrphanedBlocks) === 0) { $errorList->add(t("There are no blocks to remove.")); } else { - foreach ($this->getOrphanedBlockIds($usedAreas) as $arrOrphanedBlock) { + foreach ($arrOrphanedBlocks as $arrOrphanedBlock) { $bID = (int)$arrOrphanedBlock["bID"]; - $block = Block::getByID($bID); + $arHandle = $arrOrphanedBlock["arHandle"]; + $block = Block::getByID($bID, $this->page, $arHandle); if (!$block instanceof Block) { $errorList->add(t("Error while removing orphaned block.")); } else { // returns false because the area no longer exists in the theme. - $block->deleteBlock(true); + $block->deleteBlock(); } } }