homelessDevOps
homelessDevOps

Reputation: 20726

Zend Framework: 'Cannot nest headScript captures'

iam using ZF 1.11.x on my local machine (osx) everything works like excepted, but when i deploy my application to the production server an error occures:

mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'Zend_View_Helper_Placeholder_Container_Exception' with message 'Cannot nest headScript captures' in /var/www/virtual/website/library/Zend/View/Helper/HeadScript.php:146

Iam using the viewHelper to set some variables inside my layout.phtml. I can fix it by putting them just in script tags but i like to know why this error happens..

Upvotes: 0

Views: 607

Answers (2)

Yahia
Yahia

Reputation: 70369

According to the source code here this exception happens when you try to nest captureStart() calls.

Since it doesn't happen locally I suspect that your provider/production server has been setup in a specific manner - which often is the case when you don't use a dedicated root server...

Upvotes: 1

mevans
mevans

Reputation: 316

For us, this problem was caused due to short tags not being enabled for PHP.

Edit your php.ini, change "short_open_tag" to "on"

Basically we were using the following to end capture.

<?
$this->inlineScript()->captureEnd();
?>

But if short tags aren't enabled, this wont be recognized and any subsequent call of $this->inlineScript()->captureStart(); will crash.

Upvotes: 0

Related Questions