Closed radiocity closed 5 years ago
Hi,
As the error says: The backtrack limit was exhausted (Increase pcre.backtrack_limit in php.ini)
you need to increase the pcre.backtrack_limit in php.ini (the default value 1000000 should be enough, but you may have lower setting enforced). Else you need to double the value until the error disappears.
Pug-php is a parser, it uses complex regular expression that cannot work with a low pcre.backtrack_limit setting.
Note than using the cache, those RegExp are no longer executed in production. This is needed only for the compilation.
Thanks!
That are bad news, actually. Source code isn`t so complex as could be.
Just saying for the sake of sharing: having a simple (what does it mean simple?) source doesn't mean the parser will use RegEx-es with less backtracking. Moreover:
Don't mind it so much 😃 ❤️ (my 2 joking cents)
Well, parser fails at production environment... I thought developers should care about optimization more than cutting-corner solutions or jokes.
Source code isn`t so complex as could be.
I did not say it depends on the source complexity.
Well, parser fails at production environment
It depends how you deploy, it also depends on the framework (for example laravel-pug will rely on the template cache of Laravel) and if you pre-compile templates in production (you should).
Then you may cache templates on the production machine if you do it in your deployment script (so it does not impact your users). Else you can compile templates then deploy the whole thing on the production machine, this way the production machine will never render any templates.
Finally, I don't think you reached pcre.backtrack_limit because RegExp run into an excessive backtrack loop. I think you more likely have a smaller limit than the default value (1000000) and a normal application should have at least 1000000.
I thought developers should care about optimization more than cutting-corner solutions or jokes.
That's why you should care about our recommendations for production: https://phug-lang.com/#usage
By following it, you will really optimize the page display and resources consumption. Reducing pcre.backtrack_limit will just force a limit for RegExp calculation, while following caching method will not run those RegExps at all when users load pages.
Hello,
I encountered an issue with the following code:
I expected to get:
But I actually get:
Workaround
Thanks!