robh76
July 16, 2023, 6:28am
1
Just upgraded from Modx 2.84 to Modx 3.03-pl, now I have this problem…
This works fine:
[[!isMemberPricing:is=‘1’:then=‘Hello World’]]
but this doesn’t work and literally just prints out the whole thing to screen:
[[!isMemberPricing:is=‘1’:then=‘[[~723459]]’]]
I know there are various threads on this which suggest mods to the ModInputFilter.php and ModOutputFilter.php core files, including this one which I’ve tried and doesn’t work for me:
(Revert and break nested output filters by JoshuaLuckers · Pull Request #16254 · modxcms/revolution · GitHub )
Does anyone have a resolution for this issue?
MODX 3.0.3 still has some parser problems.
Usually applying these two PRs fixes the issue:
modxcms:3.x
← Mark-H:302-fix-brackets
opened 01:51PM - 17 Nov 22 UTC
### What does it do?
Fix where literal brackets (not intended as an opening/clo… sing tag) go in the parsed command modifiers.
### Why is it needed?
John MacDonald reported the parser breaking in the following scenario:
```
[[++google_analytics:notempty=`
<script async src="https://www.googletagmanager.com/gtag/js?id=[[++google_analytics]]"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '[[++google_analytics]]');
</script>
`]]
```
Rather than outputting the script, it returned just the value of `[[++google_analytics]]`.
That test case was simplified to ```[[+tag:notempty=`[]`]]``` as the literal brackets appeared to be the problem.
Internally, the command ended up as `notempty[]` with an empty modifier. The `notempty[]` command doesn't exist so the original value is returned in its place.
By using the `$inModifier` flag (which gets set in the switch case for ``` ` ``` when depth is 0) the brackets are parsed into the modifiers as they should.
### How to test
See tests for examples. Feel free to come up with more complex cases.
### Related issue(s)/PR(s)
Reported via Slack.
Introduced with #16288 in 3.0.2.
modxcms:3.x
← Mark-H:issue-16263
opened 01:02AM - 02 Dec 22 UTC
### What does it do?
Improves the regex pattern used in modParser::collectEle… mentTags() to avoid hitting a backtrack limit under some environments (PHP 7.2, 7.3). Also adds a log message in case an error is detected.
Credit to @JoshuaLuckers for providing the patch.
### Why is it needed?
Make sure long tags can be parsed correctly and make debugging easier if something does fail. Please see #16263 for more details.
### How to test
Please see #16263 for more details. It's worth noting I've so far seen 3 people refer to the fix in the issue as fixing the issue they had. As with all parser tweaks, trying it out on different real sites would be preferred to ensure this doesn't introduce any new issues.
[Here's a CI run of the unit test prior to applying the fix](https://github.com/Mark-H/revolution/actions/runs/3597851277/jobs/6060109440), to show the unit test and fix work.
Locally I've also been able to reproduce it by running the test on 7.2 before:
```
➜ 3.x git:(issue-16263) ✗ php core/vendor/bin/phpunit _build/test/Tests/Model/modParserTest.php
PHPUnit 8.5.31 by Sebastian Bergmann and contributors.
..........................................................[1] 78526 segmentation fault /Applications/MAMP/bin/php/php7.2.34/bin/php -c core/vendor/bin/phpunit
```
and after applying the fix:
```
➜ 3.x git:(issue-16263) ✗ php core/vendor/bin/phpunit _build/test/Tests/Model/modParserTest.php
PHPUnit 8.5.31 by Sebastian Bergmann and contributors.
........................................................... 59 / 59 (100%)
Time: 181 ms, Memory: 14.00 MB
OK (59 tests, 70 assertions)
```
(I'm doing `php core/vendor/bin/phpunit` because otherwise php can't get to mysql on my local machine.)
### Related issue(s)/PR(s)
Fixes #16263
Or alternatively install the latest nightly build .
robh76
July 16, 2023, 10:24am
3
Thank you - I just can’t get this to work. However, since it only affects one page on my website, I think I’m just going to forget the Modx filters and build the whole thing into a custom snippet. Not the best solution but should at least do the job.
Does it work if you use the link tag uncached?
[[!isMemberPricing:is=`1`:then=`[[!~723459]]`]]
system
Closed
July 19, 2023, 9:48am
5
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.
bobray
July 21, 2023, 5:46am
6
I have run in to a few cases where adding an &else property (e.g., &else=""
) straightened out the parsing.