Project
Fuzzy entity reference module allows users to integrate loilo/fuse (https://github.com/loilo/Fuse) library for entity reference autocomplete.
Typically when we have CONTAINS or STARTS_WITH operator to match the entity reference results.
Sometimes what happens when we have the correct matching it doesn't consider appropriate string because it doesn't do the approximate search. Due to that matched string doesn't appear in the auto-complete results.
This module implements the fuzzy search on node title and displays the results based on the calculated distance from the searched input string.
Code checks
Pareview.sh output is coming okay apart from suggestions related to branch name.
Sharing following output:
<ul>
-e <li>It appears you are working in the "1.0.x" branch in git. You should really be working in a version specific branch. The most direct documentation on this is <a href="https://www.drupal.org/node/1127732">Moving from a master branch to a version branch.</a> For additional resources please see the documentation about <a href="https://www.drupal.org/node/1015226">release naming conventions</a> and <a href="https://www.drupal.org/node/1066342">creating a branch in git</a>.</li>
</ul>
Review of the 1.0.x branch (commit 5fad7e8):
<ul>
</ul>
<i>This automated report was generated with <a href="https://www.drupal.org/project/pareviewsh">PAReview.sh</a>, your friendly project application review script.</i>Branch name is already following semantic versionsing.
Comments
Comment #2
mohit_aghera commentedComment #3
vishal.kadamThank you for applying! Reviewers will review the project files, describing what needs to be changed.
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.
To reviewers: Please read How to review security advisory coverage applications, What to cover in an application review, and Drupal.org security advisory coverage application workflow.
While this application is open, only the user who opened the application can make commits to the project used for the application.
Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.
Comment #4
vishal.kadamComment #5
avpadernoComment #6
vishal.kadamHello @mohit_aghera,
I have reviewed the code and it look fine to me.
Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.
Thanks
Comment #7
andrei.vesterlihi @mohit_aghera
core_version_requirement: ^8.8 || ^9 || ^10and notcore_version_requirement: ^8 || ^9 || ^10because it has 10 too.core: 8.xfrom info filegetReferenceableEntities(bool $match = NULL, string $match_operator = 'CONTAINS', int $limit = 10)and test it.composer.jsonfile.The rest seems to be ok.
Regards,
Andrei
Comment #8
andrei.vesterliComment #9
mohit_aghera commentedHi @andrei.vesterli
Fixed 1, 2 and 4th points.
Regarding point 3: I think PHP will throw error due to declaration of method compatibility.
Base class's method doesn't have typed arguments.
Update:
Tried 3rd points on local and got following error:
Declaration of Drupal\fuzzy_entity_reference\Plugin\EntityReferenceSelection\FuzzyEntityAutocomplete::getReferenceableEntities(?bool $match = NULL, string $match_operator = 'CONTAINS', int $limit = 10): array must be compatible with Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0Comment #10
andrei.vesterliHi @mohit_aghera again
I see. It's an extend probably. No worries then. For me, this is more than ok!
Regards,
Andrei
Comment #11
reszliGeneral remark:
This appreach loads all the possible entities that can possibly be referenced in order to build the source of the fuzzy search.
This can be an issues for sites with a large number of entities - this should be explained on the project detail page.
Even for small/medium data sets, IMHO a major performance imporovement would be to cache that data and only invalidate on ENTITY_TYPE_list:BUNDLE cache tags.
Manual Review
This review uses the Project Application Review Template.
Comment #12
avpadernoSince the module is compatible with Drupal 8.8.x and Drupal 9.x, it cannot use features implemented in PHP 8.1 without declaring the minimum required PHP version. Either that or the code is changed to be compatible with the PHP version required by Drupal 8.8.x.
src/Plugin/Field/FieldWidget/FuzzyAutocompleteWidget.php
{@inheritdoc}is not used for class constructors.Comment #13
mohit_aghera commented@reszli
Thank you for the feedback.
I've little doubt about following:
Even for small/medium data sets, IMHO a major performance imporovement would be to cache that data and only invalidate on ENTITY_TYPE_list:BUNDLE cache tags.I initially tried to cache it, however, since search term can be anything, we can't cache the results based on the search term.
Can you please give me more information, it seems I am missing something here.
@apaderno
{@inheritdoc} is not used for class constructors.It is already added here https://git.drupalcode.org/project/fuzzy_entity_reference/-/blob/1.0.x/s...
Should I describe each argument further?
Comment #14
avpadernoI am referring to the documentation comment before the class constructor.
{@inheritdoc}is not used for class constructors. Their documentation comments need to document the parameters the constructor receives, but not the return value.Comment #15
reszli@mohit_aghera I'm proposing to cache the list of entity labels used to run the search on (and not caching the search results themselves)
https://git.drupalcode.org/project/fuzzy_entity_reference/-/blob/1.0.x/s..., lines 57-82, aka. the $matches variable calculation could be cached until new labels are added / existing ones are updated
Comment #16
mohit_aghera commentedHi @reszli
Thanks for the feedback and guidance for the implementation.
I did refactoring so that we can cache the results for particular search term.
I've pushed the code in the branch along with test for it.
Commit https://git.drupalcode.org/project/fuzzy_entity_reference/-/commit/1df25...
(Please ignore schema changes from config, already removed in next commit)
Also, I've fixed the changes mentioned by @apaderno in comment #14
Can you please review this and let me know how it goes?
Comment #17
avpadernoThank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the Slack #contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
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 all the reviewers.
Comment #18
avpaderno