This module provides friendship workflows for Drupal users, enabling users to follow, connect, and manage friendship relationships.
This module provides friendship workflows for Drupal users, enabling users to follow, connect, and manage friendship relationships.
Comments
Comment #2
vishal.kadamThank you for applying!
Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review. See also Policy on the use of AI when contributing to Drupal, which is valid when contributing to Drupal, either by committing code in a project, or by creating a merge request for an existing project.
The important notes are the following.
Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
To the reviewers
Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.
The important notes are the following.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.
Comment #3
batigolixComment #4
batigolixI reviewed the application.
Here is a list of possible improvements.
1. Fix the phpstan warnings as shown in the Gitlab CI pipeline
2. Convert the readme.txt to a README.md conform following the template in https://www.drupal.org/docs/develop/managing-a-drupalorg-theme-module-or...
3. LICENSE.txt is not needed as your module has the same license as Drupal. See https://www.drupal.org/node/1587704#licensingchecks
4. Review the security of the routes. It seems there are no access checks defined on any friendship action routes. Any authenticated user could trigger actions without proper permission verification. Location: friendship.routing.yml - all routes
5. Review the security of the routes. Check if the need csrf_token as requirement. See https://www.drupal.org/docs/8/api/routing-system/access-checking-on-rout...
6. src/Controller/FriendshipController.php . This controller methods accept UserInterface but don't validate if: User exists and is active, User is not the current user, User is not blocked or deleted
7. src/FriendshipService.php use Drupal API to generate token. \Drupal::service('uuid')->generate() instead $id_hash = md5($target_user->id() + rand());
8. Add field descriptions in friendship_schema, because most are empty. E.g.:
9. src/FriendshipInterface.php Interface doesn't declare getProcessLink() and getLinkAttributes() methods
10. Improve name and logic of method isHasRelationship. I think it should retun true if there is a relationship?:
return FALSE;
}
11. Try resolve as much @todo comments as possible.
12. Automatic tests could be useful to prevent future regressions
13. hook_uninstall does not remove the custom table data
14. friendship/process-link library is missing (see FriendshipService.php):
15. Friendship.php refers to a missing Views data handler "views_data" = "Drupal\friendship\Entity\EntityViewsData",
16. Add more inline documentation for more complex method. E.g. in FriendshipService.php
Comment #5
batigolixComment #6
vitaliyb98 commentedHi @batigolix, thanks for your feedback.
I made changes according to your suggestion ( in release 2.1.0):
Comment #7
vishal.kadamAs a side note: These applications do not require that new releases are created after reviews.
It is better not to create new release during these applications, since a review could ask for a change that is not backward compatible with the existing releases. Just using a development version avoids those BC issues.
Comment #8
nkmaniI reviewed the latest 2.x branch code and following are my comments:
1. friendship.info.yml
Version 9.5 is an unsupported release. Consider dropping support.
2. friendship.permissions.yml
Consistency in naming yml keys; the first line does not need quotes.
3. FriendShipService.php, TotalFollowersNumber.php, TotalFollowingNumber.php, TotalFriendsNumber.php
The query results are not cached; dependence on downstream caching, which is fine. But ...
4. FriendshipSettingsForm.php
In case version 9.5 support is removed, then there is no need for '#default_value'; instead use '#config_target'. Simplifies the form; there is no need for implementing submitForm; that would be handled in the base class.
5. Consider using string constants for often re-used string values.
Comment #9
vishal.kadamComment #10
vitaliyb98 commentedHi, made changes according to your comments:
1. Introduced a new major branch 3.x which will support Drupal >= 10 https://git.drupalcode.org/project/friendship/-/blob/3.x/friendship.info...
2. Fixed: https://git.drupalcode.org/project/friendship/-/blob/2.x/friendship.perm...
3. Added cache https://git.drupalcode.org/project/friendship/-/blob/2.x/src/Plugin/view...
4. Done (in 3.x): https://git.drupalcode.org/project/friendship/-/blob/3.x/src/Form/Friend...
5. Checked code to detect which string values could be replaced with a constant, introduced this:
Comment #11
vitaliyb98 commentedHi guys, any updates?
Comment #12
vishal.kadamI am changing priority as per Issue priorities.
Comment #13
vishal.kadamI am changing priority as per Issue priorities.
Comment #14
avpadernoComment #15
solideogloria commentedThe method
isHasRelationshipshould be namedhasRelationship. You want the words in the function name to make grammatical sense. You can deprecate the old function and make it call the new. Similarly,isFollowedYoushould beisFollowingYouorhasFollowedYou.isRequestSendshould beisRequestSent.Friendship is a
ContentEntityType, but it's using the Annotation instead of the Attribute. I'm not sure what the minimum version requirement for usingDrupal\Core\Entity\Attribute\ContentEntityTypeis, but it's worth looking into whether you can use the attribute instead.Constructor doc block comments are now optional. Consider removing extraneous comments like this that don't add any new information:
Consider making the return type of the controller's
accessmethodAccessResultInterface.Comment #16
solideogloria commentedComment #17
vitaliyb98 commentedHi @solideogloria,
Thank you for your feedback. I appreciate it.
I made changes based on your suggestion and merged them into the 3.x branch: https://git.drupalcode.org/project/friendship/-/tree/3.x?ref_type=heads
Comment #18
vitaliyb98 commentedHi, guys, any updates?
Comment #19
vishal.kadamI am changing priority as per Issue priorities.
Comment #20
avpadernoComment #21
avpadernosrc/Controller/FriendshipController.php
Since that class does not use methods from the parent class, or it uses a single method from the parent class, it does not need to use
ControllerBaseas parent class.Controllers do not need to have a parent class; as long as they implement
\Drupal\Core\DependencyInjection\ContainerInjectionInterface, they are fine.With Drupal 10.2.x and higher versions, a controller class does not need to implement
create(); usingAutowireTrait, it just needs to implement the class constructor.src/Entity/Friendship.php
Projects that are compatible with Drupal 10 or higher versions should use attributes instead of annotations. This means requiring at least Drupal 10.3, but this is not an issue, considering which Drupal core versions are nowadays supported.
src/Form/FriendshipSettingsForm.php
As described in #config_target in ConfigFormBase: using validation constraints for editing simple config, that code only works starting with Drupal 10.2.x. The project needs to explicitly require Drupal 10.2.x or any higher version.
src/FriendshipService.php
Services can be autowired starting with Drupal 9.3.x. This means that it is no longer necessary to give a list of service arguments in the .services.yml file; they will be retrieved from the constructor definition.
$this->config = $configFactory->get('friendship.settings');Using a class property for the configuration object is considered an anti-pattern. Instead, the class property should be for the configuration factory.
Deprecating that method has been done in the correct way. 👍
src/FriendshipInterface.php
Deprecated methods should still be listed in that interface, but use the
@deprecatedtag. As consequence of this, the documentation comments need to be moved from the service class to the interface.friendship.module
A new module that aims to be compatible with latest Drupal releases is expected to implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
It requires increasing the minimum required Drupal version, but that is not an issue, since not all the Drupal releases are supported.
friendship.services.yml
Services can be autowired starting with Drupal 9.3.x. This means that it is no longer necessary to give a list of service arguments in the .services.yml file; they will be retrieved from the constructor definition.
Comment #22
avpadernoComment #23
vitaliyb98 commentedHi @avpaderno
Thank you for your feedback!
I decided that for the next major version of the module (the 3.x branch), we should support Drupal 11.1+ since the Drupal 12 release is coming soon anyway.
This will also give us more freedom to drop support for legacy features and compatibility with Drupal 10.
Users who are still on Drupal 10 will be able to continue using the 2.x version.
I made changes according to your feedback
These changes will also make the transition to Drupal 12 easier and faster.
Comment #24
avpadernoThank you for your contribution and for your patience with the review process!
I am going to update your account so you can opt into security advisory coverage any project you create, including the projects you already created.
These are some recommended readings to help you with maintainership:
You can find more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved!
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank also all the reviewers for helping with these applications.
Comment #25
avpaderno