Skip to content

RequestRouter: POST Requests - Process POST request inside admin_init#35

Merged
nicolas-jaussaud merged 3 commits into
mainfrom
fix/route-post-redirect
May 26, 2026
Merged

RequestRouter: POST Requests - Process POST request inside admin_init#35
nicolas-jaussaud merged 3 commits into
mainfrom
fix/route-post-redirect

Conversation

@nicolas-jaussaud

Copy link
Copy Markdown
Contributor

Hi @zinigor!

It looks like there is a small issue with the way we handle POST request currently

Every DataView request is processed inside a menu or submenu render callback (here)

It causes issues for POST requests because they trigger a redirection, and as we have already rendered content at this point it triggers the following error and the redirection fails:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/tobet/wp-includes/fonts/class-wp-font-face.php:98) in /var/www/html/tobet/wp-includes/pluggable.php on line 1535

See associated screencast:
https://github.com/user-attachments/assets/b8a89d61-b4ad-4784-8022-2daf7ea6d344

As a fix, I moved POST request handling in a separate method called maybe_redirect(), which will be triggered earlier during admin_init

@nicolas-jaussaud nicolas-jaussaud requested a review from zinigor May 21, 2026 19:27
zinigor
zinigor previously approved these changes May 25, 2026

@zinigor zinigor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense, but I think it will need some work after the Request PR is merged, wouldn't it?

@nicolas-jaussaud

Copy link
Copy Markdown
Contributor Author

Ah yes indeed!

We'll need to replace $this->is_post(), $this->url_builder->get_current_action() and $this->url_builder->get_current_id()

I'll merge the other PR first, merge the changes from main on this branch and replace what's needed before merging

@nicolas-jaussaud nicolas-jaussaud merged commit 51c473e into main May 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants