Skip to content

RequestRouter: Scope maybe_redirect to the DataView's own admin page#45

Closed
titus-toia wants to merge 1 commit into
mainfrom
fix/maybe-redirect-page-scope
Closed

RequestRouter: Scope maybe_redirect to the DataView's own admin page#45
titus-toia wants to merge 1 commit into
mainfrom
fix/maybe-redirect-page-scope

Conversation

@titus-toia
Copy link
Copy Markdown

Problem

RequestRouter::maybe_redirect() is hooked on the global admin_init (#35), so it runs on every admin request. For a singular DataView it calls handle_settings_submit() on any admin POST with no check that the request actually targets its own page.

As a result, Gutenberg meta-box saves (post.php?meta-box-loader=1) get routed into the DataView's settings handler, fail its nonce check, and wp_die( 'Security check failed.' )breaking every meta-box save on the site (HTTP 500) for any install that registers a singular DataView.

Same hazard applies to plural DataViews if a stray POST carries a create/edit/delete action.

Fix

Bail out of maybe_redirect() unless $_GET['page'] matches the DataView's own menu_page, before any capability check or submit handling. Real settings/create/edit submits post to ?page=<menu_page>&…, so they still pass; unrelated admin POSTs (meta-box saves, other plugins' forms) are now ignored.

Testing

Reproduced on a course edit screen (block editor): meta-box save returned 500 Security check failed, traced to maybe_redirect()handle_settings_submit() → nonce fail. With this guard, the meta-box save completes and the DataView settings form still saves normally.

maybe_redirect() is hooked on the global admin_init (#35), so it runs on
every admin request. For a singular DataView it called handle_settings_submit()
on ANY admin POST without checking the request targeted its own page — so
Gutenberg meta-box saves (post.php?meta-box-loader=1) were routed into the
settings handler, failed the DataView nonce check, and wp_die('Security check
failed.'), breaking every meta-box save on the site.

Bail unless $_GET['page'] matches the DataView's menu page before doing any
capability check or submit handling.
@zinigor
Copy link
Copy Markdown
Contributor

zinigor commented Jun 3, 2026

Sorry, already fixed by #43

@titus-toia titus-toia closed this Jun 4, 2026
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.

3 participants