An exception has been thrown during the rendering of a template (“Catchable Fatal Error: Object of class __PHP_Incomplete_Class could not be converted to string”) in “default_frame.twig” at line 67.
管理画面のカスタマイズのため、MemberエンティティにOneToManyの関連を付け足すと
Catchable Fatal Errorではまりました。
$app[“user”]が__PHP_Incomplete_Classになってしまったため、Memberオブジェクトにアクセスできなくなってしまったようです。
原因は$app[‘user’]がセッションに保存されていること。
セッションから取り出すタイミングではまだMemberエンティティの定義が読み込まれていないことが原因のようです。
(DB問い合わせじゃないのか・・・)
少し探すと対処法がオフィシャルのGithubに掲載されていました。
https://github.com/EC-CUBE/ec-cube/issues/1680
この通りにApplicationクラスを書き換えるとエラーは出なくなりました。
public function initSession()
{
+ ini_set('unserialize_callback_func', 'Eccube\Application::proxymissing');
$this->register(new \Silex\Provider\SessionServiceProvider(), array(
'session.storage.save_path' => $this['config']['root_dir'].'/app/cache/eccube/session',
'session.storage.options' => array(
@@ -997,4 +998,13 @@ class Application extends ApplicationTrait
}
return true;
}
+
+ public static function proxymissing( $name ) {
+ $proxyDir = __DIR__.'/../../app/cache/doctrine';
+ if ( strpos($name, 'DoctrineProxy\__CG__\Eccube\Entity') !== false) {
+ $name = str_replace('\\', '', $name);
+ $name = str_replace('DoctrineProxy', '', $name);
+ require $proxyDir.'/'.$name.'.php';
+ }
+ }
EC-CUBEに関するお問い合わせ
[重要]現在公式にセキュリティサポートが切れていないPHPは8.1以上、MySQLは8.0以上で、対応しているEC-CUBEバージョンは4.2以上です。古いEC-CUBEを使っている方は適切なタイミングでバージョンアップをご検討ください。
EC-CUBEゴールドパートナー