0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

doctrine Undefined index on doctrine m:n relation

0
Posted at

はじめに

doctrineを使っていて、以下のエラーがでてきた。

[2021-06-02 12:02:44] request.CRITICAL: Uncaught PHP Exception ErrorException: "Notice: Undefined index: <クラス名>" at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php line 122 {"exception":"[object] (ErrorException(code: 0): Notice: Undefined index: <クラス名> at /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:122)"} []

TL;DR

以下のコマンドでdoctrineのスキーマ定義を確認する

php bin/console doctrine:schema:validate

以下のようなエラーが出てきました。

root@2043c465e73b:/var/www/html # php bin/console doctrine:schema:validate
Cannot load Xdebug - it was already loaded
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(

Mapping
-------

 [FAIL] The entity-class App\Entity\NoticeLog mapping is invalid:
 * The association App\Entity\NoticeLog#user refers to the inverse side field App\Entity\User#NoticeLog which does not exist.


 [FAIL] The entity-class App\Entity\User mapping is invalid:
 * The mappings App\Entity\User#noticeLogs and App\Entity\NoticeLog#user are inconsistent with each other.


Database
--------

                                                                                                                        
 [ERROR] The database schema is not in sync with the current mapping file.                                              
                                                                                                                        

そういえば、make:entityで作成した後、作り直したプロパティがあって、そのために不整合が起きた模様。

修正することで不具合がでなくなりました。

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?