Problem/Motivation
Why does views_field_config_create() invalidate the views data cache? Why doesn't that only happen when a field is saved? The field isn't even persisted yet, so if another hook will then fetch views data, it will not be visible yet?
This is especially bad because field purging apparently invokes the create hook, during cron runs:
#0 core/modules/views/src/ViewsData.php (325, invalidateTags)
#1 core/modules/views/views.module (465, clear)
#2 (0, views_field_config_create)
#3 core/lib/Drupal/Core/Extension/ModuleHandler.php (395, call_user_func_array)
#4 core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php (336, invokeAll)
#5 core/lib/Drupal/Core/Entity/EntityStorageBase.php (197, invokeHook)
#6 core/modules/field/src/FieldConfigStorage.php (134, create)
#7 core/includes/entity.inc (166, loadByProperties)
#8 core/modules/field/field.purge.inc (83, entity_load_multiple_by_properties)
#9 core/modules/field/field.module (145, field_purge_batch)
Pretty sure this is the wrong hook and is supposed to be insert?
It's also likely that this shouldn't even invoke that hook but it still makes no sense.
Proposed resolution
Switch to the insert() hook.
Remaining tasks
User interface changes
API changes
Comments
Comment #1
berdirAnd here's a patch for that.
Comment #2
berdirI guess repeatedly only happens when you have multiple fields, improving title
Comment #3
dawehnerOH yeah, that seems to make sense.
Comment #4
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 6ebade7 and pushed to 8.0.x. Thanks!