PR

[CakePHP][BaserCMS] PHP5.3 でエラー

BaserCMS は、オープンソースPHP フレームワーク「CakePHP」 をベースとしたCMS 。今回、XAMPP 環境でBaserCMS を試用しようと思ったらエラーが噴出した。

Strict Standards: Redefining already defined constructor for class Object in D:\xampp\htdocs\www.exampe.jp\cake\libs\object.php on line 62

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\htdocs\www.exampe.jp\cake\libs\inflector.php on line 130

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\htdocs\www.exampe.jp\cake\libs\configure.php on line 128

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\htdocs\www.exampe.jp\cake\libs\configure.php on line 218

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\htdocs\www.exampe.jp\cake\libs\configure.php on line 893

Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\htdocs\www.exampe.jp\cake\libs\configure.php on line 933

これについて調べると、BaserCMS をやはりXAMPP 環境で利用しているユーザからの投稿もみられた。また、CakePHP での問題とその解決を指南する記事も見つけた。どうやらベースとなっているCakePHP が持っている問題のようで、この問題はPHP5.3 で行われた仕様変更に起因するようだ。

スポンサードリンク

PHP5.2 以下でのコンストラクタは「function クラス名()」と記述するところを、PHP5.3 では「function __クラス名()」と記述するようになったようです。(「CakePHP : CakePHP1.2 を PHP5.3 で動かした際に出たエラーの対処方法 | ゆる~くWebのこと」より引用)

解決方法

幾つかの記事に共通して見られたのが以下の対応方法。

CakePHP

cake/libs/configure.php 290行目などを修正する。

if (isset($config['debug'])) {
  if ($_this->debug) {
   error_reporting(E_ALL);

   この三行追加

   if (error_reporting() > 6143) {
    error_reporting(E_ALL & ~E_DEPRECATED);
   }

   ここまで

   if (function_exists('ini_set')) {
    ini_set('display_errors', 1);
   }

(Deprecated: Assigning the return value of new by reference is deprecated inより引用)

BaserCMS

ちょうど筆者とほぼ同様の環境のユーザから投稿があった。

xampp 1.7.7 (PHP Version 5.3.8)
basercms 1.6.15
os windows vista

cake\libs\inflector.php
cake\libs\configure.php
上記2ファイルの=&を=へ

cake\libs\object.php
上記ファイルの52行目当たりにあるphp4用コンストラクタfunction Object()・・・をごっそり削除
「XAMPPにインストール不可能|フォーラム|baserCMSユーザーズ」より引用)

筆者環境

  • XAMPP Lite Portable 1.7.7 on Windows7 SP1 64bit
    • Apache 2.2.21 (Win32)
    • mod_ssl 2.2.21
    • OpenSSL 1.0.0e
    • PHP 5.3.8
  • BaserCMS 1.6.15

ダウンロード

動作確認

表示とインストールが正しく行えた。

その他の変更内容やエラーとその対処については「PHP E_STRICTで表示されるエラーメッセージを調べてみた – Shin x blog」が詳しい。

参考文献

コメント

  1. @mokyu115 より:

    なんてこったい / “http://t.co/1eVlfxq4 » [CakePHP][BaserCMS] PHP5.3 でエラー” http://t.co/JIZpLptP