Site icon Hip-Hop Website Design and Development

Step debug wp cron run – concepts methods to get this working in PHPStorm with Xdebug?

That is driving me a bit nuts…

I’m utilizing my Mac’s cron performance to run WordPress cron jobs.

In wp-config.php

I’ve

outline('DISABLE_WP_CRON', true);
outline( 'WP_DEBUG', true );
// Allow Debug logging to the /wp-content/debug.log file
outline( 'WP_DEBUG_LOG', true );
// Disable show of errors and warnings
outline( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
outline( 'SCRIPT_DEBUG', false );

Unsure if outline( 'WP_DEBUG', true ); performs a task in my case.

Then I created a script to run jobs, which is

#!/bin/bash
#!/bin/bash
clear
export XDEBUG_CONFIG="mode=debug client_host=127.0.0.1 client_port=9003 start_with_request=yes"
cd /folder
for hook in $(wp cron occasion record --next_run_relative=now --fields=hook --format=ids); 
  do wp cron occasion run --debug "$hook";
executed;
echo "again in cron - debug set" >> /somefolder/stdout.log

I see that the cron is operating as there’s output to stdout.log

In my IDE (PHPStorm), I’ve xdebug set to port 9003, and set to interrupt at first line.

In my xdebug log I see entries like

tail -n 500 xdebug.log
[16636] [Step Debug] <- breakpoint_set -i 17 -t line -f file:///mysite/wp-content/plugins/sfwd-lms/themes/ld30/templates/course_registered_rows.php -n 14
[16636] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="17" id="166360004" resolved="unresolved"></response>

[16636] [Step Debug] <- breakpoint_set -i 18 -t line -f file:///mysite/wp-content/plugins/learndash-notifications/contains/cron.php -n 79
[16636] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="18" id="166360005" resolved="unresolved"></response>

the place the breakpoint traces proven within the log correspond to what I set in PHPStorm.

I can step debug every thing possible, besides this wp cron run. I’ve incoming webhooks from mailchimp, and so forth, all triggering step debugging. However with this cron, PHPStorm reveals a debug step for wp, however after I hit resume not one of the breakpoints within the venture are tripped, regardless that they’re set.

I really feel like I’m nearly there. However one thing not fairly proper…

Concepts?