• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.

Input Executing WordPress plugin/theme cron events through WP-CLI

wwwAndries

New Pleskian
PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE:
WordPress Toolkit 3.5.0 >

PROBLEM DESCRIPTION:
WordPress plugin/theme cron events are executed through WP-CLI, cron event is removed after executing and reporting status is success, but the plugin/theme "do_action" is actually never excuted.

STEPS TO REPRODUCE:
I’ve disabled the wp-cron for all of the sites I’am managing and use the system cron to run WP-CLI commands like:

${WP_CLI} -instance-id ${INSTANCE_ID} -- cron event run --due-now --url="${WP_SITE_URL}" &>> $CWS_TMP_FILE

The "due-now" cron events were executed and returned success status after executing, but the plugin/theme action/filter never executed. In the WordPress plugin.php the function “do_action_ref_array” was executed but the global $wp_filter[ $tag ] was NULL.

function do_action_ref_array( $tag, $args ) {
global $wp_filter, $wp_actions, $wp_current_filter;

if ( ! isset( $wp_actions[ $tag ] ) ) {
$wp_actions[ $tag ] = 1;
} else {
++$wp_actions[ $tag ];
}

// Do 'all' actions first
if ( isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
$all_args = func_get_args();
_wp_call_all_hook( $all_args );
}

+ if ( ! isset( $wp_filter[ $tag ] ) ) {
+ if ( isset( $wp_filter['all'] ) ) {
+ array_pop( $wp_current_filter );
+ }
+ return;
+ }

if ( ! isset( $wp_filter['all'] ) ) {
$wp_current_filter[] = $tag;
}

$wp_filter[ $tag ]->do_action( $args );

array_pop( $wp_current_filter );
}

Because of that, the function returned without an error and WP-CLI reported success, but the $wp_filter[ $tag ]->do_action( $args ); was never executed!

Plesk changed there wrapper for WP-CLI last year and added “skip-plugins: true” and “skip-themes: true” in the wp-cli.yml. Every WP-CLI command is executed without loading plugins and themes. This is the reason why $wp_filter[ $tag ] was NULL and the plugin/theme action/filter was never executed.

Tempory solution
After adding “--skip-plugins=dummy-plugin” at the WP-CLI command “cron event run --due-now”, all scans run fine.


EXPECTED RESULT:
When executing ${WP_CLI} -instance-id ${INSTANCE_ID} -- cron event run --due-now --url="${WP_SITE_URL}", I expect that the cron events of the core, plugins and themes are run.

ANY ADDITIONAL INFORMATION:

YOUR EXPECTATIONS FROM PLESK SERVICE TEAM:
I would expect that skip-plugins and skip-themes would be false because this is the default WP-CLI behavior. At least document this deviation.
 
Back
Top