diff --git a/plugins/baser-core/src/View/Helper/BcBaserHelper.php b/plugins/baser-core/src/View/Helper/BcBaserHelper.php
index 0ba0e73080..df5aa223e0 100755
--- a/plugins/baser-core/src/View/Helper/BcBaserHelper.php
+++ b/plugins/baser-core/src/View/Helper/BcBaserHelper.php
@@ -2603,7 +2603,7 @@ public function setCanonicalUrl()
return;
}
if ($canonicalUrl) {
- $this->_View->assign('meta',
+ $this->_View->append('meta',
$this->BcHtml->meta('canonical',
$this->getUrl($canonicalUrl, true),
[
@@ -2637,7 +2637,7 @@ public function setCanonicalUrl()
$url = preg_replace('/\.html$/', '', $url);
$url = preg_replace('/\/page:1$/', '', $url);
$url = preg_replace('/\\/index$/', '/', $url);
- $view->assign('meta',
+ $view->append('meta',
$this->BcHtml->meta('canonical',
$this->getUrl($url, true),
[
@@ -2671,7 +2671,7 @@ public function setAlternateUrl()
$request->getAttribute('currentSite')->id
)]));
- $view->assign('meta',
+ $view->append('meta',
$this->BcHtml->meta('alternate',
null,
[
diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcBaserHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcBaserHelperTest.php
index 4f127511d4..0faf9c234c 100644
--- a/plugins/baser-core/tests/TestCase/View/Helper/BcBaserHelperTest.php
+++ b/plugins/baser-core/tests/TestCase/View/Helper/BcBaserHelperTest.php
@@ -2293,6 +2293,27 @@ public function testSetCanonicalUrl($siteId, $url, $expected, $canonicalUrl = nu
$this->assertEquals($expected, $this->BcBaser->getView()->fetch('meta'));
}
+ /**
+ * testSetCanonicalUrl
+ * テンプレートで meta ブロックに追加した内容が、カノニカルタグの出力で消えないこと
+ */
+ public function testSetCanonicalUrlKeepsMetaBlock()
+ {
+ $this->loadFixtureScenario(InitAppScenario::class);
+ ContentFactory::make([
+ 'site_id' => 1,
+ 'url' => '/'
+ ])->persist();
+ $view = $this->BcBaser->getView();
+ $view->setRequest($this->getRequest('/'));
+ $view->assign('meta', '');
+ $this->BcBaser->setCanonicalUrl();
+ $this->assertEquals(
+ '',
+ $view->fetch('meta')
+ );
+ }
+
public static function setCanonicalUrlDataProvider()
{
return [