Problem
Sometimes during development fields get removed and the entity that provided gets deleted before the fields are purged via field_purge_batch() leaving field_deleted_* tables in the database that can't be removed.
Proposed resolution
Provide a warning when skipping to tell the administrator that the fields can't be removed because the entity is gone. Hopefully giving them a clue that the entity needs to be re-created for the purge to go through.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | log_a_message_when-2862308-15.patch | 661 bytes | yogeshmpawar |
| #10 | interdiff-2862308-2-10.txt | 1.53 KB | yogeshmpawar |
| #10 | provide_more_feedback-2862308-10.patch | 1.42 KB | yogeshmpawar |
| #2 | 2862308-2.patch | 1.36 KB | joelpittet |
Comments
Comment #2
joelpittetIdeally I'd prefer if they got deleted but this seems to be a safer patch in my head.
Comment #3
joelpittetComment #4
joelpittetComment #6
joelpittetThis happened during field config migration, so tagging for maybe more exposure.
Comment #7
scuba_flyLooks good, would be very helpfull to show this logging.
Is calling \Drupal::entityManager() depricated and the reason you replaced it with an $entity_manager variable?
Can we get another review?
Comment #8
joelpittet@scuba_fly, yes I removed
\Drupal::entityManager()because it's deprecated AND I needed access to$entity_manageranyway later in the code, so avoid calling it twice, though maybe superfluous, it's straightforward.Comment #9
amateescu commentedHere's a review :)
The variable should be called $entity_type_manager.
We should mention the field name in the message.
The new line seems to have been detached from the code below it, let's put it back :)
Comment #10
yogeshmpawarUpdated patch as per suggestion from @amateescu on comment #9 & also added interdiff for this patch.
Comment #11
yogeshmpawarComment #12
amateescu commentedLooks great now :)
Comment #13
xjmThanks for working on this! A lot of people run into difficulties debugging field purging, so this seems like a good idea.
The entity type manager change isn't really in scope at all... it's not used in the line being added. This is a one-line patch with seven lines in it. :P Usages of the deprecated entity manager should be removed across all of core in a single patch or a set of patches grouped by concept. References: https://www.drupal.org/core/scope#creep and also the section on incomplete scope. This patch is small enough that it's still easy to review, but ideally, we should still remove those changes from the patch.
I don't think we're actually revisiting it in this issue, just adding a logged message to the same code without revisiting the code itself? So probably we shouldn't be removing this @todo either. The actual issue for it is #2343517: Cleanup @todo referring to the config dependencies API issue. Probably the @todo should have referenced that issue instead of the old one to avoid exactly this sort of confusion, but this is another reason not to make out-of-scope changes. :)
A novice could remove the unneeded hunks from this patch, and change it to just be the single line for the logger.
Thanks!
Comment #14
yogeshmpawarComment #15
yogeshmpawarUpdated patch as per suggestion by @xjm in comment #13
Comment #16
amateescu commentedA smaller scope for the patch is good as well :)
Comment #18
xjmCool, that works. Committed and pushed to 8.5.x. Thanks!