
Problem/Motivation
The tracker module currently depends on the comment module even if some of it's functions are not related to comments at all (eg. see if a node has been created/updated since our last visit). Sites that does not have comments or that's using another comment module than the core's one (eg. Disqus) cannot use the abilities of Tracker on nodes.
Proposed resolution
Remove comment module dependency and use a condition wherever it's needed to keep existing functionnalities active if the comment module is installed.
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Instructions | Done | |
Reroll the patch if it no longer applies. | Instructions | Done | |
Update the issue summary | Instructions | Done | |
Draft a change record for the API changes | Instructions | ||
Improve patch documentation or standards (for just lines changed by the patch) | Novice | Instructions | Done |
Update the patch to incorporate feedback from reviews (include an interdiff) | Instructions | Done | |
Manually test the patch | Novice | Instructions | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
User interface changes
Comment module is no longer required to enable tracker module.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#130 | 366511-130.patch | 29.78 KB | smustgrave |
#130 | interdiff-126-130.txt | 2.85 KB | smustgrave |
#126 | 366511-126.patch | 29.73 KB | smustgrave |
#126 | interdiff-124-126.txt | 6.85 KB | smustgrave |
Comments
Comment #1
robloachThe Tracker module requires Comment module to be enabled. Does it really need this dependency?
Comment #2
naheemsays CreditAttribution: naheemsays commentedViews has a tracker-like view that (probably) can probably (be made to) work without comments enabled?
Comment #3
joachim CreditAttribution: joachim commentedhttp://drupal.org/project/trackerlite is a clone of tracker but with the comment dependency ripped out.
Comment #4
flaviovs CreditAttribution: flaviovs commented+1
Tracker shouldn't depend on comment module, though rather enhance its own functionality if the latter is installed (i.e. when
module_exists("comment")
returns TRUE).I've seen so many sites where tracking posts is a highly wanted feature, but post comments aren't needed or desirable.
Comment #5
joachim CreditAttribution: joachim commentedThis is so much simpler with the new DB API!
Patch attached.
Comment #6
berdirYou might be able to use the fluent interface to combine all non-conditional fields/condition calls into one. Something like that (after joins and conditional stuff):
$result = $query
->fields()
->fields()
->condition()
->execute();
Also, IN is the default when an array is passed to condition, so you can ommit that.
Not sure what our Coding Standard says about this, seems un-common :)
This review is powered by Dreditor.
Comment #7
joachim CreditAttribution: joachim commentedFor the conditional in the #header array -- seemed a bit easier on the eye than cutting the array assignment up key by key
What do other people think?
Comment #8
dries CreditAttribution: dries commentedmodule_exists() does internal caching (through module_list()) so I'm not sure we need to keep a local variable. Pretty minor though.
Comment #9
joachim CreditAttribution: joachim commentedI figured it saved us 3 or 4 function calls to the same thing -- though the flipside is storing the local variable.
Since I know next to nothing about code optimization, I'll change this when I reroll.
Comment #10
joachim CreditAttribution: joachim commentedUpdated patch with changes suggested above.
I've taken the ternary operator out of the array assignment but kept it like this:
Like this the two different versions of the header are on consecutive lines, and so I think it's easier to see how they differ than with an if-else block.
Comment #11
joachim CreditAttribution: joachim commentedHappened to spot these today in modules/node/content_types.inc:
which is later checked in conditionals.
and
Should I maybe revert my changes back to the original style for consistency in core?
Comment #12
catchIf it's not called dozens of times, then there's no real performance impact one way or the other, but assigning a variable can make things more concise if it's used several times, so it's really just a matter of taste here.
Comment #13
robloachWhat if instead of having Tracker check if Comment module's data is available, we make the Comment module add the data to the Tracker page through a hook? Decoupling is a good thing, just not sure of the best way around it.
Comment #14
joachim CreditAttribution: joachim commentedI don't think it would work -- for that to be a clean hierarchically, it would surely entail having comment module do things to tracker's tables, rather than with comment-related hooks in tracker as currently. Which sounds terribly complicated to me.
Also, which other modules would use this? I can't think of any in core. And why would a contrib module support this hook, for one list of stuff, when it can just supply a field to Views module?
This is a small fix I'd like to see get in for 7 -- please let's not creep it! :)
Comment #15
MichaelCole CreditAttribution: MichaelCole commented#10: 366511-2.drupal.tracker-without-comment.patch queued for re-testing.
Comment #16
catchComment #17
Nephele CreditAttribution: Nephele commented@14: Well... so much for Drupal 7 ;) To give this a chance of perhaps making it into Drupal 8, I've updated the last patch to work on HEAD. Assuming that's even the relevant code-base now??
Actually, I started out doing a patch on my own (since I was looking in 7.x instead of 8.x for existing patches), then found this thread and was pleasantly surprised to see that what I'd done was remarkably similar to the existing patch. However, by starting with a fresh look at the code, I was able to identify a few additional changes, so I've merged those into the new patch. In particular, I found a few more places where a check for module_exists('comment') was needed (probably code added to HEAD since the last patch was written). Furthermore, I revamped the tests so that there are tests being done both with and without the comment module.
Is there anything else that needs to be done to get this moving forward again?
Comment #18
joachim CreditAttribution: joachim commentedOh cool!
I doubt this would get into 7... though I would contend that depending on comment is *kinda* a bug, given that the module describes itself as:
description = Enables tracking of recent content for users.
;)
Comment #19
joachim CreditAttribution: joachim commentedOops, not sure I meant to change the status!
Comment #20
dave reidPlease try re-uploading the patch. Not sure why it's getting ignored for testing...
EDIT: nevermind, my comment triggered it
Comment #22
robloachAdding the Platform Initiative tag as this helps decouple some of our sub-systems.
Comment #23
tsvenson CreditAttribution: tsvenson commentedWouldn't mind to see this as part of http://drupal.org/community-initiatives/drupal-core/clean-up. Especially with patch in the works it shouldn't be to much effort to bring this useful improvement into core.
Comment #24
robloachRe-roll? Like tsvenson mentioned, I'm moving this to the Framework Initiative, as it involves resolving our dependency system.
Comment #25
robloachComment #27
amateescu CreditAttribution: amateescu commentedRe-rolled again, with passing tests this time. The patch looks good to me but will let someone else to rtbc.
Edit: Improvements to this patch can be done in a sub-branch of http://drupalcode.org/sandbox/sun/1255586.git/shortlog/refs/heads/platfo...
Comment #29
amateescu CreditAttribution: amateescu commentedHeh, that was silly :) We might not need Comment anymore but we still need Node.
Comment #30
tomkelly CreditAttribution: tomkelly commentedI added issue summary
Comment #31
robloach#29: 366511-29.patch queued for re-testing.
Comment #32
sun#29: 366511-29.patch queued for re-testing.
Comment #34
mitchell CreditAttribution: mitchell commentedAlternatively, we could #1261120: Deprecate Tracker module in D10 and move to contrib in D11.
Comment #34.0
mitchell CreditAttribution: mitchell commentedadded issue summary
Comment #35
andypostAt least we should add dependency on node, because comment no more coupled to node
Also listings probably would be replaced with views #1941830: Convert tracker listings to a view
Comment #36
andypostComment #37
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #38
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #39
andypostComment #41
vprocessor CreditAttribution: vprocessor at Skilld commentedComment #42
vprocessor CreditAttribution: vprocessor at Skilld commentedComment #43
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #44
joachim CreditAttribution: joachim commentedI don't understand this bit of the summary at all:
> Tracker requires an additional comment. By default two comments are added for every entry. Would like to remove the second comment entry.
Comment #45
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedRemoved comment dependencies from tracker .
Comment #46
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #48
hitesh-jain CreditAttribution: hitesh-jain at Acquia commented#45:decouple_comment_module-366511-45.patch queued for re-testing.
Comment #49
hitesh-jain CreditAttribution: hitesh-jain at Acquia commentedComment #51
manuel garcia CreditAttribution: manuel garcia at Appnovation commentedlets use short array syntax
lets use short array syntax
lets use short array syntax
Comment #52
duaelfrIs this patch really blocked for monthes just because of the array syntax?
Comment #54
duaelfrIt looks like a random failure. Retesting.
Comment #55
joachim CreditAttribution: joachim commentedEnabling Tracker without Comment crashes with this:
Comment #56
duaelfrThat's really strange it does not get triggered by a drush install nor the testbot...
That's fixed anyway.
Comment #57
andypostLooks like should work but makes complicated #1941830: Convert tracker listings to a view
Comment #58
alexpottAll the tests in the tracker module install comment so atm there's no test coverage. I expect that we need additional test coverage to ensure everything makes sense as comment is both installed on an existing site and also uninstalled.
Comment #60
duaelfrThis is just a reroll on 8.4.x to start working on tests if someone is tempted
Comment #61
duaelfrWrong tag, sorry
Comment #62
andypostAdded tests
Comment #63
andypostand second route - user's tracker
Comment #66
duaelfrThe latest patch looks good to me, still fixes the issue and add tests asked by @alexpott in #58
Congratulations!
Comment #67
alexpottAs far as I can see there's no test coverage of running cron or doing the calculation when comment is not installed.
Comment #68
pepegarciag CreditAttribution: pepegarciag at La Drupalera by Emergya commentedJust a little change to a if condition to meet coding standards.
Comment #69
duaelfrI cloned
\Drupal\tracker\Tests\TrackerTest
to make this new test by removing all comment related stuff. That's the best idea I had so I hope it's gonna be good. :/Comment #71
duaelfrTests are passing.
Comment #72
andypostLooks it covers lots more, should go now
Comment #73
alexpottThere is tonnes of duplication between TrackerWithoutCommentTest and TrackerTest. I think a few things.
1. This test should be called TrackerTest
2. The existing test should be renamed TrackerCommentTest
3. It would be great to reduce duplication. Maybe TrackerCommentTest cound extend TrackerTest and the tests be slightly refactored.
Comment #74
duaelfrLet's try a new patch.
I have a failure locally but as I cannot explain it nor reproduce it, I'll let the testbot judge.
*crossing fingers*
Comment #77
duaelfrReduced code duplication and fixed test fail.
Comment #80
duaelfrThis one is the good one! #confidence
Comment #82
naveenvalechaThanks for the huge efforts @DuaelFr
I don't see any strong requirement of adding new WTB here. I'm working on another issue where I'm converting last one WTB tracker test to BTB. If this issue will add one more WTB we'll again need the efforts to convert it to BTB. So here is the patch which converted the WTB to BTB. If you have any strong reasons of using WTB please specify.
//Naveen
Comment #83
duaelfrHi @naveenvalecha!
Thanks for your review. I'm sorry but the test you changed wasn't supposed to exist anymore. I merged it into TrackerTest as asked in #73 but, I suppose I forgot to remove it from the codebase :/
Comment #85
naveenvalecha#83,
Nice
Failures are expected.back to N/R
Comment #86
andypostCommiter's feedback #73 addressed
Comment #87
andypostTested locally and it works
Comment #90
andypostComment #91
duaelfrRerolled after #2863318: Cache: Convert system functional tests to phpunit has been commited.
Let's hope testbot is happy again then move it back to RTBC and hope it can be commited inside the 8.4 alpha
Comment #93
duaelfrTestbot is happy
Back to RTBC :)
Comment #94
catchWhy are some hunks checking if comment module exists and others if the service exists?
Also this seems incompatible with #1941830: Convert tracker listings to a view.
I'm struggling a bit to see what's useful in tracker module when comment module isn't installed, that wouldn't be handled simply by creating views at this point.
Comment #95
andypostVery interesting point @catch!
the Tracker is not maintainable
- it carry
tracker_user
&tracker_node
tables (easy to convert to field)- adds listings per user/node (mostly converted to views)
- use dirty hacks to access comment statistics and use them in listings
Makes sense to raise it in #2905741: *DRAFT* Proposed product goals for Drupal 8.5/8.6(+) core
Comment #96
duaelfr@catch @andypost Is there something I can do to move this forward?
Comment #97
andypost@DuaelFr I really no idea because tracker looks like used only to track commenting on nodes + history module
Maybe we need to open #1255674: [meta] Make core maintainable to decide about unmaintainable tracker module #1261120: Deprecate Tracker module in D10 and move to contrib in D11
Comment #98
joachim CreditAttribution: joachim commentedTracker is useful for allowing users to find content they have created -- that's why I created the Trackerlite module for sites that didn't have Comment installed.
Comment #105
andypostComment #106
anushrikumari CreditAttribution: anushrikumari at OpenSense Labs commentedRe-rolled patch #91 for 9.4.x-dev.
Comment #107
immaculatexavier CreditAttribution: immaculatexavier as a volunteer and at Material for Drupal India Association commentedRe-rolled patch against #106 with interdiff
Comment #109
immaculatexavier CreditAttribution: immaculatexavier as a volunteer and at Material for Drupal India Association commentedUpdated patch against #107 with interdiff
Comment #110
immaculatexavier CreditAttribution: immaculatexavier as a volunteer and at Material for Drupal India Association commentedUpdated patch against #109 with interdiff
Comment #113
andypostFix missing access call on entity query
Comment #115
smustgrave CreditAttribution: smustgrave at Mobomo commentedWill this be easier or harder if https://www.drupal.org/project/drupal/issues/1941830#comment-14634573 is completed? And since it's being removed in D10 is it worth it?
Comment #116
berdirTracker is not being removed from D10: https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsolete. That would be impossible without this issue being resolved first. If comment depends on it, we can't remove tracker.
Comment #117
andypostComment #118
smustgrave CreditAttribution: smustgrave at Mobomo commented@berdir don't follow. This ticket (if I follow) is trying to get comment out of the tracker module. But don't think the comment module needs tracker.
Comment #119
berdirSorry, misread the issue.
That doesn't change that tracker is AFAIK not being removed from D10. it's still there right now and also not mentioned in this week's D10 meeting about to-be-removed modules?
Comment #120
smustgrave CreditAttribution: smustgrave at Mobomo commentedSo I see it's listed as a recommended removal https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsol.... if that's the case should effort be made into this or https://www.drupal.org/project/drupal/issues/1941830#comment-14634573
Comment #121
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedTrying to fix failed tests of patch #113. Removed needs reroll tag as it's not needed anymore.
Comment #122
joachim CreditAttribution: joachim commentedNitpick:
Use $this->container->get() to get a service in tests.
Also, $service isn't a very good variable name! You can just chain it here, as we don't call the uninstaller again.
Comment #123
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedMade changes as per comment #122.
Comment #124
smustgrave CreditAttribution: smustgrave at Mobomo commentedFixed build issue
Comment #126
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems the trackerController is broken when comment is uninstalled. Added some checks.
Comment #127
joachim CreditAttribution: joachim commentedOptional function params should go at the end.
We can rearrange the method signature, because route controllers are considered internal in the BC policy:
> Core modules contain many route controllers that are bound to individual routes, as well as form classes. These controllers are not part of the API of the module unless specifically marked with an @api tag on the method or class.
Also, I wonder whether it would be over-engineering to provide TWO controller classes for this route, and a Route Provider service which decides which controller to use based on whether comment module is present.
Comment #128
asad_ahmed CreditAttribution: asad_ahmed at OpenSense Labs commentedPatch #126 cant apply. so rerolled the patch.Thanks
Comment #129
nivethasubramaniyan CreditAttribution: nivethasubramaniyan as a volunteer and at Material for Drupal India Association commentedFixing Coding Standards
Comment #130
smustgrave CreditAttribution: smustgrave at Mobomo commentedRemoving credit for #128 and #129. Patch#126 applied to 10.1.x just fine so the followup was not needed.
Addressed the ordering from #127
Comment #131
quietone CreditAttribution: quietone at PreviousNext commentedThis extension is deprecated and scheduled for removal in Drupal 11.
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.
Comment #133
andypostin contrib now, look it already decoupled enough in 10.3 core
Comment #134
andypost