Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are some helpful views field plugins that provide the label for payment method, status, etc. The code however assumes that there will always be a value, and they fatal if none is available.
This would occur for example if you have a view for an entity that has an entity reference field to the payment entity, however the views relationship is not required (ie. some entities have payments and some do not).
Proposed resolution
The solution is to check for the value first and return NULL if none is provided.
Comment | File | Size | Author |
---|---|---|---|
#5 | views_plugin_label-2902006-5.patch | 8.72 KB | yanniboi |
#2 | views_plugin_label-2902006-2.patch | 2.88 KB | yanniboi |
Comments
Comment #2
yanniboi CreditAttribution: yanniboi at FreelyGive commentedComment #3
yanniboi CreditAttribution: yanniboi at FreelyGive commentedThis might be a good opportunity to add an abstract views field plugin label class for the above to implement. We could basically abstract the entire render method out because it is virtually identical for each of the label classes.
Comment #4
yanniboi CreditAttribution: yanniboi at FreelyGive commentedIf you like the abstract class idea. This is a patch for it. However I am happy either way.
Comment #5
yanniboi CreditAttribution: yanniboi at FreelyGive commentedAhh I missed the class out... Here is the correct patch for the abstract base class.