• Resolved Robin Labadie

    (@robin-labadie)


    Hi again,

    Following up with https://wordpress.org/support/topic/fatal-error-with-2-2-0

    Now it triggers a very high memory_limit. First 512M

    AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /var/www/vhosts/site.com/httpdocs/wp-includes/class-wp-term-query.php on line 311; PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /var/www/vhosts/site.com/httpdocs/wp-includes/class-wp-recovery-mode.php on line 170'

    So I increased memory_limit from 512M to 1G, still hits memory_limit.

    AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/site.com/httpdocs/wp-content/plugins/content-control/inc/functions/compatibility.php on line 238'

    Disabling the plugin fixes the issue right away.

    Issue happens when visiting homepage with a user (or as a non logged-in visitor) that doesn’t have the right to see articles showed on the list on home page. When logged in as admin, I can’t reproduce the issue.

    As for active filters, I’ve got only one filter that will afftect a few roles roles added by WooCommerce & WCFM.

    Rule is as follow (i’m translating from french to english manually so may be some wordings differences) :

    • General / Who can see this content : Connected users
    • General / User Role : Excluding : Customer, Disable Vendor, Subscriber
    • Protection / Protecting Content : Replace Content & Custom Message TICKED ON & Replace default message & Hide the restricted items from the archive page. & Hide the restricted items from the list page.
    • Content : Content is A publication with category (custom category name) OR if content is A Selected Category (same custom category name).

    I hope this helps.

    Thank you

Viewing 12 replies - 16 through 27 (of 27 total)
  • Tecca

    (@tecca)

    Yes, WooCommerce for me as well.

    Plugin Author Daniel Iser

    (@danieliser)

    @tbob21 – Are you confirming this filter was still running outside the rest API in v2.2.2?

    Its neccessary for properly handling restricted terms in the REST API, and I’m struggling to duplicate the errors on a test site.

    I’m gonna try your suggestion for WooCommerce pages and gutenberg next to see if that triggers it.

    Hate patching any more but feel I want to try and stop the bleed for anyone newly updating. I really need to nail down the cause though so I can properly address it and re-enable it for everything else.

    Look for a patch shortly for 2.2.3. I’m probably not gonna comment that out, but rather run some more specific checks inside the query filter itself to only apply to taxonomy archives in the REST API.

    If anyone is able to test that solution before I waste another version patch I’d love your assistance.

    Plugin Author Daniel Iser

    (@danieliser)

    Ok I seem to have triggered a nesting error when going to edit a product in WooCommerce, commenting that out does resolve it. Good news is I can use this hopefully to figure out exactly what’s going wrong.

    Report back shortly.

    Thread Starter Robin Labadie

    (@robin-labadie)

    Thanks a lot for the updates!

    Please keep it up, I’m sure you’re on the right way!

    Plugin Author Daniel Iser

    (@danieliser)

    @robin-labadie – Or anyone else, if you can test this really quick and confirm it resolves the issue It would be very helpful.

    I’m trying to keep it as generic as possible, rather than a WooCommerce specific solution, I made it simply check if the current query is same as the last

    Edit file: wp-content/plugins/content-control/inc/functions/restrictions.php

    Around line 148 you should see this if ( $query instanceof \WP_Term_Query ) {

    Copy the section below and add it after the foreach loop near the bottom of that section.

    	if ( $query instanceof \WP_Term_Query ) {
    		...
    		foreach ( (array) $taxonomies_to_ignore as $taxonomy ) {
    			if ( in_array( $taxonomy, $query_taxonomies, true ) ) {
    				return true;
    			}
    		}
    
    ----- COPY BELOW HERE
    		static $last_term_query = null;
    
    		if ( $last_term_query && doing_filter( 'get_terms' ) &&
    		(
    			$query === $last_term_query ||
    			wp_json_encode( $query->query_vars ) === wp_json_encode( $last_term_query->query_vars )
    		)
    		) {
    			return true;
    		}
    
    		$last_term_query = $query;
    ------- COPY ABOVE HERE
    	}
    • This reply was modified 10 months ago by Daniel Iser.
    Plugin Author Daniel Iser

    (@danieliser)

    Effectively to check conditions we set the global $post and call setup_post, this makes most WP conditionals just work, such as is_post() etc.

    In the case of WooCommerce, they tap into the_post (called within setup_post), to setup their global $product var, which also calls for taxonomy data, making queries.

    Thus, WooCommerce makes tax query, our rule engine sets global post to check if any restrictions apply to this query, this then triggers WooC to set the global $product, making a new tax query, and on and on.

    Thread Starter Robin Labadie

    (@robin-labadie)

    So I’ve updated the plugin (that erases the previous patch), then applied the proposed code. It appears to work properly for me.

    It appears that you nailed the bug. Probably time for a new patch? I know that’s a lot in a few days but yeah, when a bug like this appears, that’s necessary.

    Plugin Author Daniel Iser

    (@danieliser)

    Patch incoming :), was just waiting on someone else to confirm..

    Thread Starter Robin Labadie

    (@robin-labadie)

    Lucky I’m away at night from France then! πŸ˜€

    Hoping for the best for this deploy.

    Plugin Author Daniel Iser

    (@danieliser)

    @robin-labadie – Its available now.

    Thread Starter Robin Labadie

    (@robin-labadie)

    Confirmed still working after updating, thank you!

    I may bother you with another issue related to performance soon. Sorry in advance. πŸ™‚

    heresthecavalry

    (@heresthecavalry)

    Sorry to say my property pages broke with the update. The front end feature categories, the galleries, and the maps widget loaded ok but the booking calendar and the jet reviews form didn’t. I have full screenshots of both if it helps. I’ve reverted to a back up and it’s ok at the moment. I’ve also got a job to do on the site. But if you need a look let me know. Both Jet Reviews and the WP Booking System plugins are well-established and in widespread use.

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Critical bug: memory_limit reached with 2.2.1’ is closed to new replies.