Weird effects with nested items (cached, uncached) #13250

Open
pixelive opened this Issue Jan 12, 2017 · 7 comments

Projects

None yet

5 participants

@pixelive
Contributor
pixelive commented Jan 12, 2017 edited

Summary

Weird effects with nested items. Although the use cases are a bit weird and probably give wrong results, it should not give broken results like it does now.

Step to reproduce

I simplified the cases a bit.

Case A
Create a chunk called 'rowChunk' with the following content:

[[+rows]]

Create a chunk called 'equalChunk' with the following content:

[[!++site_url:notempty=`<p class="success">[[!++site_url]]</p>`]]

Put this in your template:

[[$rowChunk?
&rows=`[[$equalChunk]]`
]]

Case B
Create a chunk called 'rowChunk' with the following content:

[[+rows]]

Create a chunk called 'longChunk' with the following content:

[[!longSnippet? &value=`Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. 
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. 
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. 
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. 
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. 
Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. 
Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper 
ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing 
sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. 
Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. 
Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,
quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, 
nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante 
ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. 
Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a,
consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum
volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id,
imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet
imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non,
euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu.
Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam`]]

Create a snippet called 'longSnippet' with the following content:

<?php
$value = $modx->getOption('value', $scriptProperties, '');

return $value;

Put this in your template:

[[$rowChunk?
&rows=`[[$longChunk]]`
]]

Observed behavior

Case A
It shows no output at all, but if I remove 'class="success"' it works. Making the !$rowChunk or the !$equalChunk uncached also works. But the case as described breaks.

Case B
It shows the following:

Sed aliquam`]]`

So not the full string as given.

Making the !$rowChunk or the !$longChunk uncached works. But the case as described breaks.

Expected behavior

Case A
Showing the Site URL.

Case B
Show the given string.

Environment

  • MODX: Tried multiple versions (2.5.0, 2.5.1, 2.5.2, 2.5.4).
  • Nginx
  • Mysql: Ver 15.1 Distrib 10.0.28-MariaDB

I tried multiple encodings and collations.

@Jako
Collaborator
Jako commented Jan 12, 2017

I have noticed something similar with long parameter values lately. Maybe it is a regex limitation. I could bypass it with the mosquito syntax in that installation, but thats not possible everywhere.

[[$rowChunk?
&rows=`[[$longChunk]]`
]]

vs

[[[[$rowChunk?
&rows=`$longChunk`
]]]]
@Bruno17
Contributor
Bruno17 commented Jan 15, 2017

I'm doing it this way:

[[$rowChunk?
&rows=`$longChunk`
]]

and use a placeholder inside the rowChunk like:

[[[[+rows]]]]
@OptimusCrime
Contributor

@Bruno17 Is that syntax working? I thought the two combinations @Jako posted were the ones that work?

Also @Jako I am pretty sure this has nothing to do with regex. The templates are parsed using a lexer/tokenizer, as far as I know.

@Bruno17
Contributor
Bruno17 commented Jan 15, 2017

@OptimusCrime Sure, you pass only the value '$longChunk' into the placeholder [[+rows]], which results in [[$longChunk]] inside the chunk and gets parsed, when the chunk-code is parsed. That's much better than trying to pass the whole long chunk-code into the placeholder. At some point the code in between nested MODX - tags gets to long and breaks the whole thing.

@OptimusCrime
Contributor

Oh. I've never done it like that. Interesting.

@mrhaw
mrhaw commented Jan 16, 2017 edited

What if you set this in your php.ini

;PCRE library backtracking limit.
pcre.backtrack_limit=200000

Read more https://forums.modx.com/thread/45375/phx-and-parser-limits#dis-post-262137

@pixelive
Contributor

@mrhaw does not seem to work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment