Way to reproduce :
- layout.php :
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include_title() ?>
<?php include_http_metas() ?>
<?php include_metas() ?>
</head>
<body>
avant
<?php try { include_partial('user/widgetAccount'); } catch (Exception $e) { echo 'coucou'; } ?>
apres
</body>
</html>
- components.class.php :
function executeComponent() { throw new Exception('toto'); }
Result :
- We have the expected content loaded "avant coucou apres"
- Not any CSS nor Javascript is loaded
Why ? Because the ob_start done in sfPHPView is interrupted by an uncatched exception, and therefore is never cleaned, which leads to unexpected behavior of the sfCommonFilter who don't get a fully generated contents (well, I'm not exactly sure of the full diagnostic, but I'm sure of the cause, the consequence, and the medication).
See sfPHPView.class.php :
- Before
ob_start();
ob_implicit_flush(0);
require($_sfFile);
return ob_get_clean();
- After
ob_start();
ob_implicit_flush(0);
try {
require($_sfFile);
}
catch (Exception $e)
{
ob_end_clean();
throw $e;
}
return ob_get_clean();
Uncatched exception in the middle of an output buffering, quite an unforgivable mistake ;=)
Patch included.