Problem/Motivation
After updating open social from 8.4.0 => 9.2.0 i got an HTTP 500 Error when entering a new Post in Newsfeed Field (Say something to the community). Apache Error Log logs:
Declaration of Drupal\\social_group_request\\Plugin\\ActivityContext\\ApprovedRequestJoinGroupActivityContext::isValidEntity($entity) must be compatible with Drupal\\activity_creator\\Plugin\\ActivityContextInterface::isValidEntity(Drupal\\Core\\Entity\\EntityInterface $entity) in ../profiles/contrib/social/modules/social_features/social_group/modules/social_group_request/src/Plugin/ActivityContext/ApprovedRequestJoinGroupActivityContext.php
Quite similar error happens when creating a new event:
Got error 'PHP message: PHP Fatal error: Declaration of Drupal\\social_group_invite\\Plugin\\ActivityContext\\InvitedToGroupActivityContext::isValidEntity($entity) must be compatible with Drupal\\activity_creator\\Plugin\\ActivityContextInterface::isValidEntity(Drupal\\Core\\Entity\\EntityInterface $entity) in ../profiles/contrib/social/modules/social_features/social_group/modules/social_group_invite/src/Plugin/ActivityContext/InvitedToGroupActivityContext.php
Steps to reproduce
Update Open Social from 8.4.0 => 9.2.0 with
composer update
Proposed resolution
Add EntityInterface to $entity parameter isValidEntity() and use statement in
profiles/contrib/social/modules/social_features/social_group/modules/social_group_invite/src/Plugin/ActivityContext/InvitedToGroupActivityContext.php and profiles/contrib/social/modules/social_features/social_group/modules/social_group_request/src/Plugin/ActivityContext/ApprovedRequestJoinGroupActivityContext.php and the matching use statement:
use Drupal\Core\Entity\EntityInterface;
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 114-add-entityinterface.patch | 2.47 KB | makkus183 |
Comments
Comment #2
makkus183 commentedComment #3
makkus183 commentedComment #4
kingdutchA short-term workaround is to update your PHP version, since this implementation is valid in PHP 7.2 and above: https://www.php.net/manual/en/migration72.new-features.php#migration72.n... This indicates you're probably using PHP 7.1 which no longer receives security updates.
Having said that, the classes implementing the interface do no actual work to support types other than an EntityInterface typed paramter (and even add a doccomment in the class to indicate this) so this is not a correct use of paramter type widening and should be resolved with the patch attached.
Comment #5
ronaldtebrake commentedThanks for the patch, it will be part of the 9.6 release
Comment #8
ronaldtebrake commented