• I just updated several websites to v1.0.2 and all of them are displaying critical errors. Please advise.

    An error of type E_ERROR was caused in line 77 of the file /home/user/public_html/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php. Error message: Uncaught Error: Non-static method WC_Legacy_REST_API_Plugin::hpos_is_enabled() cannot be called statically in /home/user/public_html/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php:77 Stack trace: #0 /home/user/public_html/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php(28): WC_Legacy_REST_API_Plugin::maybe_add_hpos_incompatibility_admin_notice() #1 /home/user/public_html/wp-includes/class-wp-hook.php(324): WC_Legacy_REST_API_Plugin::on_woocommerce_init('') #2 /home/user/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /home/user/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/user/public_html/wp-content/plugins/woocommerce/includes/class-woocommerce.php(812): do_action('woocommerce_ini...') #5 /home/user/public_html/wp-includes/class-wp-hook.php(324): WooCommerce->init('') #6 /home/user/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #7 /home/user/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #8 /home/user/public_html/wp-settings.php(695): do_action('init') #9 /home/user/wp-config.php(83): require_once('/home/user/publi...') #10 /home/user/public_html/wp-load.php(55): require_once('/home/user/wp-co...') #11 /home/user/public_html/wp-admin/admin.php(34): require_once('/home/user/publi...') #12 /home/user/public_html/wp-admin/plugins.php(10): require_once('/home/user/publi...') #13 {main} thrown
