mhawksey / wp-evidence-hub

OER Research Hub - WordPress plugin
6 stars 1 forks source link

"hypothesis_summary" shortcode, the_excerpt function recursion [LACE]+ #33

Closed nfreear closed 10 years ago

nfreear commented 10 years ago

The OER Map site periodically crashes, and we had determined that this was caused by the Web server running out of memory. We also found that the MySQL server was closing connections without an error message, which can be caused by dynamically generated queries which exceed a specified size.

Through research for bug #31, I've determined that a call to the WordPress function the_excerpt() within the short-code rendering, it can lead to unintentional recursion. This happens when there is no explicit "excerpt" for the the post - the excerpt is auto-generated from the main post content - if the post itself contains short-codes, then these are evaluated, and recursion occurs...

Simplified PHP:

<?php
class Evidence_Hub_Shortcode_Hypothesis_Summary {

    const SHORTCODE = 'hypothesis_summary';
//...
    protected function add_to_page($content) {
        if (/* is post-type with shortcode */) {
            if (get_option( 'hypothesis_template_page' )) {
//...
                    $content = 
//...
                         . the_excerpt() . $included_page->post_content;   //<<<<<<< Line 48
//...
    }
}
nfreear commented 10 years ago

Fixed on OER Map, LACE live sites etc.