From ff6cdf69e1879ac1354e9255b3a1a6df3fd0a4b3 Mon Sep 17 00:00:00 2001 From: hissy Date: Fri, 11 Sep 2026 07:26:41 +0900 Subject: [PATCH] Honor the mapped page template when creating pages CreatePageStructureCommandHandler::createRegularPage() resolved the mapped page template into $pageTemplate, but only passed its ID inside the $data array. Page::add() never reads $data['pTemplateID']; it takes the template from its third argument, and when that is falsy it substitutes the page type's default template instead. As a result every newly published page received its page type's default template, and the template mapping configured for the batch had no effect. Batches published a second time looked correct, because updateExistingPage() goes through Page::update(), which does honor pTemplateID. Passing the template to Page::add() also lets it copy the page type defaults belonging to that template, via getPageTypePageTemplateDefaultPageObject($template), so pages no longer inherit the default template's blocks. Aliases and external links are unaffected: they have no page template. The multilingual home page branch below already passed $pageTemplate to addHomePage(). Co-authored-by: Cursor --- .../Command/Handler/CreatePageStructureCommandHandler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PortlandLabs/Concrete5/MigrationTool/Publisher/Command/Handler/CreatePageStructureCommandHandler.php b/src/PortlandLabs/Concrete5/MigrationTool/Publisher/Command/Handler/CreatePageStructureCommandHandler.php index a4c57943..bcfb3477 100644 --- a/src/PortlandLabs/Concrete5/MigrationTool/Publisher/Command/Handler/CreatePageStructureCommandHandler.php +++ b/src/PortlandLabs/Concrete5/MigrationTool/Publisher/Command/Handler/CreatePageStructureCommandHandler.php @@ -89,7 +89,9 @@ private function createRegularPage(Batch $batch, ?CCMPage $ccmParentPage, MTPage ]; $localeInfo = $mtPage->getLocaleRoot(); if ($localeInfo === null || $batch->isPublishToSitemap() !== true || $this->localeAlreadyExists($batch, $localeInfo)) { - return $ccmParentPage->add($pageType, $data); + // Page::add() ignores $data['pTemplateID'] and falls back to the page type's + // default template unless the template is passed as the third argument. + return $ccmParentPage->add($pageType, $data, $pageTemplate ?: false); } if (!$pageTemplate) { throw new UserMessageException(t('Missing page template when creating the home of a language'));