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
Fix - TGM Plugin activation calling undefined function wc_get_screen_ids #44114
Conversation
If we add woocommerce and enable the `force_activation` config in TGM plugin activation then the bug appears.
Hi , Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shivapoudel, thanks for the PR! Rather than bailing early on the add_notices
method when wc_get_screen_ids
doesn't exist, I think it would be preferable to maintain the functionality and just ensure that wc_get_screen_ids
does exist.
The reason the error is happening is that the wc-admin-functions.php
file isn't getting loaded during the TGM request for some reason. But we could do something like what happens here, and require the file within add_notices
. So maybe at the top of the method we could add a line like this:
require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php';
What do you think?
But TGM is external library so how the inclusion occurs? Or you mean to say rather than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you mean to say rather than function_exists check just to include the file within wc_get_screen_ids function.
Sort of. I mean something like the below suggestion.
@coreymckrill Adapted the changes. Thanks! |
Closing and re-opening this PR to fix the stuck CI actions... |
If we add woocommerce and enable the
force_activation
config in TGM plugin activation then the bug appears.Submission Review Guidelines:
Changes proposed in this Pull Request:
How to test the changes in this Pull Request:
All this does is ensure that a particular file is loaded before a function within that file is called. Most of the time, the file is already loaded, so in those cases, this change does nothing. Rather than having to install and set up the third-party TGM Plugin, all we really need to do here is make sure this change doesn't break anything. So after switching to this branch, try a few things:
Doing these things, you shouldn't see any fatal errors about notices or about functions already being defined.
Changelog entry
Significance
Type
Message
Ensure WC admin functions are defined before attempting to add notices.
Comment