Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
shortcut.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 May 2010 at 00:55 UTC
Updated:
27 Jan 2017 at 17:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jbrown commentedComment #2
David_Rothstein commentedAwesome! Yeah, this idea came up in passing in a couple other issues, but no one actually tried to write a patch. Thanks for starting this.
A couple comments:
Also, one more thing - not an actual problem with the patch, but more of a bonus thing that would be neat to have (could also be a followup issue)... I think that if you delete a shortcut by clicking the '-' icon and immediately "undo" it by adding it back with the '+' icon on the next page load, it should restore itself to the same place in the shortcut list that it was before (currently it will be added back at the end of the list instead). This could be done pretty simply by allowing shortcut_link_add_inline() to pull an optional 'weight' parameter from the URL, and potentially passing that along in the session or via other means for that one page load.
Comment #3
jbrown commentedGreat ideas!
I had a fever last night and couldn't sleep so I created the patch - hence the security vulnerability.
Comment #4
swentel commentedAs suggested by David:
- added token to prevent CSRF vulnaribility
- uses new callback.
The restory/undo functionality could be for another issue imo.
Comment #5
Bojhan commentedGonna RTBC it, I tested it and it worked.
Comment #6
Bojhan commentedComment #7
webchickMoving to 8.x, but this sounds like something we could probably backport. Tagging.
I'd love an extra set of eyes on that CSRF protection code and ensure that it's copasetic.
Comment #8
David_Rothstein commentedI reviewed the patch, and the CSRF protection code looks as copasetic as can be :) Basically, it's just standard use of drupal_valid_token() (and the same exact pattern used in the equivalent function for adding a shortcut).
However, it looks like there are two other problems:
Comment #9
swentel commentedAddressed the two points in a new patch, setting to review again.
Comment #10
valthebaldPatch from #9 worked fine for me, both in 8.x and 7.x installations
Test steps:
git clone --branch 8.x http://git.drupal.org/project/drupal.git d8git clone --branch 7.x http://git.drupal.org/project/drupal.git d7patch -p1 < ~/tmp/791072-9.patchComment #11
valthebaldPatch from #9 worked fine for me, both in 8.x and 7.x installations
Comment #12
xjmMinor thing but there's a missing newline here.
Otherwise, it appears the changes David asked for in #8 have been made, and the patch has been tested functionally in #10.
Comment #13
swentel commentedThere is no single newline in any file in core, so this one is good to go.
Comment #14
David_Rothstein commentedHere's a version without the newline thing (note the issue is missing newline characters, not actual newlines, I think - those can mess up future patches).
I reviewed also and agree it's RTBC.
Comment #15
sunVariable name should be $link, and the loader is actually menu_link_load(), not item.
Should return MENU_ACCESS_DENIED instead.
Why is this a separate menu router item, and why does it break the hierarchical structure?
20 days to next Drupal core point release.
Comment #16
gregglesThe csrf protection in the most recent patch (and at least several of the others) is appropriate. Removing the "needs security review" tag.
Comment #17
swentel commentedUdated the patch per sun's remarks.
Also changed the drupal_access_denied() to the same constant in shortcut_link_add_inline().
As for the separate menu router item and structure. Well it follows the add-link-inline menu item. When adding a link, we need to know the current shortcut set, when deleting we only need to know the mlid. Granted, this could all be in one single page callback, but that would be messy code in my opinion.
Comment #18
xjm#17 looks good to me overall. Can we add tests for this?
Outside of that, a couple comment nitpicks:
The first line should be:
Page callback: Deletes a link from a shortcut set.Also, I'd say "redirects the user to the original page" rather than "where they came from"--the latter is a bit odd.
Comment #19
kscheirer#17: 791072-17.patch queued for re-testing.
Comment #20
kscheirerRetesting against latest HEAD since it has been over a year.
Comment #22
valthebald@xjm: I am not sure what test can check here
Comment #23
lz1irq commentedThis test probably doesn't work at all but it was all I could throw together for GCI 2013. Probably best to ignore it.
Comment #24
wim leersThis would be a very nice UX improvement :)
Comment #25
Danny.Wouters commentedI am going to try to look at this problem.
Comment #26
Danny.Wouters commentedThe confirmation screen is no longer shown when using the delete quicklink.
Instead of using a new test it was also possible to slightly change the test testShortcutQuickLink.
The delete confiirmation form remains unchanged when triggered by the operation link in the manage form.
Comment #27
wim leersWhy not just do
$shortcut->delete()?Other than that, this looks good to go :)
Comment #28
Danny.Wouters commentedThanks for the review.
The function now uses $shortcut->delete()
Comment #29
wim leersLovely, thank you! :)
This is now good to go.
P.S.: you even hid the previous patch — awesome, you're getting up to speed in best practices super fast! :D
Comment #30
xano@throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpExceptionThe method does not actually throw any exceptions, and any exceptions thrown by the storage controller are caught.
Also, are the links and buttons to the delete page now marked with a
danger? We should make sure it's clear clicking those results in a destructive action straight away.Comment #31
wim leersGood catch!
@Danny.Wouters: could you remove that one line? :)
Please actually try the patch. This is for the inline "delete shortcut" link, i.e. when you click the star icon.
Comment #32
Danny.Wouters commentedThanks for the review.
I removed the line and created a new patch.
Comment #33
wim leers#30.1 is fixed, back to RTBC.
Comment #34
alexpottWe need some tests - no?
The comment does not true?
Comment #35
Danny.Wouters commentedThe comment on the function is changed.
There are some tests in the function testShortcutQuicklink
Are these tests sufficient or do we need more tests?
Comment #36
mr.baileysThis line in the patch adapts the existing test and makes sure that a) the delete confirmation page is gone, and b) the shortcut link is still removed as it should be, so I think we have enough test coverage?
Leaving
Does it always redirect to front, or only if not 'destination' query parameter is set?
Comment #37
Danny.Wouters commented@mr.baileys: Indeed, the function redirects to the page where the user clicked on the quicklink (to delete the shortcut to that page).
Is there a function to verify what the destination parameter is?
Comment #38
Danny.Wouters commentedSome minor changes were made to re-roll the patch.
shortcut.module
$route_name = 'entity.shortcut.link_delete_inline';shortcut.routing.yml
entity.shortcut.link_delete_inlineThe comment in the function deleteShortcutLinkInline in ShortcutController.php is changed
Comment #39
Danny.Wouters commentedComment #40
jbrown commentedI don't think there is anything further to do here. After 4+ years let's get this committed.
Comment #41
wim leersWow! :D I didn't realize that!
Thanks for seeing this through, Danny.Wouters!
Comment #42
alexpottCommitted e023a68 and pushed to 8.0.x. Thanks!
Comment #44
Danny.Wouters commented