I’ve just noticed a problem with pthumb and PHP8 in that filtering doesn’t work. It is mentioned on Github but thought I’d raise it here as others may not have noticed it.
This is my call:
*Image1:pthumb=`fltr[]=clr|50|000000&w=2696&q=80`
If I remove the filter the image is processed.
Where exactly?
Is the problem the pThumb extra, or MODX, or the PHP library phpThumb that is used by MODX and pThumb?
In the github issue you linked, it is mentioned that the problem is the []
that doesn’t get parsed properly.
Can you apply this pull request in MODX 3.0.3 and check if that fixes the problem?
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.
2 Likes
markh
March 1, 2023, 10:20am
5
Instead of manually patching, there is also a nightly build for 3.0.4 available that includes the fix if you’re more comfortable running an upgrade than fixing individual files.
2 Likes
Thank you chaps, I’ve patched manually and will upgrade when 3.0.4 is ‘official’.