Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
forum.module
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
28 Nov 2012 at 17:33 UTC
Updated:
5 Dec 2014 at 03:44 UTC
Jump to comment: Most recent, Most recent file





Comments
Comment #1
xjmThanks @bjlewis2!
So probably these messages should simply not be displayed inside the actions link markup. We can't backport anything here because it would be a UI change, but the only real oddities are in D8 in any case.
This might also have been affected by #1167350: Action links were ignored .
Comment #2
droplet commentedI've attached a patch to #1167350: Action links were ignored , it will fix this problem
Comment #3
sunUnpostponing, since the markup being output here seems to be improper usage of action links.
We probably need to move those "messages"/notices into the page markup.
Comment #4
Anonymous (not verified) commentedI picked this up from http://core.drupalofficehours.org/task/1238 and have made a first attempt. This simply moves the access checking into the template. I have no idea if this is the best/correct/etc. way of doing it so welcome reviews!
Comment #5
droplet commentedAction links broken the UI pattern because it's called "Action link" only. I still think display the text is needed in this case.
Patch seems need more better access handle.
Comment #6
Anonymous (not verified) commentedHere's another version which turns the "Log in" into an action (and fixes the link code) so only moves the not authorised message to the template.
Comment #7
Anonymous (not verified) commented@xjm in core office hours recommended I post screenshots and code snippets, so here we go. This is for the patch in #6 which is a more sensible patch than #4:
Anonymous, no access
Authenticated, no access
Posting this makes me realise there's no markup on the error message, however I'm presuming all this still needs changing to twig at some point?
Comment #8
carsonblack commentedI applied the patch in #6, created the Test user and tested as anonymous as well as logged in as the Test user and the results were the same as indicated in #7.
Comment #9
carsonblack commentedNote: Applying this patch causes the patch in http://drupal.org/node/953214#comment-6693922 to not apply.
Comment #10
Anonymous (not verified) commentedI've taken a first go at merging patches #1853072-6: Remove forum_menu_local_tasks_alter() hack and instead add links in ForumController::build and #953214-50: 'Login to post new content in the forum' button assumes auth users have permission to post. I've attached an interdiff file but first time created one so not sure if it worked ok.
If authenticated user has access to post new forum content and visitors can register on the site the action button now redirects to /user and looks like this:

...and if Administrator only registrations then it redirects to /user/login and looks like this:

