• Resolved Jeff Starr

    (@specialk)


    Hello, upgrading to EDD version 3.2.0 crashed my site, fatal error:

    PHP Fatal error: Uncaught Error: Call to undefined function EDD\\Blocks\\Checkout\\Functions\\checkout_has_blocks() in /wp-content/plugins/easy-digital-downloads/includes/cart/template.php:23
    
    Stack trace:
    
    #0 /wp-content/plugins/easy-digital-downloads/includes/checkout/template.php(28): edd_checkout_cart()
    #1 /wp-content/plugins/easy-digital-downloads/includes/shortcodes.php(139): edd_checkout_form()
    #2 /wp-includes/shortcodes.php(395): edd_checkout_form_shortcode()
    #3 [internal function]: do_shortcode_tag()
    #4 /wp-includes/shortcodes.php(235): preg_replace_callback()
    #5 /wp-includes/class-wp-hook.php(310): do_shortcode...'

    Rolling back to version 3.1.5 resolved the issue completely.

    PS: already submitted a support ticket (via your site), please leave this thread open for the sake of other users who may be experiencing the same issue, thank you.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Support Mihai Joldis

    (@misulicus)

    Hey @specialk

    You should have the EDD 3.2.1 update available to update. Please install that and see if you still have the issue.

    Also please check if you have the old EDD Blocks plugin active and if you do, you can remove it as it’s no longer needed.

    Thread Starter Jeff Starr

    (@specialk)

    Yep same issue with 3.2.1.

    Not using any blocks stuff.

    Plugin Author Chris Klosowski

    (@cklosows)

    @specialk

    Thanks for the information. I’ve replied to your support ticket with some more details but in case anyone else has this same error come up, we’ve had people run this version successfully by reinstalling via uploading a .zip file.

    This release had many files changed as we updated some of our dependency libraries for PHP 8.1 support and it is possible that the server failed to copy one or more files into place properly. The link to download the latest version is located here: https://downloads.www.ads-software.com/plugin/easy-digital-downloads.zip

    I got this too, but only with one custom theme that uses Timber/Twig. I tested on a couple of other sites in Twentytwelve, Themedd, and another custom Timber theme, without error. I resolved on my breaking site with this snippet:

    use function EDD\Blocks\init_core_blocks as edd_init_core_blocks;
    
    /**
     * ensure that EDD core blocks are loaded for checkout page, since EDD 3.2.0
     */
    add_action('wp', function() : void {
    	if (edd_is_checkout() && !defined('EDD_BLOCKS_DIR')) {
    		edd_init_core_blocks();
    	}
    });

    Maybe worth mentioning, my site that requires this fix is a multisite non-primary site running the Classic Editor plugin set to Classic editor by default and allowing switch editors — I edit posts in Classic editor, pages in Block editor.

    Plugin Author Chris Klosowski

    (@cklosows)

    @webaware Thank you for the details. I’ll note this on our logged issue

    Thread Starter Jeff Starr

    (@specialk)

    @cklosows Thanks I will investigate further and report back. Also please leave this thread marked as “not resolved” until it actually is resolved, thank you.

    @webaware Thank you for sharing this information. Also do you happen to know, on your site is it only the checkout page that produces the error?

    • This reply was modified 1 year, 5 months ago by Jeff Starr.
    Plugin Author Chris Klosowski

    (@cklosows)

    @webaware I know this is a longshot, but is it possible to get a copy of the theme you’re working with? Maybe even just a super slimmed down version of it that I can replicate with?

    You can email it directly to me through our support@easydigitaldownloads.com email address. That way I can ensure I’m replicating. I’m still not able to reproduce this with a number of combinations of plugins that have been discussed.

    @specialk when I tested, it only happened on the checkout. It happens because the checkout rendering function calls checkout_has_blocks() to see whether it should continue or not. Not defined unless EDD core blocks have been initialised. It used to check whether that function exists before calling it, but no longer checks since v3.2.0

    @cklosows will do.

    Plugin Author Chris Klosowski

    (@cklosows)

    @webaware Thanks for sending in your plugin and theme you are using.

    I found the issue and it is a result of this in your plugin for edd modules.

    /**
     * fully disable EDD blocks, so that its CSS and JS are not loaded everywhere
     */
    add_action('plugins_loaded', function() {
    	remove_action('plugins_loaded', 'EDD\\Blocks\\init_core_blocks', 500);
    }, 499);

    Two notes to make:

    1. We previously conditionally checked for the function to exist because our blocks only worked with WordPress 5.8 or greater, but EDD supported WordPress 5.4 or greater, so the blocks would only render and load on 5.8 or greater.
    2. Since 3.2.0, we sorted out the JS and CSS loading on every page and it only loads the CSS or JS if the page contains the block now.

    @specialk I’m not sure if you are doing something similar and removing our block loading (since your site doesn’t use blocks), but that might produce the same error. We’re going to look into a way to prevent the fatal error if someone fully unhooks our init_core_blocks function, and possibly add back in the function exists check for a further prevention of this issue.

    Thread Starter Jeff Starr

    (@specialk)

    @webaware Thank you for the code snippet, it works perfectly. As in your case, the fatal error was happening only on the Checkout page, other pages were unaffected. And also I am using the Classic Editor via Disable Gutenberg plugin. Again, thanks for sharing your solution, much appreciated.

    @cklosows I appreciate your concern and help. The site is not altering any default block loading, but as explained is using Disable Gutenberg to restore the Classic Editor. Also tried re-uploading the latest version from scratch via SFTP (instead of doing one-click admin update), and that did not work, I got the same error on checkout page. Fortunately @webaware’s code snippet worked to resolve the issue. Hopefully you can get this fixed up in a future update of EDD.

    Plugin Author Chris Klosowski

    (@cklosows)

    @specialk Yes, we are going to fix it in the next version and put back the function_exists check to the template loading. I also tried with the Disable Gutenberg Plugin but couldn’t replicate the issue.

    This leads me to believe it’s somewhere in the logic of the theme loading and possibly including files in an order we are not expecting. Since it’s impossible to think of all the ways a theme or plugin could call our function for the cart template, the function_exists check should ensure it doesn’t happen again.

    @cklosows duh! Of course, I forgot that (it was a while ago!) I can confirm that not doing the dumb thing stops breaking it in the dumb way, thanks for spotting that. Will remove the fix, and the bork, from the live site now. I guess I’m not doing that on the other site that isn’t breaking (and will remove the fix from there too now).

    cheers,
    Ross

    Thread Starter Jeff Starr

    (@specialk)

    @cklosows Just checking on this:

    “Yes, we are going to fix it in the next version and put back the?function_exists?check to the template loading.”

    Can you confirm this in the latest EDD? Would be great to remove the workaround snippet. Thank you.

    Plugin Support Mihai Joldis

    (@misulicus)

    Hey @specialk

    That check was added as of EDD 3.2.2 so it is available in the latest versions for a while now.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘PHP Fatal Error in latest version’ is closed to new replies.