Skip to content

feat(avatars): store the placeholder as the photo on deletePhoto - #14065

Merged
Meldiron merged 1 commit into
mainfrom
feat-delete-photo-fallback
Oct 2, 2026
Merged

Meldiron merged 1 commit into
mainfrom
feat-delete-photo-fallback

Conversation

@Meldiron

@Meldiron Meldiron commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • DELETE /v1/avatars/photo no 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, until updatePhoto replaces it.
  • Storing bytes as the user's photo — upload, optimistic-lock retry on photoId, cleanup of the new file on failure and of the previous file on success — is now the same step for Update and Delete, so it moved to Photo/Base.php::replacePhoto(). Update is behaviour-unchanged; Delete renders the placeholder at 1024×1024 and hands it to the same method.
  • Fallback::render() is public, mirroring Initials::render(), so the action gets PNG bytes directly rather than going through get()'s SVG last resort.
  • SDK description of deletePhoto updated to describe the new behaviour. Response stays 204 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 new createIdTokenSession() helper (also used by testGetPhotoIdToken now), so the single mock browser-flow user shared across suites is never touched.
  • AvatarsConsoleClientTest::testDeletePhotoWithConsoleSession — asserts the placeholder instead of initials.
  • Locally: php -l, Pint, PHPStan on the touched files and composer refactor:check all pass. E2E runs in CI.

🤖 Generated with Claude Code

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]>
@ghost

ghost commented Oct 2, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed actions, provider resolution, storage contract, and test helpers are consistent; no concrete defects were found.

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.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
src/Appwrite/AvatarPhotos/Providers/Fallback.php Exposes PNG rendering for use by the delete action.
src/Appwrite/Platform/Modules/Avatars/Http/Photo/Base.php Extracts shared photo storage, conflict retries, and previous-file cleanup.
src/Appwrite/Platform/Modules/Avatars/Http/Photo/Delete.php Renders and persists the placeholder while retaining the 204 response.
src/Appwrite/Platform/Modules/Avatars/Http/Photo/Update.php Delegates photo replacement to the shared base action.
tests/e2e/Services/Avatars/AvatarsConsoleClientTest.php Expects the placeholder after initial and repeated deletion.
tests/e2e/Services/Avatars/AvatarsCustomClientTest.php Tests placeholder persistence, resizing, OAuth2 precedence, and replacement by an upload; extracts isolated ID-token sign-in.

Reviewed 113f875 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat-delete-photo-fallback (after).

Metric Before After Change
🚀 Requests/sec 193.84 186.46 ⚪ -3.8%
⏱️ Latency P50 87.97 ms 93.06 ms 🔴 +5.8%
⏱️ Latency P95 210.76 ms 216.36 ms ⚪ +2.7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 93.06 216.36 11,571 186.46 +5.6
Account 182.96 354.02 609 10.13 +20.53
TablesDB 90.06 169.39 6,293 103.4 +5.74
Storage 83.62 177.97 3,045 51.82 -4.18
Functions 132.11 261.11 1,624 28.15 +9.23

Top API waits (after)

API request Max wait (ms)
account.name.update 600.77
account.prefs.update 520.66
functions.delete 516.47
functions.variables.update 469.45
tablesdb.rows.create 437.16

@Meldiron
Meldiron merged commit 2aa55a4 into main Oct 2, 2026
52 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.

1 participant