- This topic has 13 replies, 4 voices, and was last updated 4 years, 12 months ago by
Elvin.
-
AuthorPosts
-
April 6, 2021 at 4:03 am #1723089
Peter Duggan
WordPress 5.7
GeneratePress theme 3.0.3
GP Premium 1.12.3
WooCommerce 5.1.0
PHP 7.3.21Having just upgraded several things on a site that’s previously been running quite happily, I started getting intermittent fatal errors/white screens. My child theme’s functions.php (originally set up after seeking help here for a few layout issues including the blog sidebar appearing on the shop home page) appears to be involved.
If I deactivate WooCommerce with this functions.php operational, I get the fatal error straight away.
If I deactivate WooCommerce with PHP 7.3 running and this functions.php removed, things work except that I get that unwanted sidebar (haven’t noticed any other changes that bother me).
If I deactivate WooCommerce with PHP 7.4 running, I get the fatal error whether or not this functions.php is there.
I don’t understand why the PHP version changes this, but can replicate the effect.Here’s the functions.php, which is five years old and I’ve currently removed (the only other thing in the child theme is the style.css):
<?php /** * Generate child theme functions and definitions * * @package Generate */ /* https://generatepress.com/forums/topic/remove-metabox-from-posts/ */ add_action( 'after_setup_theme','generate_remove_metaboxes' ); function generate_remove_metaboxes() { remove_action('add_meta_boxes', 'generate_add_layout_meta_box'); remove_action('add_meta_boxes', 'generate_add_footer_widget_meta_box'); remove_action( 'add_meta_boxes', 'generate_add_de_meta_box' ); } /* https://generatepress.com/forums/topic/hide-sidebar-in-woocommerce-search-results-page/ */ add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' ); function generate_custom_woocommerce_sidebar_layout( $layout ) { // If we are on a woocommerce page, set the sidebar if ( is_woocommerce() ) return 'no-sidebar'; // Or else, set the regular layout return $layout; } add_filter('generate_blog_masonry','generate_blog_woocommerce_masonry'); function generate_blog_woocommerce_masonry() { // Disable in WooCommerce if ( is_woocommerce() ) return 'false'; // Check if blog if ( is_home() ) return 'true'; // Otherwise, disable it return 'false'; } /* add_filter( 'generate_blog_get_column_count','tu_search_column_count' ); function tu_search_column_count( $count ) { if ( is_search() ) { return 100; } return $count; } */ add_filter( 'generate_blog_columns', 'tu_disable_search_columns' ); function tu_disable_search_columns( $columns ) { if ( is_search() ) { return false; } return $columns; }So hoping you can help work out what’s wrong here?
April 6, 2021 at 4:05 am #1723092Peter Duggan
Forgot to say I have another GeneratePress site without WooCommerce but also all updated to current and running happily on PHP 7.4.
April 6, 2021 at 6:28 am #1723259David
StaffCustomer SupportHi there,
can you the remove the
/* */comments that contain the URLS in your functions. Not sure if 7.4 is throwing an issue with them being there.April 6, 2021 at 7:06 am #1723562Peter Duggan
Just tried that, but the errors occurred exactly as before. I’ve also tried removing the commented-out function lower down:
/* add_filter( 'generate_blog_get_column_count','tu_search_column_count' ); function tu_search_column_count( $count ) { if ( is_search() ) { return 100; } return $count; } */To leave just this:
<?php /** * Generate child theme functions and definitions * * @package Generate */ add_action( 'after_setup_theme','generate_remove_metaboxes' ); function generate_remove_metaboxes() { remove_action('add_meta_boxes', 'generate_add_layout_meta_box'); remove_action('add_meta_boxes', 'generate_add_footer_widget_meta_box'); remove_action( 'add_meta_boxes', 'generate_add_de_meta_box' ); } add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' ); function generate_custom_woocommerce_sidebar_layout( $layout ) { // If we are on a woocommerce page, set the sidebar if ( is_woocommerce() ) return 'no-sidebar'; // Or else, set the regular layout return $layout; } add_filter('generate_blog_masonry','generate_blog_woocommerce_masonry'); function generate_blog_woocommerce_masonry() { // Disable in WooCommerce if ( is_woocommerce() ) return 'false'; // Check if blog if ( is_home() ) return 'true'; // Otherwise, disable it return 'false'; } add_filter( 'generate_blog_columns', 'tu_disable_search_columns' ); function tu_disable_search_columns( $columns ) { if ( is_search() ) { return false; } return $columns; }But still get the critical error if I deactivate WooCommerce with it like that in PHP 7.3 and (as far as I can see) whether it’s there or not with or without WooCommerce active in PHP 7.4.
April 6, 2021 at 8:57 am #1723687Tom
Lead DeveloperLead DeveloperWhat’s the error, exactly?
Your functions are using WooCommerce-specific functions (
is_woocommerce()), so if you deactivate WooCommerce, this will return an undefined function fatal error. To prevent that, you can replace this throughout your code:is_woocommerce()With this:
function_exists( 'is_woocommerce' ) && is_woocommerce()April 6, 2021 at 9:17 am #1723712Peter Duggan
Sorry I haven’t got exact error codes just now because I couldn’t got them to log with WP_DEBUG and WP_DEBUG_LOG. But it’s some variant of the ‘There has been a critical error on this website. Please check your site admin email inbox for instructions.’ white screen thing, on which note I’m not getting the emails either.
I’ll try modifying those functions as you suggest, but please note also that I’m getting the fatal errors running PHP 7.4 even when I remove the child theme functions.php completely.
I’m willing to supply a login privately for you to take a look if necessary, but want to try everything I reasonably can myself first.
April 6, 2021 at 9:30 am #1723726Peter Duggan
OK, that seems to have fixed the problem when running PHP 7.3 but it’s still crashing with PHP 7.4. But this time I got the email and it said:
Error Details
=============
An error of type E_ERROR was caused in line 773 of the file /****/******/public_html/wp-content/plugins/woocommerce/includes/class-wc-order.php. Error message: Allowed memory size of 41943040 bytes exhausted (tried to allocate 20480 bytes)(I put the asterisks in that!)
PS It also said:
When seeking help with this issue, you may be asked for some of the following information:
WordPress version 5.7
Current theme: GeneratePress Child (version 0.1)
Current plugin: WooCommerce (version 5.1.0)
PHP version 7.4.9April 6, 2021 at 9:36 am #1723736Peter Duggan
Perhaps there’s something wrong with the PHP 7.4 in my cPanel if it’s now sorted with PHP 7.3? Except that my other GeneratePress site (with no WooCommerce) is running fine with PHP 7.4…
April 6, 2021 at 1:45 pm #1723994Peter Duggan
Just to add that this didn’t start with me wanting to deactivate anything, but rather updating the PHP so I could update WordPress and WooCommerce. So it was only when the site starting crashing after going from PHP 5.6 (I think) to 7.4 that deactivating/reactivating plugins to test along with trying PHP 7.2 and 7.3 led me to PHP 7.4, WooCommerce and my child theme as the combination that doesn’t seem happy under any circumstances.
April 6, 2021 at 6:31 pm #1724100Elvin
StaffCustomer SupportHi there,
Do you have access to your wp-config.php file? (FTP or file manager)
Can you try changing your memory limit?
https://docs.generatepress.com/article/increasing-php-memory-limit/
https://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/comment-page-1/And then try PHP 7.4 again and let us know if it still occurs.
April 7, 2021 at 1:49 am #1724362Peter Duggan
Yes, I do and I can, thanks!
I didn’t think to try this before because the WooCommerce system status was reporting ‘WordPress memory limit: 256 MB’. So I checked the PHP 7.4 on another of my sites (same host) with phpinfo() and discovered ‘memory_limit 32M’ there, then the PHP 7.3, which was ‘memory_limit 128M’. So the PHP version assigned by my cPanel has for some reason been set up with a much lower limit for PHP 7.4 which is enough for my simpler GeneratePress site without WooCommerce etc. but not for the one that’s been crashing. And my child theme functions.php was an unfortunate red herring from trying to test systematically by deactivating/reactivating plugins, but now better off for being rewritten with function_exists anyway.
So I’ve now allocated 256MB via wp-config.php, the site’s running with PHP 7.4 and I’m going to be marking the topic as resolved (thanks!), but have just one more question first:
Any idea why WooCommerce system status would be reporting a WordPress memory limit that’s greater than what’s actually available? (I know this isn’t a GeneratePress issue, but I’m curious because it has been involved in the solution and also why I didn’t suspect memory sooner.)
Thanks
PeterApril 7, 2021 at 3:22 pm #1725461Elvin
StaffCustomer SupportAny idea why WooCommerce system status would be reporting a WordPress memory limit that’s greater than what’s actually available? (I know this isn’t a GeneratePress issue, but I’m curious because it has been involved in the solution and also why I didn’t suspect memory sooner.)
The value you see is the mem space used. It being greater means the plugin’s required memory exceeds the 32M.
The solution is actually found on the documentation – https://docs.woocommerce.com/document/increasing-the-wordpress-memory-limit/
April 8, 2021 at 12:38 am #1725759Peter Duggan
Yes, I’d seen that page already, but took 256M as an example (suggestion?) rather than a requirement. The WooCommerce requirements page at https://docs.woocommerce.com/document/server-requirements/ actually specifies ‘WordPress memory limit of 128 MB or greater’ and our (small-scale) installation has clearly been running quite happily with 128M (just not the 32M that my PHP 7.4 was set up with!). But it really doesn’t matter now because we’re digressing from GeneratePress when you’ve already helped me sort the issue, so I’m going to say thanks now and mark this as resolved. 🙂
Thank you
PeterApril 8, 2021 at 2:59 pm #1726914Elvin
StaffCustomer SupportNo problem. Glad you got it sorted. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.