The buttons are still somewhat confusing as you could have comments on forum topics where you can post, this just checks for posting of topics.
Comment #12
sunThe result of the discussion in #1167350: Action links were ignored was that Forum module should not use
hook_menu_local_tasks_alter()to expose/show these links in the first place, because these are not action links.So what we want to do here is to move that code to an entirely different spot, but essentially try to retain the approximate position.
The most simple approach would be to move the code into an own helper function (i.e., renaming the current hook implementation function), make it accept a
$buildrender array, and make it add a container that contains the respective link or markup, depending on the configuration settings, and apply a very low negative weight to the container. (i.e., essentially doing what the current action links are doing, just without action links.)Then, inject calls to this helper method from every forum page callback that needs it.
That would be the most simple way. However, I want to amend that this messaging is not really part of the actual page callback content (which is probably more or less the reason for why it has been moved into
hook_menu_local_tasks_alter()).Therefore, an alternative approach would be to turn this container into a real and new block, which just outputs the necessary link/content, and make
forum_install()enable and position that block into the 'content' region with a low weight. As a result, site builders and themers will be able to move this messaging block very easily to a different place/region (e.g., into a sidebar).Overall, the block approach would make more sense to me.
Comment #13
Anonymous (not verified) commented@sun thanks for the info, I've had a go at moving it into a block, patch attached with code from #953214-50: 'Login to post new content in the forum' button assumes auth users have permission to post as it uses a function
Block as it appears in block admin after installing forum module:
Block content when not logged in and auth user does not have permission to post:
Block content when not logged in, auth user can post, admin-only registration:
Block content when not logged in, auth user can post, visitors can register:
Block content when have permission to post:
Block content when have permission to post, with redirect to forum being viewed:
Block content when logged in and no permission to post:
Comment #14
Anonymous (not verified) commentedFixing white space issues in patch and status change to needs review
Comment #16
Anonymous (not verified) commentedHad introduced dependency on block module which also affected other tests. Re-trying.
Comment #17
Anonymous (not verified) commentedMissed a file. I'll get the grip of this soon, many appo logies ;)
Comment #18
Anonymous (not verified) commentedSo *that's* why I see those "Fixing new line issue" posts.
Comment #19
larowlanNot sure I like the block approach, not sure why though.
I think it has to do with making block a dependency for forum, but I can't put my finger on it.
Comment #20
Anonymous (not verified) commentedI totally agree, I was just following orders ;)
Do you have any alternative suggestions? I know what mine would be, but guess we'd better keep forum for the moment :D
Comment #21
larowlanWell, my longer term goal would be a header area in a view, but we need some other things resolved before we can do that eg #1867642: Expose forum tables to views.
But I am struggling to come up with something that doesn't feel wrong, after re-reading sun's comments I guess block is the way to go, given most other content is moving to a block (eg site name etc).
Comment #22
Anonymous (not verified) commentedMe too which is why I just did the patch, sounds like best idea is to leave it for a while to see how other things develop. If you want me to look at anything in particular feel free to use my contact form or mail steve@purkiss.com and I'll take a look, quite enjoyed getting my teeth into this even though it did give me a little bit of a shock when I realised it broke lots of tests due to the block dependency - all good learning though!
Comment #23
Anonymous (not verified) commentedSomeone just mentioned on twitter to me that forums should be entities - done a bit of searching but didn't find anything - is this in the planning at all? Would it be worth creating a new issue? Saw it discussed on Advanced Forum but not for Forum.
Comment #24
sun@stevepurkiss: Forum containers + forums are taxonomy vocabularies, forum posts are nodes. Both vocabularies and nodes are entities in D8, so that's done already. However, that's off-topic here. :)
Comment #25
Anonymous (not verified) commented@sun ok cool thanks - just trying to get my head around future developments as it seems (I may be wrong) that I did a lot of work that won't actually be used, so just want to make sure I spend my "spare" time wisely!
thanks,
Comment #26
chintan.vyas commented#6: forum-move-access-error-into-template-1853072-6.patch queued for re-testing.
Comment #27
chintan.vyas commented#18: forum_access_messages-1853072-18.patch queued for re-testing.
Comment #29
mgiffordYup, this patch fails to apply in many, many ways right now. It will have to be re-built if the problem still exists.
Comment #29.0
mgiffordAdded images inline
Comment #30
mgiffordPretty much everything seems to have changed since the last roll a year ago in #18.
Comment #31
larowlanThis blocks #2347465: Convert all instances of #type link/links to convert to use routes - over there they're just going to remove the hook and uncomment the tests - so we need to reinstate that functionality here.
Bumping accordingly
Comment #32
larowlanComment #33
larowlanComment #34
mgiffordLogged in as the test user looking at the forum without ability to post it as per the description in the summary:
I think this is ready to go. Got it up and running here for the next 5 hrs http://sb1cc35baa618c1d.s3.simplytest.me/
The code looks good to me.
Comment #35
dawehnerCan someone explain why we cannot solve the bug as part of forum_menu_local_tasks_alter()?
Comment #36
dawehnerPlease try to not do this as part of the constructor?
Comment #37
mgiffordComment #38
larowlan35 because they're abusing it to show text in the header in the case if the unauthorized user, ie local action with no link.
36 that is in the factory
Comment #39
mgiffordComment #40
dawehnerWell, this is not about "the constructor" but about the construction of objects. Executing anything there opens potentially a lot of race conditions, circular dependencies, slow code paths etc.
Comment #41
larowlanCan you elaborate what you mean? This constructor signature makes it explicit what the dependencies are. The alternative is to inject the whole entity manager but that obscures the real dependencies and would mean we'd have to mock a load of methods on the entity manager if we ever wanted to add unit tests.
Comment #42
larowlanFwiw I've had several patches elsewhere that inject the entity manager knocked back in favor of this level of explicitness so assume there is no policy, instead its more of a reviewer preference thing?
Comment #43
dawehnerIt's okay here, not okay in services.
Comment #46
stefank commentedHere is rerolled patch from #32, as it doesn't apply anymore.
Comment #47
stefank commentedTriggering testbot.
Comment #49
larowlanre-roll
Comment #51
larowlanComment #52
tim.plunkettBase rebase?
Comment #53
larowlanre-rolled without that hunk
Comment #54
mgiffordLooks good to me. I went through and tested this patch in SimplyTest.me.
Screenshot still looks like #34.
Comment #55
alexpottThis looks like a testable bug.
Comment #56
tim.plunkettGrep for 1853072 in HEAD, you'll see that there IS test coverage, we just removed it temporarily.
This issue should restore that.
Comment #57
larowlanthanks @timplunkett - restored test
Comment #58
tim.plunkettComment #59
alexpottCan we get a followup to add a test for the anonymous case - i.e. to check that the anonymous user has a link to login.
This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed bfe4403 and pushed to 8.0.x. Thanks!
Comment #61
larowlanFollow up is #2379459: Add a test for forum action links for anon users