• I have the following in a dynamic block callback which renders block – apply_filters(‘the_content’, $post_content). If it appears anywhere in the block code, regardless if I am returning early before its used, I get the following error:
    Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in?/hiddenpath/public_html/wp-content/plugins/query-monitor/classes/Backtrace.php?on line?137

    Could this be a bug with Query Monitor?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter justauser034675

    (@woocomuser)

    UPDATE: In my block callback I was checking if (defined(‘REST_REQUEST’) && REST_REQUEST)) for backend detection to exit and presumably Query Monitor runs through my callback function before that’s true?
    …so now I do this “if ((defined(‘REST_REQUEST’) && REST_REQUEST) || is_admin())” – and it exits as expected.

    Maybe a flaw in my code and not Query Monitor? ??

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    I would have to dig into the code in QM to check exactly what it does with regard to detecting blocks within post content, but calling apply_filters('the_content', $post_content) on code that is itself processed within post content sounds risky because it can lead to an infinite loop. That might be what is happening in QM.

    Thread Starter justauser034675

    (@woocomuser)

    thanks John, you’re right with the recursion conclusion. No need to check your code, if query monitor didn’t burn out the memory something else would have ??

    FYI the block I’m using is placed inside a Kadence element of type template. It is set to replace the post content template. So there’s no risk to frontend. However on the backend the problem arose because rest checks weren’t triggering my default preview id so I think it was attempting to load itself, as kadence element is a cpt. I think I’ve solved it with the addition of the is_admin() check.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.