【问题标题】:Symfony 4 : Property App\Entity\Ad::$site does not exist (but impossible to find in the code ?)Symfony 4:属性 App\Entity\Ad::$site 不存在(但无法在代码中找到?)
【发布时间】:2019-10-22 20:30:33
【问题描述】:

我有一个指向我的班级 Annonce 的班级网站链接。 我删除了有关“站点”的所有内容,并根据教义进行了迁移。

然后出现了这个错误。

所以我在所有文件中进行了查找,以查看“站点”是否在某个地方并在任何地方删除。

我仍然有这个错误。 我不知道该怎么办 ?

可能有缓存问题?

这是堆栈跟踪

ReflectionException:
Property App\Entity\Annonce::$site does not exist

  at vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:63
  at ReflectionProperty->__construct('App\\Entity\\Annonce', 'site')
     (vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:63)
  at Doctrine\Common\Persistence\Mapping\RuntimeReflectionService->getAccessibleProperty('App\\Entity\\Annonce', 'site')
     (vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:970)
  at Doctrine\ORM\Mapping\ClassMetadataInfo->wakeupReflection(object(RuntimeReflectionService))
     (vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:750)
  at Doctrine\ORM\Mapping\ClassMetadataFactory->wakeupReflection(object(ClassMetadata), object(RuntimeReflectionService))
     (vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:181)
  at Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('App\\Entity\\Annonce')
     (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:283)
  at Doctrine\ORM\EntityManager->getClassMetadata('App\\Entity\\Annonce')
     (vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:2692)
  at Doctrine\ORM\UnitOfWork->createEntity('App\\Entity\\Categorie', array('id' => 1, 'nom' => 'Bar Tabac PMU'), array('deferEagerLoad' => true, 'fetchAlias' => 'e'))
     (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:271)
  at Doctrine\ORM\Internal\Hydration\ObjectHydrator->getEntity(array('id' => 1, 'nom' => 'Bar Tabac PMU'), 'e')
     (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:492)
  at Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData(array('id_0' => '1', 'nom_1' => 'Bar Tabac PMU'), array())
     (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:162)
  at Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateAllData()
     (vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:152)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(object(PDOStatement), object(ResultSetMapping), array())
     (vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:976)
  at Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(null, null)
     (vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:922)
  at Doctrine\ORM\AbstractQuery->execute()
     (vendor/symfony/doctrine-bridge/Form/ChoiceList/ORMQueryBuilderLoader.php:50)
  at Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader->getEntities()
     (vendor/symfony/doctrine-bridge/Form/ChoiceList/DoctrineChoiceLoader.php:85)
  at Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader->loadChoiceList(array(object(IdReader), 'getIdValue'))
     (vendor/symfony/form/ChoiceList/LazyChoiceList.php:62)
  at Symfony\Component\Form\ChoiceList\LazyChoiceList->getChoices()
     (vendor/symfony/form/ChoiceList/Factory/DefaultChoiceListFactory.php:53)
  at Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory->createView(object(LazyChoiceList), array(), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), null, null)
     (vendor/symfony/form/ChoiceList/Factory/PropertyAccessDecorator.php:193)
  at Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator->createView(object(LazyChoiceList), array(), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), null, null)
     (vendor/symfony/form/ChoiceList/Factory/CachingFactoryDecorator.php:127)
  at Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator->createView(object(LazyChoiceList), array(), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), null, null)
     (vendor/symfony/form/Extension/Core/Type/ChoiceType.php:410)
  at Symfony\Component\Form\Extension\Core\Type\ChoiceType->createChoiceListView(object(LazyChoiceList), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'translation_domain' => null, 'auto_initialize' => true, 'trim' => false, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'multiple' => false, 'expanded' => false, 'block_prefix' => null, 'label' => 'Catégorie de commerce *', 'row_attr' => array(), 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => true, 'error_bubbling' => false, 'label_attr' => array(), 'compound' => false, 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'validation_groups' => null, 'constraints' => array(), 'choices' => null, 'query_builder' => null, 'class' => 'App\\Entity\\Categorie', 'em' => object(EntityManager), 'id_reader' => object(IdReader), 'choice_loader' => object(DoctrineChoiceLoader), 'choice_label' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), 'choice_name' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), 'choice_value' => array(object(IdReader), 'getIdValue'), 'choice_attr' => null, 'preferred_choices' => array(), 'group_by' => null, 'placeholder' => 'Choisir une catégorie', 'choice_translation_domain' => false))
     (vendor/symfony/form/Extension/Core/Type/ChoiceType.php:185)
  at Symfony\Component\Form\Extension\Core\Type\ChoiceType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'translation_domain' => null, 'auto_initialize' => true, 'trim' => false, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'multiple' => false, 'expanded' => false, 'block_prefix' => null, 'label' => 'Catégorie de commerce *', 'row_attr' => array(), 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => true, 'error_bubbling' => false, 'label_attr' => array(), 'compound' => false, 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'validation_groups' => null, 'constraints' => array(), 'choices' => null, 'query_builder' => null, 'class' => 'App\\Entity\\Categorie', 'em' => object(EntityManager), 'id_reader' => object(IdReader), 'choice_loader' => object(DoctrineChoiceLoader), 'choice_label' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), 'choice_name' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), 'choice_value' => array(object(IdReader), 'getIdValue'), 'choice_attr' => null, 'preferred_choices' => array(), 'group_by' => null, 'placeholder' => 'Choisir une catégorie', 'choice_translation_domain' => false))
     (vendor/symfony/form/ResolvedFormType.php:148)
  at Symfony\Component\Form\ResolvedFormType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'translation_domain' => null, 'auto_initialize' => true, 'trim' => false, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'multiple' => false, 'expanded' => false, 'block_prefix' => null, 'label' => 'Catégorie de commerce *', 'row_attr' => array(), 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => true, 'error_bubbling' => false, 'label_attr' => array(), 'compound' => false, 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'validation_groups' => null, 'constraints' => array(), 'choices' => null, 'query_builder' => null, 'class' => 'App\\Entity\\Categorie', 'em' => object(EntityManager), 'id_reader' => object(IdReader), 'choice_loader' => object(DoctrineChoiceLoader), 'choice_label' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), 'choice_name' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), 'choice_value' => array(object(IdReader), 'getIdValue'), 'choice_attr' => null, 'preferred_choices' => array(), 'group_by' => null, 'placeholder' => 'Choisir une catégorie', 'choice_translation_domain' => false))
     (vendor/symfony/form/ResolvedFormType.php:145)
  at Symfony\Component\Form\ResolvedFormType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label_format' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'translation_domain' => null, 'auto_initialize' => true, 'trim' => false, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'inherit_data' => false, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'allow_file_upload' => false, 'help_translation_parameters' => array(), 'error_mapping' => array(), 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_token_manager' => object(CsrfTokenManager), 'csrf_token_id' => null, 'multiple' => false, 'expanded' => false, 'block_prefix' => null, 'label' => 'Catégorie de commerce *', 'row_attr' => array(), 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => true, 'error_bubbling' => false, 'label_attr' => array(), 'compound' => false, 'upload_max_size_message' => object(Closure), 'help' => null, 'help_attr' => array(), 'help_html' => false, 'validation_groups' => null, 'constraints' => array(), 'choices' => null, 'query_builder' => null, 'class' => 'App\\Entity\\Categorie', 'em' => object(EntityManager), 'id_reader' => object(IdReader), 'choice_loader' => object(DoctrineChoiceLoader), 'choice_label' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceLabel'), 'choice_name' => array('Symfony\\Bridge\\Doctrine\\Form\\Type\\DoctrineType', 'createChoiceName'), 'choice_value' => array(object(IdReader), 'getIdValue'), 'choice_attr' => null, 'preferred_choices' => array(), 'group_by' => null, 'placeholder' => 'Choisir une catégorie', 'choice_translation_domain' => false))
     (vendor/symfony/form/Form.php:1030)
  at Symfony\Component\Form\Form->createView(object(FormView))
     (vendor/symfony/form/Form.php:1033)
  at Symfony\Component\Form\Form->createView()
     (src/Controller/AnnonceController.php:60)
  at App\Controller\AnnonceController->newFree(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:22)

谢谢

【问题讨论】:

    标签: symfony symfony4


    【解决方案1】:

    这绝对是缓存问题。按顺序尝试以下方法,看看是否有帮助:

    • bin/控制台缓存:清除
    • rm var/cache 文件夹
    • 手动清除您可能启用的任何其他 PHP 缓存

    【讨论】:

      【解决方案2】:

      我也有同样的问题。我可以确认这是数据库缓存的问题。 在运行迁移之前,您应该运行以下命令:

          bin/console doctrine:cache:clear-query --flush
          bin/console doctrine:cache:clear-result --flush
          bin/console doctrine:cache:clear-metadata --flush
      

      如果您使用 redis 来存储数据库缓存,您可能还需要在执行迁移之前刷新它。你可以在 redis-cli 中输入FLUSHALL

      【讨论】:

        猜你喜欢
        • 2021-10-02
        • 2021-05-07
        • 1970-01-01
        • 1970-01-01
        • 2018-09-16
        • 2021-12-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-09
        相关资源
        最近更新 更多