MODX 3: Generated "[[!…" (don’t cache) tags seem not to work anymore

Hmm, Askimet has hidden my post. Trying again.

I made two small chunks, to be sure:

some_chunk

<p>Some chunk!</p>

other_chunk

<p>Other chunk!</p>

and used:

[[*class_key:reflect]]
[[[[*class_key:reflect:is=`CollectionContainer`:then=`!$some_chunk`:else=`$other_chunk`]]]]

What I get on the web page:

Auswahl_181

Auswahl_180

I still can’t reproduce this.

Do you have other extras installed that may overwrite the behaviour of the default MODX parser? Maybe pdoTools?

You can also reproduce it by creating a template var some_tv with a default text of Some template var! and using the two chunks above:

[[*some_tv]]
[[[[*some_tv:is=`Some template var!`:then=`!$some_chunk`:else=`!$other_chunk`]]]]

it will never expand the chunks but just display the text.

It is still a rather rudimentary site. Installed extras are:

  • Ace 1.9.2-pl
  • Collections 4.0.0-beta1
  • examplemodxblog 0.0.2-dev1 (modified)
  • getPage 1.2.5-pl
  • getResourceField 1.0.3-pl
  • getResources 1.7.0-pl
  • GoogleSiteMap 2.1.2-pl
  • Markdown Editor 1.1.0-pl
  • pThumb 2.3.3-pl
  • Resizer 1.0.2-beta
  • Tagger 2.0.0-alpha1
  • translit 1.0.0-beta
  • UpgradeMODX 2.3.1-pl

I don’t see anything in this list of extras that likely affects the MODX parser.


Unfortunately, I can’t reproduce this as well.

Darn. What else can I do to diagnose this? My daughter is already desperate to get her site up and running again… (and I was the one to tell her “always do the updates”… sigh)

Btw, the MODX Updater suggests to update to MODX 3.0.1-DEV (shown red). Should we do that?

Is it possible to make a fresh MODX3 installation on the same environment (maybe in a subfolder or a subdomain), to check if this is a general problem (on this environment) or if something is just corrupted on your current installation?


I don’t think this is an official release. So an update may not be a great idea.

Hm. Not so easy, due to .htaccess stuff. We might try on a subdomain, but it’ll take some time, I fear.

Best testing strategy? Would you agree with…

  • Installing a “naked” MODX 3
  • Setting up a test file using a calculated [[!…
  • Installing one extra at a time, then testing again

Thanks, so we won’t upgrade to any “-DEV” version.

Does MODX 3 have any known problems with certain PHP versions? (We currently run it on PHP 7.4.28.)

I wonder why others haven’t been hit by this yet…

Not that I know of. The download page says that 7.4 is “Recommended for Production” and 8 is “Supported”.

I haven’t seen anything similar here in the forum or on github. It doesn’t seem to be a widespread issue.


  • Is a simple uncached tag like [[!$some_chunk]] also not processed or only when it’s nested inside another tag?
  • Is there a system setting parser_max_iterations (and if “Yes”, what is the value)?
  • What is the “Content Type” of your resource? Under “Content” → “Content Types” is the checkbox “Binary” for this content type unchecked?

Unless I’m misunderstanding your needs, you could replace that tag in your original post with a pretty simple snippet, like this:

New Tag:

[[!SelectChunk]]

Snippet:

/* SelectChunk snippet */
$chunkName = 'blog_article';

if ($modx->resource->get('class_key') == 'CollectionContainer') {
    $chunkName = 'blog_listing';
}

return $modx->getChunk($chunkName);

It will be faster and it should avoid any possible nesting, cache, or interference issues, though it doesn’t help determine whether or not you’ve discovered a bug in MODX 3.

No, not processed. Same applies to TVs like [[!*some_tv]].

Nope.

Eventually HTML.

Yes.

Same: Displays as [[!SelectChunk]].

I really suspect either the tag parser has a bug or the 2→3 upgrade process messed something up.

In the last 3 months, most problems related to MODX 3 and the parser were caused by a change in how output modifiers are parsed. So although your problem seems to be different, maybe try changing this line in the code

to this (how it was in MODX 2.x)

if (preg_match_all('~:([^:=]+)(?:=`(.*?)`[\r\n\s]*(?=:[^:=]+|$))?~s', $modifiers, $matches)) {

and see if that helps.

1 Like

Do you have the FastField extra installed?

No, still only the ones mentioned above (plus updates of those).

@halftrainedharry: Wow, your proposed change actually worked! Thanks a bundle.

I changed /core/src/Revolution/Filters/modInputFilter.php as proposed, had to clear MODX’ cache and voilà—all back to good!

Being a change in core, we now of course fear it might be overwritten with the next update. Maybe this could also be tested by others and possible (re-)included in the release?

Thanks for all your help so far.

1 Like

The mystery is why this isn’t happening to everyone. I have several MODX 3 installs that are parsing tags perfectly.

It may be a clue that I don’t use output modifiers at all and tend to avoid deeply nested tags.

I introduced the changes causing this issue. See Fix the parser when using nested output filters by JoshuaLuckers · Pull Request #14458 · modxcms/revolution · GitHub

@opengeek can you take a look at my comment in the PR about reverting the change?

2 Likes

I saw the comment. I have not seen a PR that reverts these changes. Can you submit one so we can get this taken care of?

1 Like

Thanks again for all your help and valuable feedback, @halftrainedharry, @bobray, @joshualuckers and @opengeek!

I still feel a little uneasy about marking a solution here, for fear it might “go under” and not been officially fixed in core—possibly leading to a future upgrade overwriting the core change and breaking the sites again.

Personally, I’m not deep enough into MODX to see what side effects reverting PR #14458 actually might have, and what kind of tests would have to be written to ensure it works correctly. Then again, it seems the previous code has been working fine over years and years (and the change back solved our problems here), so I’d opt for reverting it back—ideally in a way that maybe also fixes the problem the PR was originally written for.

Unfortunately, this is currently all a little over my head, being more of a happy longtime user of “the best” CMS, after years of evaluating others. So what can we do to ensure the best possible experience for all MODXers with this issue?

Oh, and heartfelt thanks from my daughter (who silently follows this thread)—she was really impressed how problems are handled and solutions generated here in the MODX community. She actually borrowed all my MODX books on her last visit, and started following Bob’s Guides. (Love my kids! Maybe time to hand things over to the next generation, hee hee…)

2 Likes

Thanks for the kind words. I’m glad we could help, though halftrainedharry did the heavy lifting.