Problem/Motivation
As per the change record Plugin implementations should use PHP attributes instead of annotations, Drupal 11 requires plugins to use PHP 8 attributes instead of
doctrine annotations.
The FlagViewsRelationship plugin in src/Plugin/views/relationship/FlagViewsRelationship.php still uses the old annotation format:
/**
* Provides a views relationship to select flag content by a flag.
*
* @ViewsRelationship("flag_relationship")
*/
class FlagViewsRelationship extends RelationshipPluginBase implements CacheableDependencyInterface {
This causes the relationship to be marked as "Broken" in Views when running on Drupal 11.3.x, resulting in errors like:
Warning: Undefined array key "base" in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo()
InvalidArgumentException: A valid cache entry key is required
Steps to reproduce
- Install Flag 5.0.3 on Drupal 11.x
- Create a view with a Flag relationship
- The relationship appears as "Broken/missing handler"
Proposed resolution
Convert the annotation to PHP 8 attribute format:
use Drupal\views\Attribute\ViewsRelationship;
/**
* Provides a views relationship to select flag content by a flag.
*/
#[ViewsRelationship("flag_relationship")]
class FlagViewsRelationship extends RelationshipPluginBase implements CacheableDependencyInterface {
Remaining tasks
- Review if other plugins in the Flag module also need conversion to attributes
- Create patch
- Add test coverage
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
ritarshi_chakraborty commentedComment #4
eduardo morales albertiCreated MR using PHP Attributes
Comment #5
ivnishTests failed and perhaps Drupal 10 support broken (needs check tests first)
Comment #6
ivnishAlso I can't reproduce this using the latest dev-version