Restore built-in image after user profile image destruction
Summary:
When you destroy a profile picture from the command line, that picture
does not cause anymore a 404 error on your user page. So, you do not see
anymore this problem:
{F4303304}
Instead, you just see your exciting builtin image, fully operational.
This will be even more useful in a future when users could be able to delete
their own profile pictures (T15407), and this would happen in a safe way,
without causing any website damages.
This feature works thanks to the brand-new "Before-Destruction Engine",
described in T16079.
To find which users use a file, we first look at where the file is attached,
because in normal conditions this search is very efficient, even if you have
a billion users with a billion profile pictures.
As a last attempt, we look at the 'user' table. We may want an index in the
future here, but this query is so rare that we can avoid it (T16080).
Ref T15407
Ref T16079
Ref T16080
Closes T16074
Closes T16078
Test Plan:
Normal test:
As indicated in T16074, set your profile picture by uploading an image,
then, destroy it from the command line (./bin/remove destroy MONOGRAM).
You do not see anymore a broken user image causing 404 errors,
but you see your lovely builtin image.
Corner case test:
Upload another profile picture, visit that file directly, click on {nav Attached > Detach File}
(since it was possible, so we expect somebody may click on it) and destroy that file again
from command line: it still works as intended and you see your builtin image,
and not a blank image and 404 errors in the browser requests.
Quality assurance:
Images from other users are as they were before, in all cases.
Or, just execute the new unit test that covers both cases:
arc unit src/applications/people/editor/__tests__/PhabricatorUserEditorTestCase.php
You will see a green light about 'testProfilePictureDestruction'.
Reviewers: O1 Blessed Committers, mainframe98, aklapper
Reviewed By: O1 Blessed Committers, mainframe98, aklapper
Subscribers: amybones, aklapper, mainframe98, tobiaswiese, Matthew, Cigaryno
Maniphest Tasks: T16079, T16078, T16074, T15407, T16080
Differential Revision: https://we.phorge.it/D26027