教义2.5:无法识别的字段(但仅在Symfony的prod模式下) [英] Doctrine 2.5: Unrecognized field (but only in Symfony's prod mode)

查看:89
本文介绍了教义2.5:无法识别的字段(但仅在Symfony的prod模式下)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我似乎只受那些仅影响Symfony生产模式而不影响开发人员模式的问题困扰。这次,我有一个ManyToOne关联,并且我尝试仅获取没有关联的实体(即,它们在数据库中具有NULL值)。这完全符合我在开发人员迁移中的预期,但是在生产模式下,Doctrine抛出无法识别的字段异常……对于绝对存在的字段。

So I seem to be plagued by issues that only affect production mode in Symfony and not developer mode. This time, I have a ManyToOne association and I'm trying to fetch only the entities which do not have an association (i.e. they have a NULL value in the database). This works exactly as I'd expect in dev move, but in prod mode, Doctrine throws an "unrecognized field" exception... for a field which absolutely does exist.

这是相关实体(Page.php)的相关部分:

Here's the relevant part of the entity in question (Page.php):

/**
 * @ORM\ManyToOne(targetEntity="Project", inversedBy="pages")
 * @ORM\JoinColumn(name="project_id", referencedColumnName="ID")
 */
protected $project;

这是控制器(PageController.php)的相关行:

And here is the relevant line from the controller (PageController.php):

$pages = $this->getDoctrine()->getRepository('JCScopingBundle:Page')->findBy(['project' => null]);

同样,使用app_dev.php(即开发人员模式)可完美运行,但使用app.php(即产品模式),我不断收到无法识别的字段异常。

Again, this works perfectly using app_dev.php (i.e. dev mode), but using app.php (i.e. prod mode) I keep getting the "unrecognized field" exception. What gives?

更新:我在同一实体中添加了权重整数字段,并且在 prod 模式。这意味着我不能使用 prod 模式,这意味着我不能将更改上传到远程服务器。真的在这里泡菜...

Update: I added a "weight" integer field to the same entity and that field is not recognized in prod mode either. This means I can't use prod mode, which means I can't upload my changes to the remote server. Really in a pickle here...

推荐答案

好吧,低端,再看一下,重新启动Apache服务就解决了这个问题。显然,这是真正清除APCu元数据缓存的唯一方法。启发我根据这个问题/答案尝试此操作: Doctrine映射字段不起作用

Well, low and behold, restarting the Apache service resolved the issue. Apparently that's the only way to truly clear the APCu metadata cache. I was inspired to try this based on this question/answer: Doctrine mapped field is not working

这篇关于教义2.5:无法识别的字段(但仅在Symfony的prod模式下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