Problem/Motivation

The error message returned upon a non existing config entity does not include entity type.
example:
A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: field_reference_number, bundle: test_field_1

In order to make debugging easier we could improve the error message by adding the entity type to it.

Proposed resolution

Use $entity_type that already exist in the method to improve error message.
Path to file: views/views.views.inc line 378

Remaining tasks

Create patch

User interface changes

Non

API changes

Non

Data model changes

Non

CommentFileSizeAuthor
#9 2985907-9.patch959 bytesacbramley
#2 2985907-1.patch895 bytespasan.gamage

Comments

pasan.gamage created an issue. See original summary.

pasan.gamage’s picture

StatusFileSize
new895 bytes

Attaching patch file.

Thanks.

pasan.gamage’s picture

Status: Active » Needs review

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dydave’s picture

I tried patch from #2 (on D8.6.1) and indeed, it does what it says, for example, in my case :

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: body, bundle: xxx, entity type: block_content

Along with #2916266-2: How to fix "non-existent config entity name returned by FieldStorageConfigInterface::getBundles()" , it helped me debugging and fixing the error, by identifying the entity for which the field/bundle configuration was still in DB.

Thanks for the patch.
Cheers!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Usability +DX (Developer Experience)

Nice! I corrected the tags from usability to DX.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. Let's change the order to match the name - FieldConfig::loadByName($entity_type->id(), $bundle, $field_name); - ie. 'A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: %entity_type, bundle: %bundle, field name: %field,' and change %entity to be %entity_type
  2. +++ b/core/modules/views/views.views.inc
    @@ -375,8 +375,8 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
    -        t('A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: %field, bundle: %bundle',
    -          ['%field' => $field_name, '%bundle' => $bundle]
    +        t('A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: %field, bundle: %bundle, entity type: %entity',
    +          ['%field' => $field_name, '%bundle' => $bundle, '%entity' => $entity_type->id()]
             ));
    

    Let's also remove the t() here and pass the variables as proper context to the error handler. Error messages should not be translated via t().

  3. +++ b/core/modules/views/views.views.inc
    @@ -375,8 +375,8 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
           // https://www.drupal.org/node/2451657#comment-11462881
    

    Can someone file a follow-up to remove this comment and replace it with something helpful from https://www.drupal.org/node/2451657#comment-11462881

acbramley’s picture

#3005490: Replace drupal issue link in views.views.inc with helpful comment created for the follow up, patch addressing feedback coming shortly.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new959 bytes

This also fixes an exception thrown when clearing cache when your DB is in this broken state:

In TranslatableMarkup.php line 133:
  $string ("A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: %field, bundle: %bundle") must be a string.

Due to passing t() into the error() call.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect. % is the type of placeholder which can be used in error messages.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: 2985907-9.patch, failed testing. View results

acbramley’s picture

Status: Needs work » Reviewed & tested by the community

CI blip?

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 7151900f30 to 8.7.x and 675f87f7a6 to 8.6.x. Thanks!

  • alexpott committed 7151900 on 8.7.x
    Issue #2985907 by pasan.gamage, acbramley, dawehner, alexpott, DYdave:...

  • alexpott committed 675f87f on 8.6.x
    Issue #2985907 by pasan.gamage, acbramley, dawehner, alexpott, DYdave:...
dydave’s picture

Thanks Alex for the review and Adam for the re-roll.

Impressive how fast this issue was processed.
Thanks everyone!
Cheers!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rapindrive’s picture

#9 this works correctly for me. Thanks!!