Template tags are not parsed under certain conditions

Hi there,

I am currently developing our website based on ModX3. Before that we used ModX2.

I noticed that ModX3 template tags no longer processed properly under certain circumstances. At some point in processing, the template tags are simply rendered as text and not parsed.

So I took a closer look at the source code and found the following during testing:

The “collectElementTags” function in modParser has been revised and now relies on the “preg_match_all” function. If you are using PHP lower than version 7.4, preg_match_all only processes strings up to a length of 2060 characters in connection with the “PREG_SET_ORDER” option. Once the string is 2061 characters long, preg_match_all quietly stops processing the string. As a result, all following template tags are no longer processed.

I tested this under PHP 7.2 and 7.3. As of 7.4, preg_match_all handles the string correctly and all Template Tags are parsed properly.

I created a small script to test this: https://www.dropbox.com/s/p6ujmkihadr1s9q/test.php?dl=0

Can you test if this pull request fixes the problem?

I already applied this patch, but this won`t fix the problem

Apparently the problem lies in the PCRE JIT compiler. If you disable this, everything works as desired again.

Reference: php - RegEx not working for long pattern PCRE's JIT compiler stack limit - PHP7 - Stack Overflow

It looks like you have thoroughly analyzed the problem.

You should probably open an issue on github. Github is a better place to discuss such a bug and how it could be resolved.