-
Notifications
You must be signed in to change notification settings - Fork 0
Description
There's a new block in the Gutenberg plugin called post-content
. I've discovered multiple ways of causing Gutenberg to go into an infinitely recursive loop. While trying to reason what the output should be when recursion is detected, I created a test case using the [bw_pages]
shortcode which was equivalent to the scenario I'd tried using FSE. Two pages that would recursively embed each other ad infinitum.
Imagine my surprise when I discovered that my shortcode suffered the same problem.
Steps to reproduce
- Create two identical pages with the same shortcode. One called A, the other called C.
[bw_pages post_type=page format="T d e/C" post_parent=0 orderby=title numberposts=3]
- Create two other pages B and C - with normal content.
- Attempt to view either A or C.
- Wait a long time.
Details
In order to create a display that's a bit more understandable I decided it might be easier to
create 4 pages to be used in the test scenario.
A and C contain the problematic shortcode.
B and D are just for a bit of padding.
Page | Content |
---|---|
A | [bw_pages] shortcode |
B | plain content |
C | [bw_pages] shortcode |
D | plain content |
Expected output
Note: Both [bw_pages]
and core/post-content
attempt to prevent the recursion by excluding themselves from the result set.
When the shortcode's format
parameter doesn't include C
- for Content - then the problem shouldn't occur.
Try this with E
for Excerpt.
When viewing A, with format="T e / C" the processing should be:
- A's content before the shortcode should be displayed
- A runs
[bw_pages]
which returns B, C and D - B is formatted: Title edit and the rendered content
- C is formatted: Title edit
- And content is expanded.
[bw_pages]
returns A, B and D - A is formatted: Title edit
- Recursion is detected
- B is formatted as before
- D is formatted
- And content is expanded.
- C's content after the shortcode is rendered
- D is formatted
Here's the screen capture for A
And here's the screen capture for C
Additional notes
I added another line of code into the bw_pages()
function that prevents double expansion of the top level post.
// Don't process the current post inside the loop
bw_process_this_post( $cp );