zordius / lightncandy

An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ),
https://zordius.github.io/HandlebarsCookbook/
MIT License
610 stars 76 forks source link

Possible bug with `$context['flags']['debug']`? #364

Closed frewsxcv closed 1 year ago

frewsxcv commented 1 year ago

https://github.com/zordius/lightncandy/blob/f962e19ed87725f7bdd2ba96a0b20d07ff33df66/src/Context.php#L68

The code above is set when initializing the context, and it checks whether FLAG_RENDER_DEBUG is set in $flags and if so assigns it to $context['flags']['debug'].

And then upon rendering, if lightncandy encounters an error, it checks wether $context['flags']['debug'] is set to DEBUG_ERROR_LOG or DEBUG_ERROR_EXCEPTION, and if so it either logs or throws an exception (respectively):

https://github.com/zordius/lightncandy/blob/f962e19ed87725f7bdd2ba96a0b20d07ff33df66/src/Runtime.php#L106-L115

Unless I'm missing something, these conditionals will never be true since $context['flags']['debug'] is either set to 0 or FLAG_RENDER_DEBUG.

Screen Shot 2022-10-24 at 11 42 47 AM
frewsxcv commented 1 year ago

Nevermind. I now see the runtime context flags are different from the setup context flags