Support » Plugin: Easy Upload Files During Checkout » Hook on wp_handle_upload throws fatal error

  • Resolved peachpay


    I am using wp_handle_upload in my plugin. However, I believe your plugin has a hook on that function. It gets a WC session:

    $wc_session = WC()->session;

    Then it throws a fatal error when trying to use that null object.

    Can you change it somehow so that it does not affect other plugins using wp_handle_upload, or provide advice on how we can be compatible with your plugin? Thank you!

    Example stack trace:

    #6 /plugins/easy-upload-files-during-checkout/inc/functions.php on line 1556
    #5 /plugins/peachpay-for-woocommerce/peachpay.php(441): peachpay_process_upload(Array, 0)
    #4 /plugins/peachpay-for-woocommerce/peachpay.php(488): wp_handle_upload(Array, Array)
    #3 /includes/file.php(987): _wp_handle_upload(Array, Array, NULL, 'wp_handle_uploa...')
    #2 /wp-admin/includes/file.php(754): apply_filters('wp_handle_uploa...', Array)
    #1 /wp-includes/plugin.php(212): WP_Hook->apply_filters(Array, Array)
    #0 /wp-includes/class-wp-hook.php(287): eufdc_check_file_type_before_upload(Array)
    Stack trace:
    [05-Feb-2021 01:12:33 UTC] PHP Fatal error:  Uncaught Error: Call to a member function set() on null in /plugins/easy-upload-files-during-checkout/inc/functions.php:1556
Viewing 5 replies - 1 through 5 (of 5 total)
  • @peachpay we will review your suggestion.

    Thank you.

    @peachpay please try the latest version. Your issue is resolved.

    Thread Starter peachpay


    It looks like the error is still there.

    The function eufdc_check_file_type_before_upload has the line $wc_session = WC()->session;, and it does not check for null $wc_session.

    eufdc_check_file_type_before_upload is the function where the error is coming from.

    Plugin Author Fahad Mahmood


    I am releasing another version, I am surprised that you have good hands in code but you are not trying the appropriate conditions to test if that resolves the error. For just a couple of conditions, I am releasing a new version so you can test. Kindly check with the updated one, if it works?

    FYI, last version was having init hook with session init command but maybe before_upload hook was not considering that part so I am inserting that code snippet within this function differently. I am expecting that you will come up with a solution time if recent change couldn’t resolve your issue.

    Thread Starter peachpay


    Thank you for the quick response Fahad Mahmood! It is working now.

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