Symfony产品模式下无法识别的图库

问题描述 投票:0回答:1

我正在使用Sonfony 4.4开发网站,使用SonataAdmin(^ 3.56),Doctrine ORM Admin(^ 3.12),Sonata Media(^ 3.22)和SonataClassification(^ 3.9)捆绑包。我的网站在开发模式下运行良好。问题是当我将其更改为生产模式时。

。env

APP_ENV=prod
APP_DEBUG=0

当我使用SonataMedia画廊访问路线时,出现错误500。日志文件(prod.log)包含以下内容:

request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMException: "Unrecognized field: gallery" at /home/repincln/dev/site/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 101 {"exception":"[object] (Doctrine\\ORM\\ORMException(code: 0): Unrecognized field: gallery at /home/repincln/dev/site/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:101)"} []

在控制器中,我有:

...
$medias = $this->getDoctrine()->getRepository("ApplicationSonataMediaBundle:GalleryHasMedia")->findBy(array('gallery' => $article->getGallery()));
...

如果我在开发人员模式下转储$ medias,它看起来还不错,所有图像都在图库中,但是在生产模式下它不起作用。

[SonataAdmin管理员->分类中发生类似的情况

request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Semantical Error] line 0, col 84 near 'parent IS NU': Error: Class App\Application\Sonata\ClassificationBundle\Entity\Category has no field or association named parent" at /home/repincln/dev/site/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 65 {"exception":"[object] (Doctrine\\ORM\\Query\\QueryException(code: 0): [Semantical Error] line 0, col 84 near 'parent IS NU': Error: Class App\\Application\\Sonata\\ClassificationBundle\\Entity\\Category has no field or association named parent at /home/repincln/dev/site/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:65, Doctrine\\ORM\\Query\\QueryException(code: 0): SELECT c FROM App\\Application\\Sonata\\ClassificationBundle\\Entity\\Category c WHERE c.parent IS NULL at /home/repincln/dev/site/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:43)"} []

以及标签,收藏集,媒体。只有上下文正常工作。例如画廊看起来像:

enter image description here

config / packages / prod / doctrine.yaml

doctrine:
    orm:
        auto_generate_proxy_classes: false
        metadata_cache_driver:
            type: service
            id: doctrine.system_cache_provider
        query_cache_driver:
            type: service
            id: doctrine.system_cache_provider
        result_cache_driver:
            type: service
            id: doctrine.result_cache_provider

services:
    doctrine.result_cache_provider:
        class: Symfony\Component\Cache\DoctrineProvider
        public: false
        arguments:
            - '@doctrine.result_cache_pool'
    doctrine.system_cache_provider:
        class: Symfony\Component\Cache\DoctrineProvider
        public: false
        arguments:
            - '@doctrine.system_cache_pool'

framework:
    cache:
        pools:
            doctrine.result_cache_pool:
                adapter: cache.app
            doctrine.system_cache_pool:
                adapter: cache.system

config / packages / doctrine.yaml

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
        types:
            json: Sonata\Doctrine\Types\JsonType

    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

Article.php

...
    /**
    * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Gallery");
    */
    private $gallery;
...

正如我在开发模式下写的那样,一切正常。

即使我这样做,问题仍然存在(多次):

任何想法我还能做什么?我认为某处的缓存存在问题。

symfony doctrine-orm sonata-admin
1个回答
0
投票

我终于找到了解决方法。

我在config / bundles.php中有

Sonata\EasyExtendsBundle\SonataEasyExtendsBundle::class => ['dev' => true, 'test' => true],

必须是:

Sonata\EasyExtendsBundle\SonataEasyExtendsBundle::class => ['all' => true],
© www.soinside.com 2019 - 2024. All rights reserved.