Add default-private uploads for draft and unattached media#457
Closed
mikelittle wants to merge 2 commits intomasterfrom
Closed
Add default-private uploads for draft and unattached media#457mikelittle wants to merge 2 commits intomasterfrom
mikelittle wants to merge 2 commits intomasterfrom
Conversation
Introduce default-private uploads for draft/unattached media. Attachments on unpublished posts are marked private via the s3_uploads_is_attachment_private filter, and publishing a post transitions its attachments to public-read. Includes integration tests for privacy logic, presigned URL generation, and E2E HTTP access verification. Tests gracefully skip when S3 Uploads is not fully active or when the S3 server lacks object ACL support (e.g. VersityGW). Ref: #162 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 tasks
Introduce _s3_privacy='auto' meta to distinguish new uploads (managed by the private uploads feature) from pre-existing images. Images without the meta are always treated as public, preserving existing behaviour. - set_acl_on_metadata_save() now sets _s3_privacy='auto' on new uploads - is_attachment_private() returns false when _s3_privacy meta is absent - handle_post_status_transition() only processes 'auto' attachments - Admin UI uses 'auto' value instead of empty string Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
Another implementation has superseded this PR. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
s3_uploads_is_attachment_privatefilterpublic-read; unpublishing reverts them toprivate_s3_privacypost meta (values:private,public-read, or empty for default behaviour)New files
inc/private_uploads/namespace.php— core logic: privacy filters, ACL management, post transition hooks, admin UI fielddocs/private-uploads.md— user-facing documentationtests/integration.suite.yml— Codeception integration suite configtests/integration/private-uploads/PrivateUploadsTest.php— 12 unit-style tests for privacy logictests/integration/private-uploads/PrivateUploadsUrlChainTest.php— 6 tests for presigned URL generation chaintests/integration/private-uploads/PrivateUploadsAccessTest.php— 7 E2E tests for HTTP access controlRunning the tests
From the project root (inside the Docker PHP container):
Or from the host via docker exec:
Test results and known limitations
Current results on local-server (VersityGW S3): 25 tests, 15 pass, 10 skip, 1 pre-existing failure.
Tests that skip on local-server
S3 Uploads not fully active (2 tests):
testPresignedUrlForPrivateAttachmentandtestFullChainPrivateAttachmentToTachyonUrlskip because S3 Uploads'plugins_loadedinit does not fire during the WPLoader test bootstrap, so thewp_get_attachment_urlpresigning filter is not registered. These tests are expected to pass on a full WordPress environment where S3 Uploads is active.Tachyon plugin not available (2 tests):
testTachyonUrlIncludesPresignParamandtestTachyonUrlNoPresignForPublicUrlskip because the Tachyon plugin (tachyon_url()function) is not loaded during tests. Same root cause — plugin loading order in the test bootstrap.S3 server does not support object ACLs (6 tests):
All E2E access tests in
PrivateUploadsAccessTestskip with "S3 server does not support object ACLs (e.g. VersityGW)." VersityGW returns501 Not ImplementedforGetObjectAcl, so per-object access control cannot be verified locally. These tests are correctly written for AWS S3 and should pass on a real AWS stack.Next steps
Test plan
_s3_privacyoverride, confirm it takes precedenceRef: #162
Companion PR: humanmade/altis-local-server#899
🤖 Generated with Claude Code