wp-background-processing icon indicating copy to clipboard operation
wp-background-processing copied to clipboard

$_POST is always empty

Open Jamesking56 opened this issue 6 months ago • 1 comments

Hello,

I am calling via a WP REST API call (#81) and my action is successfully being called in the background, however, $_POST is always empty.

If I trigger like below:

$data['first_key'] = 'first_value';
$data['second_key'] = 'second_value';

$this->job
            ->data($data)
            ->dispatch();

The $_POST in the job handle is always empty.

Any ideas how to debug this to find out why its always empty?

Jamesking56 avatar Jun 10 '25 21:06 Jamesking56

It looks like potentially WordPress has stopped allowing POST data for non-blocking requests:

https://github.com/WordPress/wordpress-develop/blob/c1f2216287d9c097526caa7ecd456891f0c91537/src/wp-includes/class-wp-http.php#L448

Jamesking56 avatar Jun 10 '25 21:06 Jamesking56

It looks like potentially WordPress has stopped allowing POST data for non-blocking requests:

https://github.com/WordPress/wordpress-develop/blob/c1f2216287d9c097526caa7ecd456891f0c91537/src/wp-includes/class-wp-http.php#L448

Hmm, that is strange, and looks to have been the case for a few years.

Did you find a workaround @Jamesking56?

ianmjones avatar Nov 03 '25 14:11 ianmjones

@ianmjones I switched libraries, I use action scheduler instead now.

Jamesking56 avatar Nov 03 '25 14:11 Jamesking56

Thanks for letting me know @Jamesking56, I'll close this for now then as no one else has reported this issue.

ianmjones avatar Nov 03 '25 16:11 ianmjones