GoogleChromeLabs / pwa-wp

WordPress feature plugin to bring Progressive Web Apps (PWA) to Core
https://wordpress.org/plugins/pwa/
GNU General Public License v2.0
615 stars 98 forks source link

WooCommerce Memberships compatibility: is_offline was called incorrectly #232

Open lkraav opened 4 years ago

lkraav commented 4 years ago

Load front or any other page, get this PHP Notice.

Traceback:

wp-includes/functions.php:4986
    is_offline()
    wp-content/plugins/pwa/wp-includes/general-template.php:109
    wp_hide_admin_bar_offline()
    wp-includes/class-wp-hook.php:288
    do_action_ref_array('parse_query')
    wp-includes/class-wp-query.php:1069
    WP_Query->parse_query()
    wp-includes/class-wp-query.php:1744
    WP_Query->get_posts()
    wp-includes/class-wp-query.php:3413
    WP_Query->query()
    wp-includes/post.php:2039
    get_posts()
    wp-content/plugins/woocommerce-memberships.git/includes/class-wc-memberships-user-memberships.php:322
    WC_Memberships_User_Memberships->get_user_memberships()
    wp-content/plugins/woocommerce-memberships.git/includes/functions/wc-memberships-functions-user-memberships.php:56
    wc_memberships_get_user_memberships()
    wp-content/plugins/woocommerce-memberships.git/includes/functions/wc-memberships-functions-members-area.php:93
    wc_memberships_get_members_area_endpoint()
    wp-content/plugins/woocommerce-memberships.git/includes/frontend/class-wc-memberships-members-area.php:66
    WC_Memberships_Members_Area->__construct()
    wp-content/plugins/woocommerce-freshbooks/vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:759
    SkyVerge\W\P\v\SV_WC_Plugin->load_class()
    wp-content/plugins/woocommerce-memberships.git/includes/frontend/class-wc-memberships-frontend.php:54
    WC_Memberships_Frontend->__construct()
    wp-content/plugins/woocommerce-freshbooks/vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php:759
    SkyVerge\W\P\v\SV_WC_Plugin->load_class()
    wp-content/plugins/woocommerce-memberships.git/class-wc-memberships.php:328
    WC_Memberships->frontend_includes()
    wp-content/plugins/woocommerce-memberships.git/class-wc-memberships.php:258
    WC_Memberships->includes()
    wp-content/plugins/woocommerce-memberships.git/class-wc-memberships.php:153
    WC_Memberships->init_plugin()
    wp-includes/class-wp-hook.php:288
    do_action('plugins_loaded')
    wp-settings.php:392

Should we somehow be smarter about when to get involved in parse_query or... :thinking:

cc @unfulvio

unfulvio commented 4 years ago

hey @lkraav could I have a bit more context here, please? Thanks

lkraav commented 4 years ago

Could I have a bit more context here.

Oops, I could've indeed mentioned this triggers simply by loading front (or any) page.

unfulvio commented 4 years ago

hmm I narrowed it down to the Frontend class; if I exclude everything other than that looks ok - seems an interaction with wc_memberships_get_members_area_endpoint() but I'm not sure yet exactly where/how and why

I am unfamiliar with this plugin here. From semver looks like it's still not an official 1.0 and I guess code is going to change until/if it makes it to core. Is there a reason why should it be considered a bug in Memberships or should we prioritize this on our end?

If there's anything we can change in Memberships please open an issue or PR in the repo.

Thanks

westonruter commented 4 years ago

At what WordPress action does wc_memberships_get_members_area_endpoint() happen at?

Where is the codebase for this plugin?

unfulvio commented 4 years ago

@westonruter

WooCommerce Memberships is a commercial WooCommerce plugin and the repository at https://github.com/skyverge/woocommerce-memberships has private access (@lkraav and I have access; there's a mirror on the Automattic/WooCommerce org: https://github.com/woocommerce/woocommerce-memberships).

wc_memberships_get_members_area_endpoint() is used in different parts of the plugin to return a query variable to extend the WooCommerce My Account page with a new endpoint. This function is sometimes used to filter query_vars. At init it is also used to call add_rewrite_endpoint().

We did not have reports similar to the one in OP related to other plugins.