Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This module was created to handle the ordering by delta using entity reference items, views has a field to do that, but views actually duplicate the result when sorting using a relationship, works if not using a relationship (which makes no sense), but this field is missing on modules like Config Pages that has no proper views integration.
Sandbox link:
https://www.drupal.org/sandbox/mete/2795269
Git:
git clone --branch 8.x-1.x https://git.drupal.org/sandbox/Mete/2795269.git
Comments
Comment #2
PA robot CreditAttribution: PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
E-MAILiT CreditAttribution: E-MAILiT commentedAUTOMATED REVIEW
There is some coding standard errors to fix:
http://pareview.sh/pareview/httpsgitdrupalorgsandboxmete2795269git
Individual user account
No: Please add your firstname and surname to your profile
No duplication
Yes: Does not cause
3rd party assets/code
Yes: Follows
README.txt/README.md
Please add a README.txt or README.md file.
Code long/complex enough for review
Yes. Well documented.
Secure code
None security issue found. Looks good.
Comment #4
anand.toshniwal93 CreditAttribution: anand.toshniwal93 as a volunteer and at QED42 commentedAutomated Review
There are some issues of coding standard try to fix it
http://pareview.sh/pareview/httpsgitdrupalorgsandboxmete2795269git
Manual Review
This review uses the Project Application Review Template.
Comment #5
anand.toshniwal93 CreditAttribution: anand.toshniwal93 as a volunteer and at QED42 commentedComment #6
Joao Sausen CreditAttribution: Joao Sausen commentedThanks for the reviews, I add the readme file and also properly renamed the module to views_order_by_delta from order_by_delta.
Comment #7
Joao Sausen CreditAttribution: Joao Sausen commentedComment #8
joachim CreditAttribution: joachim at Torchbox commentedI think you can get that from the entity storage handler.
That's wrong. You'll clash with something else, surely. Your key in the views data array should be unique.
So does every other handler class... tell us something different ;)
This is wrong. What if the query doesn't have the table for the field -- your handler does nothing!! You need to ensure your table is added. There's a method called something like ensureTable for that.
Overall, code looks good.
But AFAICT this functionality is already in core: I have a multi-valued field on my article nodes, and in Views I see this sort handler:
test text multiple (field_test_multiple:delta) Content Delta - Appears in: article.
Comment #9
Joao Sausen CreditAttribution: Joao Sausen commentedHey Joachim, thanks for your input. The feature exists indeed, but if you try to sort by that you will get duplicated results in case you use a relationship. You will probably be able to use the field without a relationship if you are referencing nodes to nodes, or any other entities, because the field exists in the referencing entity. Bu if you try to do that with different entities the field will exists for the referencing entity only and therefore there will be no way to use this field if not using a relationship, and this will cause duplications. In any case, try to setup that using 2 different entities, or try to use config_pages for that purpose. The issue is a bit difficult to explain, I hope you understand. In any case, I appreciate your review!
Comment #10
Joao Sausen CreditAttribution: Joao Sausen commentedAdd some comments and renamed the array key.
Comment #11
Joao Sausen CreditAttribution: Joao Sausen commentedComment #12
joachim CreditAttribution: joachim at Torchbox commented> The feature exists indeed, but if you try to sort by that you will get duplicated results in case you use a relationship. You will probably be able to use the field without a relationship if you are referencing nodes to nodes, or any other entities, because the field exists in the referencing entity.
I'm really confused by all this!
Can you give me a simple example of when core would give me duplicated results, but your module won't?
Comment #13
Joao Sausen CreditAttribution: Joao Sausen commentedAbsolutely.
Here are the steps to reproduce the error in a fresh drupal 8 installation:
Now the steps above are different on both cases.
For the drupal core field:
For the module field:
This only happens when relating 2 different entities, if you want to go ahead on the tests:
Note: In these examples, if you remove all sort criterias the content will be ordered like if you ordered by the delta value, you can rearrange the items on your field reference and this will works, but we can't rely on that since there will be no Order By.
Comment #14
joachim CreditAttribution: joachim at Torchbox commentedOk yup I see the duplicates.
It's because the Views relationship is going *backwards* along the reference. The field is like Term -> Node, but in the View, the relationship is used going Node -> Term.
The sort handler appears to be unaware of this, and is adding the join to {taxonomy_term__field_reference} all over again.
I would say this is a case for a bug report on core rather than a new module to work around it!
Comment #15
Joao Sausen CreditAttribution: Joao Sausen commentedI agree, thats a bug for sure, this also exists in Drupal 7. I was trying to debug core to try to solve that, unfortunately I don't have enough knowledge to do that for now...
Comment #16
Joao Sausen CreditAttribution: Joao Sausen at Dexa commentedWill this module be approved?
Comment #17
PA robot CreditAttribution: PA robot commentedProject 1: https://www.drupal.org/node/2873432
Project 2: https://www.drupal.org/node/2796023
As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).
If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #18
cimo75 CreditAttribution: cimo75 commentedBackporting to D7 please?
Comment #19
Joao Sausen CreditAttribution: Joao Sausen at Dexa commentedCimo75, leave the sort items blank and it will work as expected.
Comment #20
cimo75 CreditAttribution: cimo75 commentedHallo, I thinik I don't understand, can I install this module in D7?
Comment #21
Ravi Cmsminds CreditAttribution: Ravi Cmsminds commentedI checked your module and found some issues and recommendations that you may be interested in :
FILE: /root/repos/pareviewsh/pareview_temp/views_order_by_delta.views.inc
--------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------
8 | ERROR | [x] When importing a class with "use", do not include a
| | leading \
9 | ERROR | [x] When importing a class with "use", do not include a
| | leading \
15 | ERROR | [x] Short array syntax must be used to define arrays
39 | ERROR | [x] Short array syntax must be used to define arrays
40 | ERROR | [x] Short array syntax must be used to define arrays
42 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------
Comment #22
apaderno