XAMPPでブログページを作成すると、トップページが404 NotFoundになる 投稿する

投稿者:りゅーと  投稿日時:2023-02-14 12:03:13
いつも開発、メンテナンスの継続、ありがとうございます。

稼働環境
XAMPP:XAMPP Windows 8.1.6
PHP:version: 8.1.6
SOY CMS:version: 3.11.6

XAMPPを使用していて、ページの新規作成を行いブログのトップページを作ったのですが、ブログの確認をすると404 NotFoundと表示されます。
ページの新規作成で、URIを追加した場合はいいのですが、URIを空にすると404 NotFoundとなります。

以下、流れになります。
1. SOY CMSをXAMPPにインストール。
2. サイトを作成。
3. 必要項目を入力してページの新規作成。このときURIを空にする。
4. トップページのHTMLをコピペして更新。
5. ブログの確認。
6. 404 NotFoundと表示される。

通常のサーバーであればこのようなことにはならないのですが、XAMPPにだけこのような現象が起こります。
急ぎではないので、お手すきのときにでも対応していただけたらと思います。
よろしくお願いいたします。
投稿者:齋藤毅  投稿日時:2023-02-14 12:29:10
ブログページで記事を一つ投稿してみて、再びブログの確認を行ってみてください。
表示されるのであれば今回の404は仕様になります。

今回の仕様は迷っていまして、紛らわしいようでしたら、404にしないようにします。
投稿者:りゅーと  投稿日時:2023-02-14 16:35:19
早速の返信、ありがとうございます。
記事を1つ投稿してブログの確認をしたのですが、やはり404 NotFoundとなりました。

もし404にならないとしてもテスト記事は必要になるでしょうから、先にテスト記事を作るという流れでもいいかと思います。

それと、この確認をしていたときにエラーが2つ出ました。
1つ目は、ブログの設定をクリックすると、以下のエラーが出ました。
Deprecated: rawurlencode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\xampp\htdocs\cms\soycms\webapp\pages\Blog\ConfigPage.class.php on line 361

もう1つは、ダイナミック編集をクリックしたときに、以下のエラーが出ました。
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in C:\xampp\htdocs\cms\common\action\site\Page\Preview\PreviewAction.class.php on line 48

これらのエラーも今までは出ていませんでした。

すいませんが、対応をお願いいたします。
投稿者:齋藤毅  投稿日時:2023-02-15 10:26:48
エラーのご報告をありがとうございます。
修正版をダウンロードできるようにしました。
https://saitodev.co/soycms/

記事を1つ投稿してブログの確認をしたのですが、やはり404 NotFoundとなりました。
上記の件ですが、XAMPP特有の症状である可能性が高そうです。

XAMPPの環境を構築するのが大変なので、下記の内容を行っていただけないでしょうか。

/CMSインストールディレクトリ/common/site_include/CMSPageController.class.php
の46行目付近にあります
try{
	$page = soycms_get_hash_table_dao("page")->getActivePageByUri($uri);
}catch(Exception $e){
	$this->onNotFound();
}

try{
	$page = soycms_get_hash_table_dao("page")->getActivePageByUri($uri);
}catch(Exception $e){
	var_dump($e);
	$this->onNotFound();
}
に変更。

同じファイルの134行目付近にあります
if($this->webPage->getError() instanceof Exception){
	$this->onNotFound();
}

if($this->webPage->getError() instanceof Exception){
	var_dump($this->webPage->getError());
	$this->onNotFound();
}
に変更した後に、404NotFoundが表示されているページを開いてみてください。

もし、エラーメッセージが表示されていれば、その内容をお願いします。
投稿者:りゅーと  投稿日時:2023-02-15 16:49:47
早速の対処、ありがとうございます。

ブログの設定ををクリックしたときと、ダイナミック編集をクリックしたときのエラーは解消されました。

ブログの確認をしたときは、404NotFoundが表示され、以下のエラーが出ました。

object(Exception)#105 (7) { ["message":protected]=>string(25) "Too Many Argument Values." ["string":"Exception":private]=>string(0) "" ["code":protected]=>int(0) ["file":protected]=>string(61) "C:\xampp\htdocs\cms\common\site_include\CMSBlogPage.class.php" ["line":protected]=>int(372) ["trace":"Exception":private]=>array(7) { [0]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(5548) ["function"]=>string(11) "__construct" ["class"]=>string(11) "CMSBlogPage" ["type"]=>string(2) "->" ["args"]=>array(1) { [0]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#47 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } } } [1]=>array(6) { ["file"]=>string(67) "C:\xampp\htdocs\cms\common\site_include\CMSPageController.class.php" ["line"]=>int(132) ["function"]=>string(14) "createInstance" ["class"]=>string(15) "SOY2HTMLFactory" ["type"]=>string(2) "::" ["args"]=>array(2) { [0]=>string(11) "CMSBlogPage" [1]=>array(2) { ["arguments"]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#47 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } ["siteRoot"]=>string(12) "/sampleblog/" } } } [2]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(236) ["function"]=>string(7) "execute" ["class"]=>string(17) "CMSPageController" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [3]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(64) ["function"]=>string(3) "run" ["class"]=>string(18) "SOY2PageController" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [4]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(110) ["function"]=>string(14) "execute_normal" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [5]=>array(6) { ["file"]=>string(40) "C:\xampp\htdocs\cms\common\site.func.php" ["line"]=>int(42) ["function"]=>string(7) "execute" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [6]=>array(4) { ["file"]=>string(36) "C:\xampp\htdocs\sampleblog\index.php" ["line"]=>int(8) ["function"]=>string(12) "execute_site" ["args"]=>array(0) { } } } ["previous":"Exception":private]=>NULL }

