wp-rocket
wp-rocket copied to clipboard
Table `wp_wpr_rocket_cache` doesn't exist when running WP-CLI cronjobs
Before submitting an issue please check that you’ve completed the following steps:
- Made sure you’re on the latest version ✅
- Used the search feature to ensure that the bug hasn’t been reported before ✅
Describe the bug There is an error message in the log file when WP cron is called via WP-CLI.
WordPress adatbázis hiba Table 'wp_wpr_rocket_cache' doesn't exist a lekérdezésben SELECT id FROM `wp_wpr_rocket_cache` WHERE `last_accessed` <= date_sub(now(), interval 1 month) készítette include('phar:///home/***username***/wp-cli.phar/php/boot-phar.php'), include('phar:///home/***username***/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, Cron_Event_Command->run, Cron_Event_Command::run_event, do_action_ref_array('rocket_preload_clean_rows_time_event'), WP_Hook->do_action, WP_Hook->apply_filters, WP_Rocket\Engine\Preload\Cron\Subscriber->remove_old_rows, WP_Rocket\Engine\Preload\Database\Queries\Cache->remove_all_not_accessed_rows, WP_Rocket\Engine\Preload\Database\Queries\Cache->get_old_cache
The log's language is Hungarian. Translation: "WordPress database error Table wp_wpr_rocket_cache doesn't exist on database"
The mentioned table exists in the database as you can see in the image.
To Reproduce Steps to reproduce the behavior:
- Install the latest WordPress / WP Rocket.
- Disable the WP-Cron:
define( 'DISABLE_WP_CRON' , true );
- Install the latest WP-CLI.
- Call the cron events with the
wp cron event run --due-now
command. - See the error log.
Expected behavior No database error when running WP-CLI cronjobs.
Backlog Grooming (for WP Media dev team use only)
- [ ] Reproduce the problem
- [ ] Identify the root cause
- [ ] Scope a solution
- [ ] Estimate the effort
Reproduce the problem
I couldn't reproduce the issue following that process.
Identify the root cause
However I guess the problem can be solved by adding a guard before use the preload table as asked in #5351. What do you think @piotrbak ?
It wouldn't make sense to guard the use of the table if it exists, as we want the cronjobs to run in CLI too for it
@DahmaniAdame The problem with cache table that's not related to CLI is going to be fixed here: https://github.com/wp-media/wp-rocket/issues/5351
@DahmaniAdame @piotrbak my idea when guarding the table is the fact that when we launch the preload queue from the cli it won't create the table if it is missing. But then if we open the admin it will create it making us think the table was there.
I tried some scenarios and that for the moment the only one I can reproduce that issue.
I can't replicate the issue either
@CrochetFeve0251 @Tabrisrp If the issue is the one described by Cyrille here: https://github.com/wp-media/wp-rocket/issues/5361#issuecomment-1241928628
We could handle this on the CLI end maybe?
@Tabrisrp What do you think about handling it inside the WP Rocket CLI itself? 🤔
Moving it back to grooming as proposed solution prevents error from being triggered but doesn't resolve the initial problem. Maybe we could handle this on the CLI side? 🤔
@simkoG This issue is most likely fixed as we look for the init
hook while creating the tables, not admin_init
. Your feedback will be very appreciated
@piotrbak I can't replicate the issue for now. It seems it is fixed. If not I'll write back to you.