fix(data-export): name index.php in S3 completion redirects#1529
Merged
Conversation
The S3 export completion redirects used a query-only `Location: ?p=...`
reference. Firing from web/export.php, the browser resolved it against
export.php's own path (RFC 3986 section 5.2 keeps the base path for an
empty-path reference) and followed it as a GET to
export.php?p=admin&c=export..., landing in the POST-only method gate
("POST required."). The upload had already run, so the operator saw
a bogus error after a successful export.
Name index.php explicitly in both completion arms so the redirect
resolves to the router entry point (/index.php?p=admin&c=export...) and
the admin page handler paints the success/error toast. ZIP mode streams
its body and never redirects, which is why only the S3 path broke.
Adds testEntryPointRedirectsNameIndexPhpNotBareQuery() as a regression
guard: fails if a bare `Location: ?p=` reappears and asserts both arms
name index.php.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the S3-delivery mode of the owner-only Full data export: pasting a presigned S3 URL and submitting produced a bare "POST required." screen instead of a success/error toast.
web/export.php's two completion redirects (sbpp_export_redirect_success/sbpp_export_redirect_failure) emitted a query-onlyLocation: ?p=admin&c=export&result=...reference. Because the redirect fires fromexport.php, the browser resolved the empty-path reference againstexport.php's own path (RFC 3986 §5.2 keeps the base path) and followed it as a GET toexport.php?p=admin&c=export..., landing straight in the POST-only method gate at the top of the script. The S3 upload had already run by then, so the operator saw a bogus error after a successful export.Both arms now name the router entry point explicitly (
Location: index.php?p=admin&c=export...), so the redirect resolves to/index.php?p=admin&c=export...and the admin page handler paints the toast.ZIP mode streams its body to
php://outputand never redirects, which is exactly why only the S3 path was affected (ZIP downloads worked fine).Motivation and Context
Operator report: "When I paste a presigned S3 URL into the export, I get a screen 'POST required.'"
The S3 completion path is the one export branch that redirects, and it had no end-to-end coverage (only the uploader class is unit-tested via transport injection), so the bad redirect target slipped through.
How Has This Been Tested?
php -lclean on both edited files.export.php:Location: ?p=remains,index.php,index.php.Location:redirects inexport.phpand that every S3 branch (success + all failure arms) routes through the two fixed helpers.Added
testEntryPointRedirectsNameIndexPhpNotBareQuery()toAdminExportPermissionTest.phpas a regression guard (static-shape, no DB): fails if a bareLocation: ?p=reappears.Types of changes
Checklist:
Docs note: this is a redirect-path bugfix that makes the already-documented S3 flow work as written (no change to wire format, delivery modes, or the security model), so
data-export.mdx/ARCHITECTURE.mdneed no update.