Problem/Motivation

Fatal error: Call to a member function getConfigDependencyName() on a non-object in FieldConfigBase.php

Proposed resolution

throw an exception that tells you more. even if it terminates the script, a better error message tells you more than this fatal.

CommentFileSizeAuthor
#3 interdiff.txt1.26 KBbenjy
#3 2374339-3.patch1.27 KBbenjy
better_error.patch1017 byteschx

Comments

benjy’s picture

Status: Needs review » Reviewed & tested by the community

This will be super helpful for Migrate testers as this error keeps popping up and overall improves DX.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -248,7 +248,9 @@ public function calculateDependencies() {
+        throw new \LogicException('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%id' => $this->bundle));

Missing String::format()

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.27 KB
new1.26 KB

Re-rolled with String::format() added.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

This would have been super-helpful while debugging #2355909: language.settings config is not scalable.

tstoeckler’s picture

Wow, this patch is amazing. The bad part about this is that this often happens when something goes wrong during the installer and/or migrations. And slowing down these already time-intensive processes by switching on XDebug just to figure out which friggin' entity it couldn't load is super annoying and in aggregate has probably cost me multiple hours already.

+10000

chx’s picture

Don't be be so enthusiastic , you will never get to see this exception on those places instead you'll get an exception in handling the error... which if I would care I would've filed already to fix it but alas I don't. This one here produces confusing migrate bug reports and yet noone was fixing so I did it. Don't expect me to take the generic one, though.

tstoeckler’s picture

Right, the "Exception thrown during handling of an exception" is nice as well. But I do regularly get this from drush si, maybe the error handling is different there? Don't know. Anyway, I am very enthusiastic about this, I'm not making this up :-)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This 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 ea24dc5 and pushed to 8.0.x. Thanks!

  • alexpott committed ea24dc5 on 8.0.x
    Issue #2374339 by benjy, chx: FieldConfigBase::calculateDependencies()...
penyaskito’s picture

+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -248,7 +249,9 @@ public function calculateDependencies() {
+        throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%id' => $this->bundle)));

We all missed that this should use %bundle in the array.

penyaskito’s picture

Status: Fixed » Closed (fixed)

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