• Hi,

    Trying to figure out how to get my cron jobs to trigger breakpoints in PHPStorm via Xdebug 3.

    I have some details here:

    https://wordpress.stackexchange.com/questions/397491/step-debug-wp-cron-run-ideas-how-to-get-this-working-in-phpstorm-with-xdebug

    To repeat what is there:

    I am using my Mac’s cron functionality to run WordPress cron jobs.

    In wp-config.php

    I have

    define(‘DISABLE_WP_CRON’, true);
    define( ‘WP_DEBUG’, true );
    // Enable Debug logging to the /wp-content/debug.log file
    define( ‘WP_DEBUG_LOG’, true );
    // Disable display of errors and warnings
    define( ‘WP_DEBUG_DISPLAY’, false );
    @ini_set( ‘display_errors’, 0 );
    define( ‘SCRIPT_DEBUG’, false );
    Not sure if define( ‘WP_DEBUG’, true ); plays a role 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 event list –next_run_relative=now –fields=hook –format=ids);
    do wp cron event run –debug “$hook”;
    done;
    echo “again in cron – debug set” >> /somefolder/stdout.log
    I see that the cron is running as there is output to stdout.log

    In my IDE (PHPStorm), I have xdebug set to port 9003, and set to break 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&#8221; 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/includes/cron.php -n 79
    [16636] [Step Debug] -> <response xmlns=”urn:debugger_protocol_v1″ xmlns:xdebug=”https://xdebug.org/dbgp/xdebug&#8221; command=”breakpoint_set” transaction_id=”18″ id=”166360005″ resolved=”unresolved”></response>
    where the breakpoint lines shown in the log correspond to what I set in PHPStorm.

    I can step debug everything imaginable, except this wp cron run. I have incoming webhooks from mailchimp, etc, all triggering step debugging. But with this cron, PHPStorm shows a debug step for wp, but when I hit resume none of the breakpoints in the project are tripped, even though they are set.

    I feel like I am almost there. But something not quite right…

    Ideas?

    • This topic was modified 4 years, 7 months ago by Jan Dembowski.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to step debug wp cron run with xdebug?’ is closed to new replies.