Since 8.7.0, EntityViewBuilder::__construct() takes an optional fifth argument (non-optional after 9.0.0), which is an EntityDisplayRepositoryInterface implementation.
It then checks whether that argument was indeed passed and triggers a warning if it wasn't. However the message in the warning is incorrect: it mentions Calling EntityViewBuilder::__construct() with the $entity_repository argument [...]
, but:
- there is already an
EntityRepositoryInterface
implementation as the second argument - the warning should actually refer to the fifth argument which is an
EntityDisplayRepositoryInterface
instead ofEntityRepositoryInterface
.
Fix: change the wording to Calling EntityViewBuilder::__construct() with the $entity_display_repository argument [...]
.
Comment | File | Size | Author |
---|---|---|---|
#14 | incorrect_error_EntityViewBuilder-3133386-14.patch | 1.14 KB | jyotimishra-developer |
#5 | incorrect_error_EntityViewBuilder-3133386-5.patch | 1.15 KB | jyotimishra-developer |
Comments
Comment #2
jyotimishra-developer CreditAttribution: jyotimishra-developer commentedComment #3
jyotimishra-developer CreditAttribution: jyotimishra-developer commented@fgm
Hi,can you kindly tell me how did you produce or encounter this error?
Comment #4
fgmIt happened when writing the D9 patch for https://drupal.org/project/dfp which only passes the required parameters to this builder from a inherited builder in the module...using the legacy EntityManagerInterface instead of the Repository as second parameter. So my patch changed the second parameter to Repository and it didn't make sense to get this incorrect error although I had just added the Repository. That's when I noticed it was in fact about the DisplayRepository, not the Repository.
Comment #5
jyotimishra-developer CreditAttribution: jyotimishra-developer commentedComment #6
atul4drupal CreditAttribution: atul4drupal commentedhttps://dispatcher.drupalci.org/job/drupal_patches/44832/
Comment #7
atul4drupal CreditAttribution: atul4drupal commentedThanks jyotimishra123, for the patch at #5 it is good to fix the issue and returns expected message
Comment #8
jyotimishra-developer CreditAttribution: jyotimishra-developer commentedComment #9
jyotimishra-developer CreditAttribution: jyotimishra-developer at Srijan | A Material+ Company for Drupal India Association commentedComment #10
jyotimishra-developer CreditAttribution: jyotimishra-developer at Srijan | A Material+ Company for Drupal India Association commentedHi @fgm, please review
Comment #11
ju.vanderw CreditAttribution: ju.vanderw at Palantir.net commentedReviewed the trigger error and it communicates the correct parameter name and the fact that it will be required before 9.0.0.
Comment #12
alexpottThe text "__construct() with the $argument" is standardised across core. See the \Drupal\views\Plugin\views\row\EntityRow::__construct()
So that should not change here but +1 to detailing the correct argument in the message.
Comment #13
jyotimishra-developer CreditAttribution: jyotimishra-developer at Srijan | A Material+ Company for Drupal India Association commentedComment #14
jyotimishra-developer CreditAttribution: jyotimishra-developer at Srijan | A Material+ Company for Drupal India Association commentedaddressed #12
Comment #15
jyotimishra-developer CreditAttribution: jyotimishra-developer at Srijan | A Material+ Company for Drupal India Association commentedComment #16
fgmAddressed alexpott's remarks, so LGTM.Comment #18
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedMarking RTBC based on #16 and tests are green.
Comment #19
alexpottEven though we only commit major bugs to 8.9.x I think this is worth it because it helps people prep for Drupal 9 so it's worth fixing - and committing has no risk.
Committed fca86a9 and pushed to 8.9.x. Thanks!