ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Indexing is broken when plugins output directly during post content

Open tomjn opened this issue 2 years ago • 2 comments

Describe the bug

If a plugin has a shortcode that outputs directly rather than returning content, or tries to hook in to display extra output at a later date ( e.g. Gravity Forms ). This breaks the output of syncing and can stop the sync if it was triggered in the Admin UI

Steps to Reproduce

  1. install a plugin that echo's rather than returns its content in a shortcode or block
  2. use that in a post
  3. Trigger an index from WP Admin
  4. Watch as it fails to parse the output due to the stray HTML, and syncing stops

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress and ElasticPress information

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

tomjn avatar Feb 20 '23 17:02 tomjn

We will need a specific (free) plugin with specific steps for this one, @tomjn, as the documentation specifically states that:

Note that the function called by the shortcode should never produce an output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode.

felipeelia avatar Feb 21 '23 16:02 felipeelia

Indeed I'm a strong proponent of that, unfortunately lots of new WP devs are unfamiliar with this, I've even had some outright rebel in disbelief when I tell them :( . An output buffer should suffice to mitigate this in the meantime.

tomjn avatar Feb 21 '23 21:02 tomjn