Problem/Motivation
This is spun off from #2878119-116: Whether queued or not, update the media thumbnail and metadata before beginning the entity save database transaction:
If you call $media->save(), there is no chance that you will be waiting on an HTTP request during a database transaction.
If you call Drupal::entityTypeManager()->getStorage('media')->save($media), you might.
Since both ways are valid ways of saving a media item (and in fact, the second one is probably more "correct"), we need to fix this so that, no matter how you save your media items, you cannot end up in an HTTP request during a database transaction.
That's why this is critical. The crux of the issue is not whether authors have the correct metadata or not at save time; it's that they could potentially scramble their database if they are saving too many media items the "wrong" way at once.
Now, if that means we split off a new issue and fix the immediate problem without cleaning up the API as well, so be it. We can improve the actual API for 8.7.x. I defer that decision to the committers. But the main problem (the possibility of waiting for HTTP during a database transaction) is the actual critical bug that must be fixed now for 8.6.
Proposed resolution
Move the logic in Media::save() to the media entity's storage handler, so that no matter how you save, HTTP stuff is done outside the database transaction.
Remaining tasks
Do it.
User interface changes
None.
API changes
None.
Data model changes
None.