This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » Missing form token... still there

Missing form token... still there

Missing form token... still there

Wednesday 29 May 2013 10:34:26 am - 7 replies


In a previous message, I asked help about an exception I had when submitting form. An answer suggested me to use the Symfony way of rendering the form. It solved the problem.

But since, I tried to implement a new form (submitted using Ajax) and I got this error again sad.gif Emoticon And now I it's affecting all the forms on the site... I even reset my working tree to a previous comit but without any luck.

I use form_widget() to display the form and I am logged in as admin. The content object is created and is visible in the back office.

So I don't know if I am doing something wrong but I am starting to think that there is a real issue here.

He is the apache log

PHP Fatal error:  Uncaught exception 'ErrorException' with message 'Warning: Cannot 
modify header information - headers already sent by 
(output started at /var/www/ez5/ezpublish/cache/dev/classes.php:2746) in 
/var/www/ez5/ezpublish_legacy/kernel/private/classes/ezpkernelweb.php line 204' in
trace:\n#0 [internal function]: Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler->handle
(2, 'Cannot modify h...', '/var/www/ez5/ez...', 204, Array)\n#1 /var/www/ez5/ezpublish_legacy/
kernel/private/classes/ezpkernelweb.php(204): header('HTTP/1.1 500 In...')\n#2 
[internal function]: ezpKernelWeb->{closure}()\n#3 /var/www/ez5/ezpublish_legacy/lib/
ezutils/classes/ezexecution.php(128): call_user_func(Object(Closure))\n#4 
[internal function]: eZExecution::uncleanShutdownHandler()\n#5 {main}\n  thrown in 
/var/www/ez5/ezpublish_legacy/kernel/private/classes/ezpkernelweb.php on line 204 

I can provide a sample of my code if needed.

If somebody has a workaround it would be so great!

Thursday 30 May 2013 11:08:03 am

Hi Julien

Difficult to say anything without seeing some code happy.gif Emoticon. You're talking about a created content, so are you trying to create a content using a custom form ?

Can you please provide a gist of your controller/template (you can post the 2 files in one gist) ?


Thursday 30 May 2013 12:20:51 pm

Hi Jérôme.

Thank you for your answer.

The form is used to create a new (custom) content object. The view displays the list of existing objects of the given type and displays the form to create a new one.

When I submit the form to create a new object, the exception is raised but the object is created. If I refresh the page it appears in the list. So the content creation is working.

If I comment the line "$contentService->publishVersion(...)", the draft is created and no exception is raised.

Here is the gist of my controller and the view.

If you need more information, don't hesitate.

Modified on Thursday 30 May 2013 12:21:24 pm by Julien Montavit

Monday 03 June 2013 11:33:25 am

I found something more.

If a user is logged in while trying to submit the form (admin user), the exception is raised. But if no user is logged in (and anonymous has the right to create content) the form works fine and there is no exception.

I must say I a little lost :/

Tuesday 18 June 2013 9:30:29 am

The problem is still here but I found a workaround.

If somebody gets the same problem, the solution is to create only the draft in the first action :

 $draft = $repository->getContentService()->createContent( $contentCreateStruct, array( $locationCreateStruct ) );

then redirect to another action (passing the draftId) :

 $this->redirect($this->generateUrl('_publish_content', array('draftId' => $draft->id)));

load the draft :

 $draft = $repository->getContentService()->loadContent($draftId);

and finally publish the draft :

 $content = $repository->getContentService()->publishVersion( $draft->versionInfo );

Hope it helps somebody.

Tuesday 18 June 2013 9:41:33 am

Hi Julien

The token error is actually the consequence of another issue (nested exceptions). To know exactly what's happening, you need to catch the exception in your controller and check all nested exceptions in it. You can do that by placing a breakpoint using XDebug, or by doing a var_dump() of the exception.

Tuesday 18 June 2013 1:55:34 pm

Hi Jérôme.

Ok, I see.

I will try that as soon as I got time because for now, I had to move on.

Monday 09 June 2014 10:52:15 am

I've got a similar error when a user is connected. When it is anonymous user, there is not exception :


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from