-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Acorn scheduler is not loading wordpress correctly #383
Comments
up |
I also had a similar setup and noticed it would boot the Acorn Kernel AND my custom Kernel. Maybe you can try to overwrite the implementation for \Roots\bootloader()->boot(function ($app) {
$app->singleton(
\Roots\Acorn\Console\Kernel::class,
\App\Console\Kernel::class
);
});
// see comment below
// }, 0); Also the Acorn boot priority was updated recently: https://github.com/roots/radicle/commit/5af169578560f6b1b7ec0879b4d4ce2d7842f25c This is also something you could try. Recently I got rid of overwriting the Kernel and moved my logic to a ServiceProvider instead. But I don't know if that's also possible for scheduling. Details<?php
declare(strict_types=1);
namespace App\Providers;
// [...]
use BabDev\ServerPushManager\Http\Middleware\ServerPush;
use Illuminate\Support\ServiceProvider;
use Roots\Acorn\Http\Kernel;
class WordPressOptimizationProvider extends ServiceProvider
{
// [...]
public function __construct($app)
{
parent::__construct($app);
$app->extend(Kernel::class, function (Kernel $kernel) {
// We need to add this first to make sure we're able to set headers
return $kernel->prependMiddlewareToGroup('web', ServerPush::class);
});
}
// [...]
} |
still need help on this one |
@mfr75 The first bump wasn't necessary, nor was the second one. Post on Roots Discourse if you want to hire someone from the community if you're looking for immediate help. |
Version
v4.2.2
What did you expect to happen?
I'm using Acorn in combinaison with Radicle.
I did register a Kernel instance :
Which provides schedules :
Schedules are working nicely, but the load of Wordpress is not complete.
For example, If I would want to get the permalink of a page inside my command :
When using WP-CLI, this works perfectly :
But in the scheduler context, I get :
What actually happens?
When running the scheduler with acorn, the acorn binary is called.
This binary loads wordpress and then expect acorn to boot on top :
The seconds line nevers gets called.
What actually happens is that the
wp-settings.php
file is going to load the mu-plugins, which loads Acorn (00-acorn-boot.php
), and the load of Acorn "captures" the "request", and so any code that should have run after the load of mu-plugins (insidewp-settings.php
) won't run, including settings up default post_types and so on :This means that if I run a command with the scheduler :
The
debug:dump
command won't be able to get a permalink (eg:get_permalink(1)
) as the internalget_post_status_object()
function could not return values because the core is not fully loaded.Steps to reproduce
Create a Kernel class :
Make sure to register the kernel class when booting acorn :
Then, after creating a command which tries to display a permalink, test it thru the scheduler using
wp acorn schedule:test
.System info
MacBook Air M1
MacOS Sonoma 14.5
PHP 8.2.18
Log output
No response
Please confirm this isn't a support request.
Yes
The text was updated successfully, but these errors were encountered: