I've messed with trying to get scheduled posts to fire a function for months and finally stripped things down to the following code to see what is happening. The problem is that a scheduled post will not show the wp_die.
add_action( 'transition_post_status', function ( $new_status, $old_status, $post ) {
if( 'publish' == $new_status && 'publish' != $old_status ) {
wp_die('STOP');
}
}, 10, 3 );
If I simply immediately click on post then the STOP shows but a scheduled post shows nothing and will publish. I've also tried simply wp_die($post); to see what is returned on a scheduled post and there the wp_die isn't fired.
Even forcing this to 'future' == $old_status does not work.
How can I diagnose why this isn't firing for scheduled posts?
I've tried var_dump as well.