smarty icon indicating copy to clipboard operation
smarty copied to clipboard

Error handler should only allow notices etc in smarty templates, not beyond

Open rudiedirkx opened this issue 3 years ago • 9 comments

Only handle errors in the smarty compiled dir. Not errors that happen during smarty but somewhere else.

rudiedirkx avatar Jan 05 '23 19:01 rudiedirkx

See #839

rudiedirkx avatar Jan 05 '23 20:01 rudiedirkx

This has always been an important missing feature in Smarty error handler. rudiedirkx's solution looks good, I hope it gets merged into Smarty!

lemon-juice avatar Feb 07 '23 08:02 lemon-juice

@wisskid Did you catch this somewhere else by now? I haven't been paying attention to Smarty merges. My method might not be acceptable, but Smarty has to check against $smarty->getCompileDir() probably.

rudiedirkx avatar Oct 13 '23 01:10 rudiedirkx

@rudiedirkx I hadn't looked into this yet. Seems like a great improvement. At some point, I would like to get rid of the error handler altogether, but this seems like a great first step. I'll have to adapt it to the new v5 release, but this one will do just fine for v4. I'll merge it asap.

wisskid avatar Oct 19 '23 20:10 wisskid

The base branch change did something weird to the diff. I resolved a merge conflict, but it's still weird. The error handler has changed in the meantime probably. All I did was add

if (strpos($errfile, $this->smarty->getCompileDir()) === 0) {

around all of the return conditions in handleError().


Smarty still needs its own error handler, doesn't it? You don't want an uncaught error to trace to a compiled Smarty template. Or maybe you do... I don't know. Twig catches all errors during a template and rethrows it with original template info. That's good for debugging.

rudiedirkx avatar Oct 20 '23 16:10 rudiedirkx

I can't change the base branch of my fork, so I can't fix this.

rudiedirkx avatar Oct 20 '23 16:10 rudiedirkx

@rudiedirkx how about uncompiled templates such as 'eval:' templates or stream plugins?

wisskid avatar Nov 06 '23 17:11 wisskid

No idea. I've never used those. What are $errfile and $this->smarty->getCompileDir() then?

rudiedirkx avatar Nov 06 '23 19:11 rudiedirkx

The compile dir is probably still the (default) compile dir, but $errfile will be the phone script calling the template. Which will not be in the compile dir.

wisskid avatar Nov 06 '23 22:11 wisskid