Forms Symfony2 esi缓存表单不工作
我遇到了奇怪的情况。我有最新的服务器文件和本地文件。无效时,会出现此带错误的闪烁消息: 如果$form->isValid&&$this->checkLastComment$commentRepository、$user、$status、$comment{ 我有两个URL。First/Home适用于我加载带有注释的状态但不缓存页面的所有人 然后我有/建议的url,我在其中加载带有注释的状态,但使用Forms Symfony2 esi缓存表单不工作,forms,symfony,caching,esi,Forms,Symfony,Caching,Esi,我遇到了奇怪的情况。我有最新的服务器文件和本地文件。无效时,会出现此带错误的闪烁消息: 如果$form->isValid&&$this->checkLastComment$commentRepository、$user、$status、$comment{ 我有两个URL。First/Home适用于我加载带有注释的状态但不缓存页面的所有人 然后我有/建议的url,我在其中加载带有注释的状态,但使用 $response->setPublic(); $response->s
$response->setPublic();
$response->setSharedMaxAge(3600);
我缓存页面,因为它对所有用户都是一样的
但这很奇怪,因为在本地机器上缓存是打开的,我测试了当我想在prod、dev env上创建一个注释时,一切都正常运行
在服务器上,当我处于dev env.caching关闭状态时,它会正常运行,但当我尝试在prod env上发表评论时,会收到有关所述情况的错误提示消息
WTF?请问哪里会漏水?我不知道
公共esi缓存以某种方式破坏了我的表单?还是
一个朋友可以在那里发表评论…另一个不是…奇怪…我以前没有,但在缓存清除后我又可以
编辑:
午饭后我又试了一次,但我无法发表评论…wtf
这是我在chrome中看到的标题:发送
CommentForm[comment]:gllll
status_id:65084
CommentForm[_token]:4858119eccbc91da6219d4cbaa1b6c2e79dbd56a
comment_id:0
使用此jquery代码:
var url=Routing.generate('create_comment', {"comment_id": comment_id_value, "status_id": status_id_value})+'.json';
$.post(url, $this.serialize(), function(data) {
对于此控制器:
public function createAction(Request $request, $comment_id=0, $status_id)
{
// first CHECK if user exists
$user=$this->getUser();
if ($user) {
$em=$this->getDoctrine()->getManager();
// GET REPOSITORIES
$statusRepository=$em->getRepository('WallBundle:Status');
$commentRepository=$em->getRepository('WallBundle:Comments');
$notifyRepository=$em->getRepository('NotifyBundle:Notify');
$userRepository=$em->getRepository('UserBundle:User');
// GET SM
$SM=$this->get('status_manager');
// GET status by ID
$status=$statusRepository->find($status_id);
// CHECK if this status exists
if ($status) {
$targetUser=$status->getUser();
if ($request->isMethod('POST') && ($this->getRequest()->getRequestFormat() == 'json')) {
if ($comment_id==0 || !$cE) {
$cE = new Comments();
}
$form = $this->createForm(new CommentFormType(), $cE);
$form->bind($request);
$comment=$form->getData()->getComment();
if ($form->isValid() && $this->checkLastComment($commentRepository,$user,$status, $comment)) {
以及checklastcoment函数
public function checkLastComment($commentRepository, User $user,Status $status, $comment)
{
// check if last comment was more than 10s ago
$lastCommentQueryArray=$commentRepository->getLastComment($user, $status);
$lastCommentTime=0;
$lastCommentContent='';
foreach ($lastCommentQueryArray as $lastComment) {
$lastCommentTime =$lastComment['time'];
$lastCommentContent=$lastComment['comment'];
}
if (($lastCommentTime+10>=time()) && (trim($lastCommentContent)==trim($comment))) {
return false;
}
else {
return true;
}
}
*但是错误不应该出现在代码中,因为我在整个网络上都在使用这种技术,一切都运行良好…只有在这个特定的页面上它不工作…页面之间的唯一区别是这个页面被缓存了…+当我创建一个新的注释时,它与缓存无关,不是吗?它只从f获取数据缓存页上的orm…*