すいませんが、よろしくお願いいたします。
投稿者:齋藤毅  投稿日時:2023-02-15 17:26:11
ありがとうございます。
お伝え頂きましたエラーで次に調べる箇所がわかりました。

/CMSインストールディレクトリ/common/site_include/CMSBlogPage.class.php
の368行目付近にあります

//ブログページのトップページのuriが有りでページャの場合も調べる
if(count($this->arguments) === 2 && strpos($this->arguments[0], "page-") === false) $argsError = false;
の箇所を
//ブログページのトップページのuriが有りでページャの場合も調べる
if(count($this->arguments) === 2 && strpos($this->arguments[0], "page-") === false) $argsError = false;
var_dump($this->arguments);
にしてから、再度表示を確認して、表示されている内容をお伝えいただけないでしょうか。

よろしくお願いします。
投稿者:りゅーと  投稿日時:2023-02-16 09:00:49
ありがとうございます。

指摘されたところを修正して確認しましたら、404NotFoundが表示され、以下のようなエラーが出ました。

array(1) { [0]=>string(10) "sampleblog" } object(Exception)#105 (7) { ["message":protected]=>string(25) "Too Many Argument Values." ["string":"Exception":private]=>string(0) "" ["code":protected]=>int(0) ["file":protected]=>string(61) "C:\xampp\htdocs\cms\common\site_include\CMSBlogPage.class.php" ["line":protected]=>int(373) ["trace":"Exception":private]=>array(7) { [0]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(5548) ["function"]=>string(11) "__construct" ["class"]=>string(11) "CMSBlogPage" ["type"]=>string(2) "->" ["args"]=>array(1) { [0]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#47 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } } } [1]=>array(6) { ["file"]=>string(67) "C:\xampp\htdocs\cms\common\site_include\CMSPageController.class.php" ["line"]=>int(132) ["function"]=>string(14) "createInstance" ["class"]=>string(15) "SOY2HTMLFactory" ["type"]=>string(2) "::" ["args"]=>array(2) { [0]=>string(11) "CMSBlogPage" [1]=>array(2) { ["arguments"]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#47 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } ["siteRoot"]=>string(12) "/sampleblog/" } } } [2]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(236) ["function"]=>string(7) "execute" ["class"]=>string(17) "CMSPageController" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [3]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(64) ["function"]=>string(3) "run" ["class"]=>string(18) "SOY2PageController" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [4]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(110) ["function"]=>string(14) "execute_normal" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [5]=>array(6) { ["file"]=>string(40) "C:\xampp\htdocs\cms\common\site.func.php" ["line"]=>int(42) ["function"]=>string(7) "execute" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [6]=>array(4) { ["file"]=>string(36) "C:\xampp\htdocs\sampleblog\index.php" ["line"]=>int(8) ["function"]=>string(12) "execute_site" ["args"]=>array(0) { } } } ["previous":"Exception":private]=>NULL }

すいませんが、よろしくお願いいたします。
投稿者:齋藤毅  投稿日時:2023-02-16 10:41:50
エラー報告をありがとうございます。
確認ですが、sampleblogというのは、サイトを新規作成した時のサイトのIDというのは、サイトを新規作成した時のサイトのIDということでお間違いございませんか?
投稿者:りゅーと  投稿日時:2023-02-16 10:55:22
はい、そうです。

sampleblogは、今回サイトを新規に作成したときのサイトIDのことです。
投稿者:齋藤毅  投稿日時:2023-02-16 13:55:01
ありがとうございます。
sampleblogがサイトIDであれば、下記の対応でいけるかもしれません。

/CMSインストールディレクトリ/common/site_include/CMSBlogPage.class.php
の366行付近の

if(count($this->arguments) === 1 && $this->page->getTopPageUri() == $this->arguments[0]) $argsError = false;

if(count($this->arguments) === 1){
	if($this->page->getTopPageUri() == $this->arguments[0]) $argsError = false;

	// args[0]にサイトIDが入っていることがある
	if(soycms_get_site_id_by_frontcontroller() == $this->arguments[0]) $argsError = false;
}
に変更。

これで対応出来れば、整形して公開します。
投稿者:りゅーと  投稿日時:2023-02-16 16:59:54
ありがとうございます。

指摘されたところを修正して確認したのですが、同じエラーが出てしまいました。

