Problem/Motivation
The comment module offers a combination of field, sort and filter for Views on "The most recent of last comment posted or entity updated time." Sorting and filtering on this value, however, is completely broken, because they are trying to get the changed field from the node table, which has long ago moved to the node_field_data table.
Steps to reproduce
- Set up a content type and comment type.
- Create at least two nodes, one with comments, one without
- Create a view of nodes of the content type
- Add a field "The most recent of last comment posted or entity updated time"
- (Add a sort on "The most recent of last comment posted or entity updated time" - you won't be able to do this because the previous step will already fail)
Proposed resolution
- Adjust the handlers to use the correct table
- Create one or more tests to verify the solution
Remaining tasks
- Create tests
- Create solution for the problem
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Todo.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 0001-Updated-patch-for-10.3-compatibility.patch | 11.63 KB | zoeblair |
| #9 | git.drupalcode.org_project_drupal_-_merge_requests_3280.patch | 12.64 KB | zoeblair |
Issue fork drupal-3335480
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
eelkeblokComment #3
eelkeblokComment #6
AndersTwo commentedThis fix did not make it into 10.1. Patching core is not a permament solution.
The bug essentially breaks any view that summarizes current site activity (similar to what forums do). That functionality is so central to the misssion of Drupal, I wonder how this could have been neglected for so long.
I suggest raising its priority.
Comment #7
AndersTwo commentedIn order for others to find this issue with Google:
Comment #8
eelkeblokNot sure how this got bumped to core 11.
Edit: Doh. Not sure why I missed the automated comment #5, I was looking for that sort of thing... I think I'll leave it on 10.x though, because I don't understand why a bug that basically prevents a particular functionality from doing what it is meant to should not be targeted at the current major version.
Comment #9
zoeblair commentedExported the diff as a patch for my D9 site, thanks @eelkeblok
Comment #11
eelkeblokCreated a tests-only merge request. Not sure if the tests were already functional.
Comment #12
smustgrave commentedCan confirm the issue.
Wonder those with the type change in the schema if any post update hook is going to be needed?
Comment #13
quietone commentedI am doing triage on the core RTBC queue.
The issue summary is clear and there are steps to reproduce. I used the steps to reproduce on Drupal 11.x, standard install, and got a failure when saving the last step, not before. I am updating the steps based on my results. The remaining steps could use an update.
I do not see a code review here. Setting back to NR.
On the other hand this is about comment and views, two systems that have a fair number of issues. Has anyone looked for duplicates? I am taking a moment now... There is #2086125: Last read comment field/filter/argument uses still the node.changed instead of node_field_data.changed column. This may be a duplicate of that. That needs investigation. I've put that in the remaining tasks as the next step here.
Comment #14
smustgrave commentedThey certainly have some overlap. But appears a lot more is going on in #2086125: Last read comment field/filter/argument uses still the node.changed instead of node_field_data.changed column.
So we have a fix here should we delay this one until that one is ready? Tried testing their patch but doesn't work, causes errors in the view.
Comment #15
smustgrave commentedLet me know if I'm wrong. But restoring status as we got a fix on this ticket while #2086125: Last read comment field/filter/argument uses still the node.changed instead of node_field_data.changed column does not and seems to have less momentum. I believe the other issue is solving more but may not be close yet to being ready.
Comment #16
niklp commented@eelkeblok I believe the reason that this (and all improvements/fixes to Drupal) are targetted at D11 is because it is deemed better to fix in a place that is future-proof, and then backport to current releases.
Comment #17
larowlanIt looks like one of the MRs has a failing test.
It looks like MR 3280 is adding a new test view for the sake of a test, but I don't see any tests that are using that view.
Can we confirm we have test coverage here?
Comment #18
jaydarnellI could not get the patch from 3280 to apply in Drupal 10.1.3. I will attempt to rewrite it today and report back. One thing to note in the meantime, this appears to be an issue with the Comment Statistics: Updated/commented date wholesale, not just for sorting and filtering. Just trying to output the value of the field in 10.1.3 also fails so I'll see if I can add coverage to that to a patch as well.
Comment #19
jaydarnellFalse alarm. The 3280 patch does in fact apply in 10.1.3. The problem is that I already had an older patch (#47) for Drupal 8+ from this issue https://www.drupal.org/project/drupal/issues/2086125 applied but it was no longer working for Drupal 10. Replacing that patch with this one fixed the issue for me.
Comment #21
zoeblair commentedThe patch doesn't seem to be applying to 10.3.6
And I see there's a note that patch files are not recommended? I can't figure out if I can update the merge request to be to 10.3 instead of 10.1
Comment #22
joelpittetLooks like the same code is changing in #2086125: Last read comment field/filter/argument uses still the node.changed instead of node_field_data.changed column — maybe this is a duplicate?
I feel the title represents something similar to an issue I am having, but I’ll create a separate issue to be safe (and not step on toes) #3540867: Views 'last updated/commented' field fails to sort entities without comment statistics.