【環境情報】
- Database: PostgreSQL
- baserCMS Version: 5.2.1
- CakePHP Version: 5.0.11
- SitemapXML plugin : 5.0.0
上記環境でSitemapXMLを導入させていただいて、使用しようとしましたがエラーが出ましたので、調べ自己解決したものを共有情報として、お礼を込めてポストさせていただきます。
ダウンロードしたZIPファイルをそのままuploadして、pluginをインストール
歯車アイコンをクリックしPluginのページに入り「生成実行」をクリックするもエラーが出ました。
An Internal Error Has Occurred.
Error: The request sent to the address ‘/baser/admin/sitemap-xml/sitemap_xml/index’ was invalid.
色々調べたところ、cakePHPの5.xxに対応できていない様子で、3つのソースコードを修正しました。
-
./plugins/SitemapXml/src/Command/SitemapXmlCommand.php
/* $File = new \Cake\Filesystem\File($path); */ /* $File->write($sitemap); */ /* $File->close(); */ $File = new \SplFileObject($path, "w"); $File->fwrite($sitemap); $File=null; -
./plugins/SitemapXml/src/View/Helper/SitemapXmlHelper.php
/* public $helpers = ['BaserCore.BcContents']; */ protected array $helpers = ['BaserCore.BcContents']; -
./plugins/SitemapXml/src/Controller/Admin/SitemapXmlController.php
/* $File = new File($path); $File->write($sitemap); $File->close(); */ $File = new \SplFileObject($path, "w"); $File->fwrite($sitemap); $File = null; // close file handler
上記修正すると、動作できました。
生成されるsitemap.xmlは一部使用されていないパスも混じるようですので、個別にリンク先を確認して編集した方がよさそうです。
以上、元コードを作成いただいた @ryuring さんありがとうございました。

