EC-CUBE / EC-CUBE/ec-cube

proxy クラスを手動で削除するとシステムエラーが発生する

Open
#3,470 1 comment 0 reactions 0 assignees View on GitHub
bug:Low Status: needs-review
Dominant language
PHP
Stars
788
Forks
719
Avg merge
4d 4h
Merged PRs (30d)
39

Description

## 概要(Overview)
運用中、 proxy クラスを手動で削除するとシステムエラーになってしまう。
composer にて生成された Class Map が proxy クラスのみを参照しており、本体の Entity を検索してくれないのが原因

## 期待する内容(Expect) or 要望 (Requirement)
proxy クラスを手動で削除しても正常に動作する

## 再現手順(Procedure)
```shell
$ composer install # classmap を生成
$ bin/console eccube:generate:proxies # proxy を生成
## -> ここで Webサーバーを起動
$ rm app/proxy/entity/* # proxy を削除
## -> システムエラーが発生する

```

### 環境 (environment)
+ EC-CUBE: 4.0
+ PHP: 7.2.3
+ DB:
- PostgreSQL 9.6.x

## 関連情報 (Ref)

以下のパッチのように、Entity を PSR-4 autoload の対象から除外し、 `spl_autoload_register()` を実装することで、 ClassLoader での不具合は回避可能。
しかし、 Doctrine ORM のマッピングが残存するため、 property not exists のエラーが発生してしまう。

```patch
diff --git a/bin/console b/bin/console
index 4988d92f0..84babc94d 100755
--- a/bin/console
+++ b/bin/console
@@ -11,6 +11,7 @@ umask(0000);
set_time_limit(0);

require __DIR__.'/../vendor/autoload.php';
+require __DIR__.'/../entity_autoload.php';

if (!class_exists(Application::class)) {
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
diff --git a/entity_autoload.php b/entity_autoload.php
new file mode 100644
index 000000000..e3b5955d2
--- /dev/null
+++ b/entity_autoload.php
@@ -0,0 +1,15 @@
+

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.