Viewing 15 replies - 1 through 15 (of 15 total)
  • Yes the latest update causes FATAL error:

    PHP Fatal error: Uncaught Error: Non-static method WC_Legacy_REST_API_Plugin::hpos_is_enabled() cannot be called statically in /home/nginx/domains/example.com/public/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php:77

    The issue arises because the hpos_is_enabled method is non-static, but it is being called statically within the maybe_add_hpos_incompatibility_admin_notice and maybe_remove_hpos_incompatibility_admin_notice methods. To fix this, we need to create an instance of the WC_Legacy_REST_API_Plugin class before calling the non-static hpos_is_enabled method.

    Here’s how you can modify the maybe_add_hpos_incompatibility_admin_notice and maybe_remove_hpos_incompatibility_admin_notice methods to address this issue:

    1. Update maybe_add_hpos_incompatibility_admin_notice Method:

      REPLACE THIS:

      private static function maybe_add_hpos_incompatibility_admin_notice() { if( ! self::hpos_is_enabled() || self::user_has_dismissed_admin_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) ) { return false; } if ( ! WC_Admin_Notices::has_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) ) { $features_page_url = admin_url( ‘admin.php?page=wc-settings&tab=advanced&section=features’ ); WC_Admin_Notices::add_custom_notice( ‘legacy_rest_api_is_incompatible_with_hpos’, sprintf( wpautop( __( ‘? <b>The Legacy REST API plugin and HPOS are both active on this site.</b><br/><br/>Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS. <a target=”_blank” href=”%s”>Manage features</a>’, ‘woocommerce-legacy-rest-api’ ) > $features_page_url ) ); return true; } return false; }

      WITH THIS:

      private static function maybe_add_hpos_incompatibility_admin_notice() { $instance = new self(); // Create an instance of the class if( ! $instance->hpos_is_enabled() || self::user_has_dismissed_admin_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) ) { return false; } if ( ! WC_Admin_Notices::has_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) ) { $features_page_url = admin_url( ‘admin.php?page=wc-settings&tab=advanced&section=features’ ); WC_Admin_Notices::add_custom_notice( ‘legacy_rest_api_is_incompatible_with_hpos’, sprintf( wpautop( __( ‘? <b>The Legacy REST API plugin and HPOS are both active on this site.</b><br/><br/>Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS. <a target=”_blank” href=”%s”>Manage features</a>’, ‘woocommerce-legacy-rest-api’ ) ), $features_page_url ) ); return true; } return false; }

    2. Update maybe_remove_hpos_incompatibility_admin_notice Method:

      REPLACE THIS:

      private static function maybe_remove_hpos_incompatibility_admin_notice() { if ( WC_Admin_Notices::has_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) && ! self::hpos_is_enabled() ) { self::remove_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ); } }

      WITH THIS:

      private static function maybe_remove_hpos_incompatibility_admin_notice() { $instance = new self(); // Create an instance of the class if ( WC_Admin_Notices::has_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ) && ! $instance->hpos_is_enabled() ) { self::remove_notice( ‘legacy_rest_api_is_incompatible_with_hpos’ ); } }

    Good to know I am not the only one that experienced problems with the latest update.

    Highlighted Changes to fix this issue while waiting for update to be released.

    In maybe_add_hpos_incompatibility_admin_notice:

    1. Instance Creation:phpCopy code$instance = new self(); // Create an instance of the class
    2. Calling Non-static Method:phpCopy codeif( ! $instance->hpos_is_enabled() || self::user_has_dismissed_admin_notice( 'legacy_rest_api_is_incompatible_with_hpos' ) ) {

    In maybe_remove_hpos_incompatibility_admin_notice:

    1. Instance Creation:phpCopy code$instance = new self(); // Create an instance of the class
    2. Calling Non-static Method:phpCopy codeif ( WC_Admin_Notices::has_notice( 'legacy_rest_api_is_incompatible_with_hpos' ) && ! $instance->hpos_is_enabled() ) {

    These highlighted changes will resolve the error by correctly calling the non-static hpos_is_enabled method on an instance of the WC_Legacy_REST_API_Plugin class.

    Thread Starter ericreynolds007

    (@ericreynolds007)

    Thank you Newt. I can implement the fix but I am heading to bed now. I decided to deactivate the plugin for now via ftp and deal with it in the morning. ?? Eric

    Same error on all sites with the 1.0.2 version.

    Same here, renamed the folder woocommerce-legacy-rest-api to retrieve my site.

    Thanks a lot @newtlabs this wuick path, it works fine under php8.3

    Also got an error.

    [15-May-2024 09:53:58 UTC] PHP Fatal error:  Uncaught Error: Non-static method WC_Legacy_REST_API_Plugin::hpos_is_enabled() cannot be called statically in /var/www/html/wordpress/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php:77
    Stack trace:
    #0 /var/www/html/wordpress/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php(28): WC_Legacy_REST_API_Plugin::maybe_add_hpos_incompatibility_admin_notice()
    #1 /var/www/html/wordpress/wp-includes/class-wp-hook.php(324): WC_Legacy_REST_API_Plugin::on_woocommerce_init()
    #2 /var/www/html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #3 /var/www/html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /var/www/html/wordpress/wp-content/plugins/woocommerce/includes/class-woocommerce.php(812): do_action()
    #5 /var/www/html/wordpress/wp-includes/class-wp-hook.php(324): WooCommerce->init()
    #6 /var/www/html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #7 /var/www/html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action()
    #8 /var/www/html/wordpress/wp-settings.php(695): do_action()
    #9 /var/www/html/wordpress/wp-config.php(132): require_once('...')
    #10 /var/www/html/wordpress/wp-load.php(50): require_once('...')
    #11 /var/www/html/wordpress/wp-blog-header.php(13): require_once('...')
    #12 /var/www/html/wordpress/index.php(17): require('...')
    #13 {main}
      thrown in /var/www/html/wordpress/wp-content/plugins/woocommerce-legacy-rest-api/includes/class-wc-legacy-rest-api-plugin.php on line 77
    

    Un errore di E_ERROR è stato causato nella linea 77

    disabilitato plugin per il momento in attesa di aggiornamento …..

    Same here ?? What to do???

    Disable the plugin from ftp. Install 1 version back.

    ir just wait for a fix ??

    • This reply was modified 5 months, 1 week ago by Al.

    Installed the 1.0.2 update on 20 sites and it crashed every site!

    Same here

    PEOPLE, DON’T UPDATE!!!

    Just installed v1.0.4….this version fixes the fatal error!

    Keep on rocking ??

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