Repository navigation
feat(avatars): store the placeholder as the photo on deletePhoto - #14065
Conversation
DELETE /v1/avatars/photo used to clear the user's photo and let the chain fall through to identity photos, Gravatar, Libravatar or initials. It now renders the built-in placeholder and stores it as the user's own photo — replacing an upload, or becoming the photo when there was none — so the placeholder wins the chain the way an upload does, until updatePhoto replaces it. Storing bytes as the user's photo (upload, optimistic-lock retry, cleanup of the new file on failure and the previous one on success) is the same step for Update and Delete, so it lives in Photo/Base.php as replacePhoto(). Fallback::render() is public, like Initials::render(). Co-Authored-By: Claude Fable 5.1 <[email protected]>
🟢 Tier S · Ready to merge
Deleting a profile photo now stores a rendered placeholder as the user's own photo, overriding the remaining avatar sources. Upload and delete share the existing storage replacement and optimistic-lock logic through a new base action. The SDK description and end-to-end tests are updated for the new behavior, including OAuth2 photo precedence and subsequent uploads.
📂 Walkthrough · 6
Reviewed |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Summary
DELETE /v1/avatars/photono longer clears the user's photo and lets resolution fall through to OAuth2 identity photos, Gravatar, Libravatar or initials. It now renders the built-in placeholder (Fallback— the neutral grey tile with the person mark) and stores it as the user's own photo: it replaces an uploaded photo, or becomes the photo when there was none. From then on the placeholder wins the chain exactly like an upload would, untilupdatePhotoreplaces it.photoId, cleanup of the new file on failure and of the previous file on success — is now the same step forUpdateandDelete, so it moved toPhoto/Base.php::replacePhoto().Updateis behaviour-unchanged;Deleterenders the placeholder at 1024×1024 and hands it to the same method.Fallback::render()is public, mirroringInitials::render(), so the action gets PNG bytes directly rather than going throughget()'s SVG last resort.deletePhotoupdated to describe the new behaviour. Response stays204 No Content.Tests
AvatarsCustomClientTest::testDeletePhoto— with no photo, delete still sets the placeholder (shadowing initials); an upload is replaced by the placeholder; deleting again keeps it; the stored placeholder is served at the requested size; a new upload still works afterwards.AvatarsCustomClientTest::testDeletePhotoOverridesIdentityPhoto— a user whose OAuth2 identity photo wins the chain gets the placeholder after delete. Signs in a fresh user through the native ID-token flow via a newcreateIdTokenSession()helper (also used bytestGetPhotoIdTokennow), so the single mock browser-flow user shared across suites is never touched.AvatarsConsoleClientTest::testDeletePhotoWithConsoleSession— asserts the placeholder instead of initials.php -l, Pint, PHPStan on the touched files andcomposer refactor:checkall pass. E2E runs in CI.🤖 Generated with Claude Code