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

CommentFileSizeAuthor
#2 114-add-entityinterface.patch2.47 KBmakkus183

Comments

makkus183 created an issue. See original summary.

makkus183’s picture

StatusFileSize
new2.47 KB
makkus183’s picture

Status: Active » Needs review
kingdutch’s picture

Version: 8.x-9.2 » 8.x-9.x-dev
Assigned: makkus183 » Unassigned

A 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.

ronaldtebrake’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch, it will be part of the 9.6 release

  • ronaldtebrake committed 86c9cf9 on 8.x-9.x
    Merge pull request #2017 from makkus183/bugfix/3175191-add-entity-...

ronaldtebrake’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.