Redirect in cron task
-
Hello, I use Ultimate Member together with the Rank Math SEO plugin. I run cron tasks on my website using wp-cli in this way:
wp cron event run --due-now
Rank Math SEO does some post processing using the WordPress
update_post_meta
function. And when this occurs, Ultimate Member tries to do a redirect, causing the errorSome code is trying to do a URL redirect
with following stack trace:#0 [internal function]: WP_CLI\Utils\wp_redirect_handler('...') #1 wp-includes/class-wp-hook.php(310): call_user_func_array('...', Array) #2 wp-includes/plugin.php(205): WP_Hook->apply_filters('...', Array) #3 wp-includes/pluggable.php(1388): apply_filters('...', '...', 302) #4 wp-content/plugins/ultimate-member/includes/um-short-functions.php(608): wp_redirect('...') #5 wp-content/plugins/ultimate-member/includes/core/um-actions-profile.php(1358): um_redirect_home(false, false) #6 [internal function]: um_pre_profile_shortcode(Array) #7 wp-includes/class-wp-hook.php(308): call_user_func_array('...', Array) #8 wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #9 wp-includes/plugin.php(517): WP_Hook->do_action(Array) #10 wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php(844): do_action('...', Array) #11 wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php(633): um\core\Shortcodes->load(Array) #12 [internal function]: um\core\Shortcodes->ultimatemember(Array, '', '...') #13 wp-includes/shortcodes.php(355): call_user_func(Array, Array, '', '...') #14 [internal function]: do_shortcode_tag(Array) #15 wp-includes/shortcodes.php(227): preg_replace_callback('...', '...', '...') #16 [internal function]: do_shortcode('...') #17 wp-includes/class-wp-hook.php(308): call_user_func_array('...', Array) #18 wp-includes/plugin.php(205): WP_Hook->apply_filters('...', Array) #19 wp-content/plugins/seo-by-rank-math/includes/modules/links/class-links.php(167): apply_filters('...', '...') #20 wp-content/plugins/seo-by-rank-math/includes/modules/links/class-links.php(59): RankMath\Links\Links->process(111488, '...') #21 wp-content/plugins/seo-by-rank-math/includes/modules/links/class-links.php(154): RankMath\Links\Links->save_post(111488, Object(WP_Post)) #22 [internal function]: RankMath\Links\Links->cron_job() #23 wp-includes/class-wp-hook.php(308): call_user_func_array(Array, Array) #24 wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #25 wp-includes/plugin.php(565): WP_Hook->do_action(Array) #26 phar:///usr/local/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(343): do_action_ref_array('...', Array) #27 phar:///usr/local/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(265): Cron_Event_Command::run_event(Object(stdClass)) #28 [internal function]: Cron_Event_Command->run(Array, Array) #29 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array) #30 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array) #31 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array) #32 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(419): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array) #33 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(442): WP_CLI\Runner->run_command(Array, Array) #34 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1256): WP_CLI\Runner->run_command_and_exit() #35 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start() #36 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState)) #37 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap() #38 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('...') #39 /usr/local/bin/wp(4): include('...') 1
It seems to me that Rank Math SEO doesn’t do anything bad, and maybe Ultimate Member should check if the code runs in a cron task using the DOING_CRON constant and prevent redirecting in such a case. Thank you for checking it!
- The topic ‘Redirect in cron task’ is closed to new replies.