Follow-up to #2374339: FieldConfigBase::calculateDependencies() fatal error is unhelpful
Problem/Motivation
+++ 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)));
This should use %bundle in the array.
Proposed resolution
Fix.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | interdiff.txt | 1.32 KB | benjy |
| #6 | 2384665-6.patch | 3.61 KB | benjy |
| #4 | interdiff.txt | 2.61 KB | benjy |
| #4 | 2384665-4.patch | 3.63 KB | benjy |
| #1 | 2384665.patch | 1.02 KB | penyaskito |
Comments
Comment #1
penyaskitoPatch attached.
Comment #2
benjy commentedGood catch.
Comment #3
alexpottLet's test this in FieldConfigEntityUnitTest
Comment #4
benjy commentedI first went with the following on top of the class:
But I decided that catching the exception would allow me to assert the exact error message since we had previously got that wrong as well.
Comment #5
penyaskitoIf message is hardcoded, why the previous approach would not work?
Comment #6
benjy commentedGood point, when I wrote that I was using $this->entityTypeId which is calculated at run time but then I updated it last minute. New patch attached.
Thanks for the review.
Comment #7
penyaskitoI was just curious, not a strong preference. Both #4 and #6 look good to me.
Comment #8
dawehnerDo we really want to ensure that things are called here in that exact order? I think using ->willReturnValueMap is the better approach to reduce changes in the test, when the actual code is refactored.
Comment #9
benjy commentedIt was an exact copy and paste from the test above it. We could refactor both tests if you think willReturnValueMap() is better, how about a follow-up for that?
Comment #10
dawehnerOkay sure, where is the URL :P
Comment #11
benjy commentedIssue created, #2389837: Refactor FieldConfigEntityUnitTest to make it resilient to changes. See you there.
Comment #12
penyaskitoPostponed that one on this one.
Comment #13
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 1ffac67 and pushed to 8.0.x. Thanks!