Using {{dc:post:excerpt}} in component parameters causes page crash

Hi, I ran into a strange error today: when I enter the following in a component’s parameters:
{
“Subline” : {
“label” : “Subline”,
“type” : “text”,
“initial” : “{{dc:post:excerpt}}”
}
}
…all pages using the component crash.
The problem is {{dc:post:excerpt}}; as soon as I use something like {{dc:post:title}}, for example, there is no issue.
Can you reproduce or explain this?

Hey @Daryl_Shaw,

This crash is caused by an infinite recursion (infinite loop) during the layout rendering process.

Here is exactly why it happens:

1. The Recursive Loop ( ❴❴dc:post:excerpt❵❵ )

When a page containing the component is rendered, Cornerstone evaluates the component’s parameters, including the default/initial value of Subline which is set to ❴❴dc:post:excerpt❵❵ :

  1. Parameter Evaluation : Cornerstone attempts to resolve ❴❴dc:post:excerpt❵❵ for the current post.
  2. Retrieve Excerpt : The dynamic content resolver calls WordPress’s get_the_excerpt() function.
  3. Automatic Excerpt Generation : If the post does not have a manually crafted excerpt (in the WordPress Excerpt field), WordPress falls back to generating one from the post’s body ( post_content ).
  4. Executing [cs_content] : In the Pro theme / Cornerstone, the page content is wrapped inside the [cs_content] shortcode. To ensure that layout content is readable by search engines and excerpt generators, the theme hooks into strip_shortcodes_tagnames to prevent [cs_content] from being stripped.
  5. Render Content : Because it is not stripped, the [cs_content] shortcode executes, starting to render all the elements and components on the page again to extract text for the excerpt.
  6. Nested Evaluation : During this nested render, the layout engine encounters the same component and tries to evaluate its initial parameter values.
  7. Infinite Loop : Evaluating Subline triggers ❴❴dc:post:excerpt❵❵ again, which invokes get_the_excerpt() , which attempts to render the layout, which encounters the component, and so on.
  8. Crash : The execution stack overflows, causing PHP to exceed its maximum nesting level or run out of memory, crashing the page.

2. Why ❴❴dc:post:title❵❵ Works Fine

When you use ❴❴dc:post:title❵❵ :

  • The dynamic content parser resolves this via get_the_title( $post )
  • This function simply reads the database column for the title string and returns it directly. It never triggers the parsing or rendering of post_content (shortcodes), meaning no recursion loop is created.

Workarounds

  1. Avoid Self-Referencing Excerpts in Initial Values : Do not set the default/initial parameter of a component to ❴❴dc:post:excerpt❵❵ directly inside the parameter setup. Instead, set the default to an empty string or standard text, and pass the dynamic content tag only when implementing/consuming the component instance on the page.
  2. Add a Manual Excerpt : If the post/page using the component has a handcrafted manual excerpt defined in the WordPress post editor, WordPress will return it directly and bypass the automatic content parsing, which avoids the loop.

Ok, thanks for quick response!

You’re most welcome, @Daryl_Shaw.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.