array(1) { [0]=>string(10) "sampleblog" } object(Exception)#105 (7) { ["message":protected]=>string(25) "Too Many Argument Values." ["string":"Exception":private]=>string(0) "" ["code":protected]=>int(0) ["file":protected]=>string(61) "C:\xampp\htdocs\cms\common\site_include\CMSBlogPage.class.php" ["line":protected]=>int(378) ["trace":"Exception":private]=>array(7) { [0]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(5548) ["function"]=>string(11) "__construct" ["class"]=>string(11) "CMSBlogPage" ["type"]=>string(2) "->" ["args"]=>array(1) { [0]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#15 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } } } [1]=>array(6) { ["file"]=>string(67) "C:\xampp\htdocs\cms\common\site_include\CMSPageController.class.php" ["line"]=>int(132) ["function"]=>string(14) "createInstance" ["class"]=>string(15) "SOY2HTMLFactory" ["type"]=>string(2) "::" ["args"]=>array(2) { [0]=>string(11) "CMSBlogPage" [1]=>array(2) { ["arguments"]=>array(3) { [0]=>int(2) [1]=>array(1) { [0]=>string(10) "sampleblog" } [2]=>object(SiteConfig)#15 (4) { ["name":"SiteConfig":private]=>string(30) "サンプル商事株式会社" ["siteConfig":"SiteConfig":private]=>string(80) "a:2:{s:16:"useLabelCategory";i:1;s:3:"url";s:28:"http://localhost/sampleblog/";}" ["charset":"SiteConfig":private]=>int(1) ["description":"SiteConfig":private]=>NULL } } ["siteRoot"]=>string(12) "/sampleblog/" } } } [2]=>array(6) { ["file"]=>string(45) "C:\xampp\htdocs\cms\common\lib\soy2_build.php" ["line"]=>int(236) ["function"]=>string(7) "execute" ["class"]=>string(17) "CMSPageController" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [3]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(64) ["function"]=>string(3) "run" ["class"]=>string(18) "SOY2PageController" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [4]=>array(6) { ["file"]=>string(70) "C:\xampp\htdocs\cms\common\site_include\SOYCMSOutputContents.class.php" ["line"]=>int(110) ["function"]=>string(14) "execute_normal" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "::" ["args"]=>array(0) { } } [5]=>array(6) { ["file"]=>string(40) "C:\xampp\htdocs\cms\common\site.func.php" ["line"]=>int(42) ["function"]=>string(7) "execute" ["class"]=>string(20) "SOYCMSOutputContents" ["type"]=>string(2) "->" ["args"]=>array(0) { } } [6]=>array(4) { ["file"]=>string(36) "C:\xampp\htdocs\sampleblog\index.php" ["line"]=>int(8) ["function"]=>string(12) "execute_site" ["args"]=>array(0) { } } } ["previous":"Exception":private]=>NULL }

なかなかうまくいかないですね。
投稿者:齋藤毅  投稿日時:2023-02-17 04:45:13
ご確認をありがとうございます。
今回のエラーで何処に問題があるかがわかりました。

古い記事で有効ではないかもしれませんが、RootBreak Blog: PATH_INFOを有効にするまでに躓くに記載されている内容で解決するかもしれません。

解決しなければ、他の方法を考えます。
投稿者:りゅーと  投稿日時:2023-02-17 09:54:19
ありがとうございます。

教えていただいたページを参考に、C:\xampp\apache\conf\httpd.conf にAcceptPathInfo Onを追加してxamppを再起動したのですが、やはり同じエラーになってしまいした。

また、同じxamppの別フォルダでSOY CMSをインストールしてサイトを作成してみました。
ページの新規作成画面で必要項目を入力して「ページを作成」をクリックしたところ、一瞬だけエラーのウィンドウが出てブログページが作成されました。
エラーのウィンドウは一瞬だけでしたので、何が書かれているかまではわかりませんでした。

xamppはローカルの開発環境とは言っても、やはり通常のサーバー環境とは違うということなんでしょうかね。
投稿者:齋藤毅  投稿日時:2023-02-17 16:34:15
教えていただいたページを参考に、C:\xampp\apache\conf\httpd.conf にAcceptPathInfo Onを追加してxamppを再起動したのですが、やはり同じエラーになってしまいした。
上記の件のご連絡をありがとうございます。
xamppは使った事がないのでわかりませんが、Apacheの標準の設定が不十分である可能性は高いです。

windowsのマシンでxamppを入れて、Apacheの設定を確認してみます。
投稿者:齋藤毅  投稿日時:2023-02-18 06:03:59
原因がわかりましたので、修正してダウンロードできるようにしました。
https://saitodev.co/soycms/

WindowsのPHPでは、パスの出力がバックスラッシュになり、Linuxと挙動が異なる事が考慮されていませんでした。
他にも今回と同様の問題が発生する事があるかもしれません。
投稿者:りゅーと  投稿日時:2023-02-18 09:30:21
ありがとうございます。

確認したところ、問題なく動作しました。

今回は、わざわざxamppの環境まで構築して対応していただき、ありがとうございました。
ログインして投稿する