Problem/Motivation
I got a lot of warnings in our log on a new site, where I forgot to to disable assert() on production.
I'm still trying to figure out what exactly is going on, but I think assert() is the wrong tool for the job.
assert() is a developer-oriented, dev-environment only validation of input provide by... developers.
This however seems to be about preventing to break twig if we pass in weird stuff, possibly even security related?
But most production sites have zend.assertions on -1 (everyone should), which means this protection doesn't run at all and anything goes.
Proposed resolution
Convert to an actual if condition, if necessary, log violations (and it would be very useful if we would log the problematic value, as currently, this is very hard to reproduce/debug).
Comments
Comment #2
lendude@Berdir agreed, converting this to a normal if() and logging this makes more sense.
Just dug into this a little and this was originally added in #2546210: Views subtokens are broken since the introduction of inline templates for replacements per request of @alexpott. The other instances around this appear to be just copy/paste stuff of the original logic.
Comment #11
alexpott#3548695: Custom fields which start with a number can break views is a possible fix for this.