Bug #1:
In Drupal 6 the "Add new forum topic" link appears both on the main forums page and on all forum pages. In Drupal 7 this does not appear on a forum page, just the main forums page. I did a search of the forum module issue queue, but couldn't find an existing issue (and then a drupal.org wide search) so if this is a duplicate please mark as such.
Test by going to forum/ and then forum/1.
The reason is that we're doing a string equality comparison $router_item == 'forum'
. This can be changed to substr($router_item, 0, 5) == 'forum'
.
Bug #2:
When I did this I exposed a bug a couple of lines down because the conditional in $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0] : 0);
would also fail anyway. $router_item['page_arguments'][0]
can be an object when viewing a forum page.
Let's see if this patch passes all tests? I'm not sure what else $router_item['page_arguments'][0] can show up as for forum router items (just an associative array? just an integer?) so this patch might not fix the bug completely.
Comment | File | Size | Author |
---|---|---|---|
#34 | 786620-forum-add-d7_2.patch | 3.06 KB | mradcliffe |
#27 | 786620-forum-add-d7.patch | 3.26 KB | andypost |
#15 | 786620-forum-add-d7.patch | 3.28 KB | andypost |
#12 | 786620-forum-add-d7.patch | 3.3 KB | andypost |
#10 | forums-page.PNG | 19.79 KB | andypost |
Comments
Comment #1
joachim CreditAttribution: joachim commentedI'm afraid I haven't time to review this right now, but want to say in passing that this is rather similar to #784842: shouldn't the "post new blog entry" link have 'action-links' class?.
Comment #2
joachim CreditAttribution: joachim commentedI've applied the patch and it fixes the bug.
RTBC :)
Comment #3
webchickWow, nice sleuthing! :D
- substr() always kinda weirds me out a bit. I can see that you wouldn't be able to use something like arg(0) here because this alter hook is only checked during "compile time", and I don't particularly have any better ideas, but could you check if there is anything in either &$data or $router_item that we could potentially re-use directly instead?
- I hemmed and hawed a bit about whether or not this should have a test, since you found not one but *two* bugs. Please check forum.test and see if it's easy to add a quick two-ish line test that clicks the link on forum/1 and verifies a node form exists. "In theory" this should be pretty simple, and would ensure we don't ever break this functionality again in the future.
Comment #4
joachim CreditAttribution: joachim commentedThere's actually a bug #3 too, but it's to do with FieldAPI so I've filed it separately: #787654: deleting a bundle doesn't remove it from the $field data.
And #4: anon users are invited to log in even if once logged in they still won't be able to post content. But that's separate to what we're fixing here: #788320: anon user is invited to log in to post in the forum, even if that won't allow them to.
- substr: it looks like we can check $root_path is either 'forum' or 'forum/%'. But #788310: hook_menu_local_tasks_alter() doc is missing 2 parameters.
- tests: not sure I've put them in the best place in forum.test, as there are quite a few things in there I don't quite follow. eg viewForumTopics -- does drupalGet automatically do an assertion? It does say DIE DIE on it though ;)
At any rate, I've added two tests and they pass with the patch.
Comment #5
mradcliffeThe only other place I can think to put the test is under verifyForumView function. This specifically only tests within forums and containers, and not the main forum page. It also is only called for authenticated users.
Comment #6
andypost#4: 786620.drupal.forum-action-links-subpages.4.patch queued for re-testing.
Comment #8
andypostTest is wrong, suppose there should be test for /forum/X page and checking is there links.
Also when user visits container page - link to point to a first forum inside, not to /node/add/forum/{container term}
PS I'm working on #12089: Better method of showing forum containers in form so propose do not point user to a page where he could get a confusing error message about "choose forum, nnot container"
Comment #9
andypostAlso this is a major priority because lacking of link "Add new forum topic" is very bad regression in usability of our ugly forum
Comment #10
andypostCurrent screens
Comment #11
Bojhan CreditAttribution: Bojhan commentedLooks good, fix the tests and this is committable. For those reviewing, remember blog post is just an example not like that by default
Comment #12
andypostAlso this links should not be visible for container pages (http://api.drupal.org/api/function/forum_page/7)
Also http://api.drupal.org/api/function/forum_form_alter/7 should be fixed
Current patch
- Hides context links from /forum
- Displays them at /forum/%
I think we should hide this links when we visiting a forum container but this require fixes in tests.
While we are using interaction of Context Links so no links should be displayed on pages where no ability to add node
Also #12089: Better method of showing forum containers in form this should help to predict errors
Comment #13
andypostIs this a good idea to hide links for pages which lead to error submissions?
Comment #15
andypostLet's search link by it's title
Comment #16
andypostEverything works, but we should decide on breadcrumbs (what should they show) for nodes that is not 'forum topic'
related
#599016: Only allow nodes to be posted to forums
#787652: Forum vocabulary alterations possibly obsolete -- possible to delete forum vocab
Comment #19
ericy CreditAttribution: ericy commentedadd-new-topic-on-forum.patch queued for re-testing.
Comment #20
ericy CreditAttribution: ericy commentedComment #21
ericy CreditAttribution: ericy commentedPatch code was reviewed, the change should be fine, also it passed the test, so it's ok for community review and test.
Comment #22
ericy CreditAttribution: ericy commentedComment #23
joachim CreditAttribution: joachim commented(disclaimer: sleep deprived!)
Patch applies and works as described in #12.
Comment #24
meba CreditAttribution: meba commentedThis looks good.
Comment #25
Gurpartap Singh CreditAttribution: Gurpartap Singh commented#15: 786620-forum-add-d7.patch queued for re-testing.
Comment #26
webchickThat really needs to be broken out. The original code is easy to follow, I have *absolutely* no idea what this new stuff is doing.
Or at the very least, we need a comment here to explain wtf is going on. :P
Powered by Dreditor.
Comment #27
andypostChanged comment and code to exclude containers.
Summary:
1) Currently local tasks (links to "add content to forum") are displayed only on /forum and not at internal pages
Proposed change
2) Links should be displayed only within forums pages "forum/%"
3) Forum containers could not contain topics so on their pages links are hidden - this behavior could change after #12089: Better method of showing forum containers in form
Comment #28
andypostRelated #895774: Forum field should not rely on vocabulary machine name
Comment #29
james.elliott CreditAttribution: james.elliott commentedI have a question about the patch. Should I expect to only see the "Add new Forum topic" link while viewing a forum? Not on the forum list, /forum?
http://skitch.com/jameselliott/diyhr/forums-d7-test
If that is expected, then I would say this should be RTBC
Comment #30
andypost@james.elliott Links ("Add new Forum topic") should be visible ONLY on internals pages - forum/%, because user can't add topics into containers and /forum forum list
Comment #31
james.elliott CreditAttribution: james.elliott commentedMakes sense from a UX perspective to me. RTBC it is.
Comment #32
webchickThis is definitely a bug that needs to get fixed, but not at the expense of removing "Post new forum topic" from the main forum listing. That's a UI change 9 months after UI freeze that has nothing to do with fixing a bug. Please remove that portion of the patch.
Comment #33
MichelleI just wanted to make a quick comment re #32. It always seemed logical to me to not put this link anywhere but on the actual forum listings. After all, anywhere else forced a user to choose a forum from the dropdown which seemed like a horrible UI. I even took it out of there in AF.
But I've found on my site that the number of topics added by other people is higher now that I've put the link back on the top level. It still doesn't make sense to me but people do use that link even on the main forum listing. So taking it out is something that needs some serious discussion and, as webchick said, not this late in the game.
Michelle
Comment #34
mradcliffeI rolled back the patch so Add New Forum Topic is on the forum/ page, and adjusted the test appropriately.
Comment #35
reglogge CreditAttribution: reglogge commentedThis now works as advertised. "Add new Forum topic" is now visible on both /forum and /forum/*
Comment #36
webchickGreat! I just made one small adjustment -- removing the leading slash on the various drupalGet() calls -- and committed to HEAD.
Thanks for cleaning up this long-standing bug!