Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Fatal Error during Newspack Setup using latest Newspack Plugin 5.3.9 release with latest Newspack Blocks 4.1.1 #3426

Closed
ronchambers opened this issue Sep 17, 2024 · 1 comment
Assignees
Labels

Comments

@ronchambers
Copy link
Collaborator

ronchambers commented Sep 17, 2024

Describe the bug

When doing the normal Newspack Setup in WP Admin or wp newspack setup, using the latest Newspack Plugin 5.3.9 and the latest Newspack Blocks 4.1.1, a fatal error will be thrown.

PHP Fatal error: Uncaught Error: Call to undefined function is_account_page().

Offending code here:

Original PR.

The function is_account_page() is defined within Woocommerce which is not installed/activated yet when the Blocks plugin is attempted to be activated.

To Reproduce

This can be tested by creating a clean wp install, then installing the plugin and blocks:

# create a clean wp install

# activate these 2 plugins from zip release files
wp plugin install --activate ~/releases/newspack-plugin/5.3.9/newspack-plugin.zip
wp plugin install --activate ~/releases/newspack-blocks/4.1.1/newspack-blocks.zip

Newspack Blocks will fail to activate. (Newspack "setup" will also fail since Blocks is activated prior to Woo).

View debug.log:


PHP Fatal error:  Uncaught Error: Call to undefined function is_account_page() in plugins\newspack-plugin\includes\reader-revenue\my-account\class-woocommerce-my-account.php:438

Stack trace:
#0 ...plugins\newspack-blocks\includes\class-modal-checkout.php(1078): Newspack\WooCommerce_My_Account::is_from_my_account()
#1 ...plugins\newspack-blocks\includes\class-modal-checkout.php(86): Newspack_Blocks\Modal_Checkout::is_modal_checkout()
#2 ...plugins\newspack-blocks\includes\class-modal-checkout.php(1258): Newspack_Blocks\Modal_Checkout::init()
#3 ...plugins\newspack-blocks\newspack-blocks.php(23)

Expected behavior

Neither Newspack setup nor Newspack Blocks activation should throw error. I would assume checking if function_exists and/or if Woocommerce is installed/active will solve the problem. I'm not sure if is_from_my_account() needs to proactively return true/false based on if Woo is active or not (I would assume return false).

@miguelpeixe
Copy link
Member

Thanks, @ronchambers! Fixed by #3427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants