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

shutdown action may cause fatal during update when 3rd party plugin are removing or moving action scheduler #1235

Open
dpanta94 opened this issue Jan 22, 2025 · 0 comments
Labels
type: enhancement The issue is a request for an enhancement.

Comments

@dpanta94
Copy link
Member

dpanta94 commented Jan 22, 2025

First of all, thank you for such a great tool. I have been using it to all my projects where i am have to deal with scheduled actions.

I did notice a weird fatal though when we changed location for action scheduler in plugins i am working for.

The fatal was during the upgrade of said plugin.

What was happening behind the scenes ?

Please do have in mind how php would load files and objects into memory during this example. It took me some time to figure out how that is possible.

Action scheduler registers an action during shutdown here

The file above is already loaded into memory and an instance of ActionScheduler_QueueRunner. We can be sure of that because we are using $this to refer to it.

By the time the request though reaches the shutdown hook and as a result the callback.

if this was an upgrade request to the plugin that includes Action scheduler, Action scheduler files may have been moved!

The already in memory vendor/autoload.php would point to file no longer in place for retrieving the singleton instance returned by ActionScheduler::lock(). Causing a fatal.

Steps to recreate:

create a third party single file plugin.
require action scheduler through composer.
init action scheduler in your third party plugin.
install this plugin in your wp installation.

create a zip which we would treat as an update to the above plugin.
remove action scheduler through composer and simply include it another directory e.g. as
change the require in your main plugin file to point to the new location of action scheduler.
create an installable zip.
upgrade your plugin in your wp instalaltion.
the fatal should be present (as long as WP_DEBUG is true and display errors true should be visible as well).

Possible solution:

I think the simplest solution would be to NOT hook into shutdown if the current request is an upgrade request for plugin(s) or bail early during the shutdown callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants