Problem/Motivation
The title says it.
This is part of #1823450: [Meta] Convert core listings to Views
From xjm's comment in #1823450-5: [Meta] Convert core listings to Views:
Would probably need forum data integration for {forum_index} to avoid potential performance regressions
Proposed resolution
Convert "Active forum topics" block to a View
Remaining tasks
- Rebuild the view or go back to the last working view and run the Drupal updates.
- fix extra long underline on "More" link
- Profiling | Contributor task document for profiling
User interface changes
Should be none.
Before (from #42)
After (from #68)
Note also from @webchick in #26:
this also "... actually fixes a bug with the old block where it lies to you about the existence of more forum topics"
Accessibility Improvements
- ?
API changes
None?
Comment | File | Size | Author |
---|---|---|---|
#186 | interdiff-2020387-176-184.txt | 25.63 KB | Bhanu951 |
#176 | 2020387-176.patch | 26.26 KB | snehalgaikwad |
#174 | 2020387-174.patch | 17.91 KB | snehalgaikwad |
#173 | Screenshot 2020-07-13 at 11.20.20 PM.png | 154.82 KB | samiullah |
#172 | 2020387-172.patch | 25.36 KB | Hardik_Patel_12 |
Issue fork drupal-2020387
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 #1
oadaeh CreditAttribution: oadaeh commentedForgot the tag.
Comment #2
Andi-D CreditAttribution: Andi-D commentedI am here in Dublin and i will make this issues
Comment #3
Andi-D CreditAttribution: Andi-D commentedI created a new view with two block displays:
New forum topics
Active forum topics
The view selects following fields:
I selecting the Nid because i need to rewrite the link target as views doesnt provide any automatic option to to this.
The patch also remove the old block files
And remove the following function:
Comment #5
Kars-T CreditAttribution: Kars-T commentedI changed the patch:
Comment #6
YesCT CreditAttribution: YesCT commentedhere is the interdiff. :)
Comment #7
YesCT CreditAttribution: YesCT commentedlet's do a before and after screenshot too.
Comment #9
dawehnerThanks for working on the patch.
So it seems to be that if the items per page override is in, this functionality is not part of the active forum topic view, so it should not be tested on here. That is fine to remove for now.
Comment #10
Andi-D CreditAttribution: Andi-D commentedCreate new version of the patch:
Comment #11
Andi-D CreditAttribution: Andi-D commentedHere the New Version after the patch
New Version off add active topic block, add new topic blocks looks the same
New Version off the new Blocks
Here the old Versions before the patch:
Old add active topic block
old add new topic block
old blocks
Comment #12
Andi-D CreditAttribution: Andi-D commentedComment #14
dawehnerWe can now override the items per page, let's get this issue up to speed again.
Comment #15
oadaeh CreditAttribution: oadaeh commentedUpdated patch.
I think the test is going to fail again, but I couldn't figure out where to look to fix it.
Comment #17
mr.baileysAssigning to myself to see if I can resolve the test failure during the DrupalCon Prague Code Sprint.
Comment #18
mr.baileysOk, after some troubleshooting, I found out that the tests fail simply because the views module is not included during test set up. However...
After adding the Views module as a required module for the test, the "Forum private node access" test fails on one of the next statements. This is caused by the fact that, since D8, when querying with the "node_access"-tag against a base table <> {node}, you need to explicitly define the base table using $query->addMetadata('base_table', 'forum_index') (See http://drpual.org/node/1885420 for a discussion)
Unfortunately, hook_views_data currently only allows you to specify the query tag, not the query metadata. I have opened a new issue for this #2099511: Change notice: Need support for adding metadata in hook_views_data()..
Attached is a patch that includes the patch for that issue to prove tests pass, but this issue is blocked by #2099511: Change notice: Need support for adding metadata in hook_views_data().. Setting to NR for the testbot.
Comment #20
mr.baileysViews yml file was missing in previous patch.
Comment #21
dawehnerThis was basically a straight rerole, so let's get it to RTBC
Comment #22
Xano21: vdc-2020387.patch queued for re-testing.
Comment #23
webchickSorry, I tried really hard to get to this one tonight but I am completely out of steam. :( But please check the in-depth review at #2020399-54: Convert "Who's online" block to a View because some of that might apply here, too.
Will try and bang this out tomorrow.
Comment #24
webchickSorry, cancel that. #2020399-58: Convert "Who's online" block to a View Patch still applies though, so hopefully one of the other core maintainers can get to it.
Comment #25
mr.baileysComment #26
webchickOk, dawehner and I subsequently hugged and made up, and now that #1957276: Let users set the block instance title for Views blocks in the Block UI is in, there's no reason not to go all out on block conversion patches anymore. YEAH.
I'd love for all of these block conversions to make it into the next alpha, so tagging.
This one is funny because in addition to removing a bunch of crappy custom code, it actually fixes a bug with the old block where it lies to you about the existence of more forum topics:
Committed and pushed to 8.x. Thanks!
Comment #27
tim.plunkettNot sure what broke this, but it hadn't been retested since mid-November.
git revert d166be3
Comment #28
alexpottReverted the earlier commit with 5aab968 and pushed to 8.x.
Comment #29
alexpottComment #30
alexpott21: vdc-2020387.patch queued for re-testing.
Comment #32
webchickUh oh. :( Sorry, folks! :(
Comment #33
webchickIn fairness, who would've guessed anyone did anything with Forum module in 2 weeks? :P~
Comment #34
mr.baileysAttached is an updated patch which resolves the test failures. However, as indicated in #18, this patch contains a hunk from #2099511: Change notice: Need support for adding metadata in hook_views_data()., so is blocked until that lands.
Comment #35
sunOne more reason for why HEAD was broken is most likely this:
→ The foreach lacks a block; the $count_query line only adds meta data for the last $key and $value of the loop.
Comment #36
dawehnerYeah I had the same kind of trouble while writing tests in the other issue.
Comment #37
moshe weitzman CreditAttribution: moshe weitzman commentedThe patches to date delete the caching that this block implements. We should enable time based results caching for this block for a short duration. I'd say 5-10min. No need for output caching.
Comment #38
ianthomas_ukThe issue this was postponed on has been committed.
Comment #39
mr.baileysNew patch
Comment #40
dawehnerI try to figure out why we don't use time based output caching,
beside from that this looks perfect!
Comment #41
moshe weitzman CreditAttribution: moshe weitzman commentedI suggested results based cache just to more closely mimic what we had before. I'd be fine with output cache as well.
Comment #42
larowlanThe more link in the views output doesn't contain a title attribute - can that be added or is that something views doesn't support? If not, I guess we can live without it, but it would be a worthwhile addition for other views too.
Less custom code++
More customisability++
Shedding the 'too specific to be of any use, too rigid to customise' tag that has burdened forum since forever.
Screenshots of title issue
before
after
Comment #43
dawehnerAh okay, I am fine with keeping that for now and think about more in a follow up.
Don't we kind of need it for accessibility as well?
Comment #44
larowlanWe either have
Or the title.
If we can do the markup above with views, then we're fine I think.
Comment #45
dawehnerAs said on IRC, it feels like an actual usecase for a template.
Comment #46
larowlanAdds some markup to help screen-readers.
If this approach is acceptable, I consider this RTBC
Screenshot of markup/output
Comment #48
larowlan46: forum-block.46.patch queued for re-testing.
Comment #50
larowlanschema tests++
Comment #52
larowlanand the other display
Comment #54
mgiffordThis looks like it will be an improvement for accessibility! Great job.
Comment #55
joelpittetI'd prefer if there was no markup in PHP. Though right now we don't have
filter_xss_admin
as a filter(easily added though). This to me looks like an opportunity to use twig blocks. http://twig.sensiolabs.org/doc/tags/block.html We haven't used them at all in core yet but this seems like a fit if we can get them to work. Duplicating views-view.html.twig is asking for trouble, that's why I suggest this. Also would need a suggestion hook potentially for the view id, if that doesn't already exist (thought d7 had these suggestions I don't know if they carried over).Comment #56
joelpittet@Cottser, I'll need you to help vet my crazy ideas:) Something to discuss at the weekly.
Comment #57
xjmComment #58
oadaeh CreditAttribution: oadaeh commentedHere's is a re-roll of @larowlan's patch, updated to the current state of core. I also removed the caching in the views, as that was causing my local tests to fail.
Comment #60
oadaeh CreditAttribution: oadaeh commented58: forum-block-2020387-58.patch queued for re-testing.
Comment #63
dawehnerFixed the failures.
Comment #64
joelpittetIf this goes green, can these blocks get names like
block_active_topics
,block_new_topics
. Similar question was asked previously #5.I'll gladdly roll it in if you don't mind @dawehner? Thanks for the fixes, nevertheless:)
Comment #65
dawehnerI won't do that because I hate abysmally to rename the generated machine names but people disagree with that.
Comment #66
joelpittet@dawehner that's understandable... then would you be in favour if I opened up an issue to have the view's blocks create better generated machine names?
Comment #67
dawehnerWell, I am not sure whether it is worth to fight here, not sure whether there is anyone else agreeing here.
Comment #68
joelpittetWe can see if it has any interest, otherwise nice work getting this green:)
#2269711: Generate views' display ids by their display_title.
Looks and great again :)
I'm assuming the tests removed from #5 are still fine and the ranges from 2-20 changed to 5, 10, 20, 40 are still cool with everybody.
Comment #69
larowlanWhat's the deal with the more link underline?
Comment #70
YesCT CreditAttribution: YesCT commentedput screenshots in the issue summary.
does this need profiling? or a follow-up for looking into that?
Comment #71
YesCT CreditAttribution: YesCT commentedComment #72
YesCT CreditAttribution: YesCT commentedlooking at the screenshots, seems a typo capitalizing Topics in "New forum Topics". fixed that.
Comment #73
dawehnerComment #74
YesCT CreditAttribution: YesCT commentedadding profile contributor task doc to the issue summary
https://drupal.org/contributor-tasks/profiling
Comment #75
joelpittetRe #69 seems that because the class of .more-link class is on the link itself and not the wrapping div of the link. Nice sport @larowlan
Also that may have some implications on this issue: #2031301: Replace theme_more_link() and replace with #type 'more_link'
I'm thinking that may need some CSS tweaks as I do prefer the one-less-div but I'll see if others agree?
Comment #76
mgifford@larowlan that's definitely something we missed when adding it here #890362: Links should not be indicated by color only
Comment #77
dawehnerBut well, this is not a problem which is related at all with the patch.
Comment #79
star-szrThis needs a reroll, maybe mostly for PSR-4? https://groups.drupal.org/node/424758
Comment #80
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedLooking at where this stands.
Comment #81
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedReroll with PSR-4. There is a remaining issue with the markup for the more link getting double escaped that I didn't quite have time to fix yet.
Comment #82
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedThis patch introduces a template override for the more link and goes back to using the title attribute. Is this an acceptable way or is there a better one? It's pretty similar to what's being done with the system module's branding block.
Comment #84
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedFixing the schema issue with slave being renamed to replica and adding the template that was missing from last patch.
Comment #85
dawehnerDecided to drop the need for the additional template and moved the function along. But this is just a small detail.
Comment #86
star-szrWhat about the profiling?
I don't think this is needed, the Attribute object is initialized in _theme() for attributes, content_attributes, title_attributes.
But maybe I'm missing something :)
Comment #87
star-szrReally like the use of addClass btw.
Comment #88
dawehner@Antti J. Salminen
Please feel free to fix the reviews. Just wanted to avoid explaining my idea and just implemented it.
Comment #91
Antti J. Salminen CreditAttribution: Antti J. Salminen commented@dawehner Thanks! I'll do that and try to take it forward from that.
Comment #92
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedOk, this should be working now. At least profiling still remains.
Comment #95
dawehnerso ....
Comment #96
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedThis should be a very straightforward reroll with no real changes, hopefully tests pass again after it.
Comment #97
dawehner@Cottser
Well, profiling would be obviously a little bit unfair, but let's see what happens.
Comment #98
star-szr@dawehner just saying that because it's tagged. I'm fine either way :)
Comment #99
dawehnerYeah I guess we cannot not do it.
Comment #100
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedHere's an attempt at profiling the "Active forum topics block". This is with 50 topics containing 9 comments each for a total of 500 posts. Current is 8.0.x. Done as described in the contributor task. Only change to default config was to enable the APC Classloader. I suppose the "New forum topics" block also needs to be tested.
Comment #101
dawehner@Antti J. Salminen
Just to be sure, did you checked that the caches are warmed like finding all the views plugins (just curious).
Comment #102
Antti J. Salminen CreditAttribution: Antti J. Salminen commented@dawehner
I believe they should be. To me the profiling that was done on the recent comments block looks somewhat similar (https://www.drupal.org/node/1938062#comment-7576867). I think most of the extra time is spent in rendering the view.
I put the diff available online in the xhprof UI:
http://xhprof.facingworlds.com/?sort=ct&run1=54233b929147b&run2=54233f7f...
Comment #103
Antti J. Salminen CreditAttribution: Antti J. Salminen commentedRerolling because one of the files this deletes changed.
Comment #105
larowlanComment #106
oadaeh CreditAttribution: oadaeh commentedComment #107
oadaeh CreditAttribution: oadaeh commentedA simple re-roll with only changes to account for Drupal updates.
Comment #108
oadaeh CreditAttribution: oadaeh commentedComment #109
oadaeh CreditAttribution: oadaeh commentedI found a bug in my previous patch.
This patch simply changes the content links from
'node/[nid]'
to'node/{{ nid }}'
.Comment #110
mgiffordSeems to apply fine. You can definitely see the Active Forum Topics in the list of views.
There's a slightly different display of the block /admin/structure/block before & after:
This may not matter, but wanted to point it out. What manual testing should we do before this is marked RTBC? I really don't use forums much.
Comment #113
oadaeh CreditAttribution: oadaeh as a volunteer commentedComment #114
mgiffordHave to address the missing views-more.html.twig #2036195: Remove views-more.html.twig and replace with #type link render arrays
Also have to look into why core/modules/forum/src/Plugin/Block/ForumBlockBase.php was rejected when applying the patch.
Comment #115
lokapujyaI think both of those files should be deleted.
Comment #117
xjmThis issue was marked as a beta target for the 8.0.x beta, but is not applicable as an 8.1.x beta target, so untagging.
This change is disruptive and so should be targeted for 8.2.x at this point.
Comment #118
lokapujyaComment #119
lokapujyareroll and re-export of the view.
Comment #121
lokapujyaAre these schema errors and unmet dependencies a problem with the view? Might need to be rebuilt or maybe go back to the last working one and run the Drupal updates.
Comment #128
jibranComment #130
lokapujyaComment #131
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #133
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch in #131 no longer applies.
Minor correction in schema.
Comment #135
jofitz CreditAttribution: jofitz at ComputerMinds commentedResolve many of the test failures.
Comment #137
jofitz CreditAttribution: jofitz at ComputerMinds commentedI think I've taken this as far as I can. Does someone else want to take over? Otherwise I'm happy to accept advice/guidance.
Comment #138
lokapujyaI recommend rebuilding the view.
Comment #142
geek-merlinComment #144
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedPatch created for 8.9.x-dev, Please review.
Comment #146
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedMore test fixes.
Comment #148
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedTest Fixes.
Comment #150
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedMore test fixes.
Comment #151
shaktikComment #152
shaktikhere is some failure test.
Comment #153
shaktikComment #154
shaktikComment #155
shaktikComment #157
shaktik#155 Patch working fine also test case pass see screenshot.
Comment #158
shaktikComment #160
shaktikComment #162
shaktikPatch in #155 no longer applies d9, so created a new patch to support d9.
Comment #164
shaktikMore test case fixes.
Comment #165
shaktikComment #167
martin107 CreditAttribution: martin107 as a volunteer commentedThese changes make 'view' a dependency of the forum module.
Comment #169
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedFixed More test, Please review.
Comment #170
martin107 CreditAttribution: martin107 as a volunteer commentedvsujeetkumar++
thanks for debugging that -- changes look good.
Comment #171
Rkumar CreditAttribution: Rkumar as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedPatch looks fine and now blocks are rendering through views.
Thanks for this contribution.
Comment #172
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedPatch #169 failed to apply , so re-rolling the patch. Kindly review a patch.
Comment #173
samiullah CreditAttribution: samiullah at Salsa Digital commented@hardik patel
I applie ur latest patch getting some hunks failed
refer screenshot
Comment #174
snehalgaikwad CreditAttribution: snehalgaikwad as a volunteer and at QED42 for Drupal India Association commentedComment #176
snehalgaikwad CreditAttribution: snehalgaikwad as a volunteer and at QED42 for Drupal India Association commentedComment #182
nod_D10 version needed
At this time we need a D10.1.x patch or MR for this issue.
Comment #183
nod_Comment #184
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedComment #186
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedRe-Rolled patch 2020387-176.patch to 10.1.x .
Comment #187
quietone CreditAttribution: quietone at PreviousNext commentedForum is approved for removal. See #1898812: [policy] Deprecate forum module 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 #189
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedShould we move this issue to Forum Module Queue as decision is finalised ?