Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Apr 2012 at 23:21 UTC
Updated:
29 Jul 2014 at 20:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
cwithout commentedComment #2
cwithout commentedChanging status.
Comment #3
gagarine commented#1: taxonomy-vocab-title-encode-1555294-1.patch queued for re-testing.
Comment #4
gagarine commentedPatch works for me. The property title is automatically escaped in hook_menu .
Comment #5
tim.plunkettThis needs to be rerolled for D8 first.
Comment #6
gagarine commentedSame patch for D8
Comment #7
underq commentedworks for me
Comment #8
tim.plunkettMakes sense, and matches the other title callbacks I've seen (user_page_title, node_page_title, menu_test_title_callback, filter_admin_format_title, menu_overview_title)
Comment #9
catchThanks. Committed/pushed to 8.x.
Comment #10
polI just tested the patch and it's working on D7. Thanks !
Here's the updated patch.
Comment #11
polComment #12
David_Rothstein commentedThis is a public function that could be called from other contexts, so for Drupal 7 it's probably not safe to change its behavior in this way.
I'd suggest backporting it via a method like #1363358-6: Shortcut set titles are double-escaped with check_plain() instead - and while doing so, feel free to review/RTBC that patch :)
Comment #13
polHi David,
What's the difference between your method and the one here ?
Thanks.
Comment #14
David_Rothstein commentedMy method does not change the output of an existing API(-ish) function; rather, it adds a new function.
Comment #15
polTrue true... but is there a way to verify that this function is used by a module ? Or we just can't change the API now ?
Is this patch better ?
Comment #16
tim.plunkettThere are docs at http://drupal.org/node/1354 about how to document hook_menu callbacks.
Or, you could just mimic #1363358-6: Shortcut set titles are double-escaped with check_plain() because it does it properly.
Also mimic the marking of the old function as deprecated.
Comment #17
David_Rothstein commentedRight, exactly. It's a public function and we don't know who is using it or how, so it's best not to change its behavior in a stable release.
The patch looks like the right idea; I don't think "taxonomy_admin_vocabulary_set_title" is the right function name though (since it's not really setting anything); how about just "taxonomy_vocabulary_title_callback"? I also think we should add a note to the old function saying it's deprecated, like I did in the other issue; you can feel free to borrow the text I wrote there, or tweak/improve it as necessary.
Comment #18
David_Rothstein commentedSorry, crosspost.
Comment #19
polThanks for your advices :-)
Patch updated !
Comment #20
David_Rothstein commentedLooks pretty good on a quick glance, except:
Too much copy-paste :)
Also, this got me thinking:
Frankly I think taxonomy_vocabulary_title_callback() is a better name, so it may make sense for Drupal 8 to just remove taxonomy_admin_vocabulary_title_callback() instead. We don't necessarily have to figure that out now except that it affects the code comments for the Drupal 7 patch... Perhaps that sentence isn't necessary and could just be removed anyway.
Comment #21
polUpdated patch.
Comment #22
cwithout commentedI made the original patch mimic #973328: Special characters are encoded twice in taxonomy term title, which is a similar issue. Why was it okay to change that callback function (taxonomy_term_title) which is used in exactly the same way as this one, but not okay to change this one, where the function seems much more specific than the one that was already changed? Should that one not have been changed?
Not saying it's wrong to do it that way, but this solution creates a more general "taxonomy_vocabulary_title_callback" from one that's specific to the admin page. If you're going to change the name of the callback to be general rather than specific to the admin page, for consistency sake, it would make most sense to simply call it "taxonomy_vocabulary_title" since it performs the same functionality as the title callback "taxonomy_term_title" but for the taxonomy vocabulary rather than term. That or change both function names to include "_callback".
Comment #23
damien tournoud commentedI disagree here, hooks, page callbacks, form callbacks, etc. are *not* API functions. Here we just have the case of a menu title callback (explicitly documented as such) that has been implemented incorrectly. I don't see the harm in changing its behavior.
If another module is using this function for what it is not (ie. using it as something different then a menu title callback), it's a bug in that other module.
Comment #24
dave reidI would argue the opposite. If it's not prefixed with '_' and it's in the .module file, it's a public API due to our nature.
As an alternative here, why not use this instead, which would be perfectly backportable to D7 rather than adding a new function:
Comment #25
David_Rothstein commentedHm, I would tend to think that other one was a mistake, yes. Although since it was committed only a couple weeks after Drupal 7.0 was released (when not that many people were actually using Drupal 7 yet on real sites), it was less of a risk than doing it now would be :)
Ah! That sounds like a very good idea.
Comment #26
tim.plunkettShame this isn't forwardportable, since entity_label is deprecated in D8.
Comment #27
David_Rothstein commentedAh, shoot, now I'm wondering... is it actually safe to change 'title arguments' like that?
If anyone is using hook_menu_alter() to swap in a different title callback, then this is going to result in a totally different set of parameters being passed to their function. Sorry for not thinking of that earlier.
Comment #28
tim.plunkettI don't know about you, but when I hook_menu_alter the arguments, I also explicitly duplicate the callback for that exact reason.
Comment #29
David_Rothstein commentedTrue, it's definitely best practice to alter both if you need to alter one.
Also, we're only talking about the title of an admin page here, so I guess it wouldn't be that big of a deal if it breaks for someone. I'm OK with going ahead with this approach.
Comment #30
gagarine commentedI agree the patch #26 is nice approach... but I you think changing taxonomy_admin_vocabulary_title_callback was a problem because it can possibly break some website this patch can do it to.
That say they will break website differently. In the first patch it can introduce XSS. This one will just break the admin... for me it's acceptable as their is a very small chance than it's append and the consequences are not that bad (compared to the unreadable title we have now).
Let's commit this!
Comment #31
dave reidThis is forward portable for D8. We have a valid use case here that I've already identified when we tried to completely remove entity_label() that we need title callback support. I think it's going to be renamed to entity_page_title() for title support.
Comment #32
tim.plunkett#1615240: Remove entity_label() in favor of EntityInterface::label() went in, so entity_page_label can be used in D8
Comment #33
polDo you think we can make it for 7.15 ?
Comment #34
webchickLet's fix this in D8 first with entity_page_label().
Comment #35
webchickAlso, tests?
Comment #36
tim.plunkettStill needs tests, but this removes taxonomy_admin_vocabulary_title_callback() (it will be marked deprecated in D7).
Comment #37
tim.plunkettHere's a patch with tests that reverts the commit to prove it fails, and the combined patch.
Comment #38
tim.plunkettRemoving tag.
Comment #39
marcingy commentedLooks good
Comment #40
catchYes this looks good. Committed/pushed to 8.x, moving to 7.x for backport.
Comment #41
oriol_e9gComment #43
oriol_e9gDefault value for site name :/
Comment #45
dcam commentedThe test failed because the behavior of 8.x when saving a new vocabulary is different from 7.x. 8.x takes you to admin/structure/taxonomy/%vocab_machine_name. 7.x takes you back to admin/structure/taxonomy.
I added a line to the test to go to admin/structure/taxonomy/%vocab_machine_name after creating the vocabulary in order to check the page title. The change caused the test to pass here on my local machine. We'll see what Testbot thinks.
Comment #46
dcam commentedBlah, changing status. That's the 3rd time today I've forgotten.
Comment #47
dcam commented#45: vocabulary-title-1555294-45.patch queued for re-testing.
Comment #48
oriol_e9gFix from D8
Comment #49
webchickThanks for the fix, and for the test! Committed and pushed to 7.x.
Comment #51
David_Rothstein commentedThis is tagged "Needs change notification" (for Drupal 8) but doesn't look like it ever got one? Could probably use something similar to the shortcut set one at http://drupal.org/node/1762604 ...
Also, I'm tagging this for the Drupal 7.17 release notes and adding it to CHANGELOG.txt.
Comment #52
dawehnerhttp://drupal.org/node/1838750
Comment #53
Anonymous (not verified) commentedI checked my copy of contrib and there are a few contrib modules (er, og's tests, private_taxonomy, etc) that use this function, so I took out the "probably" and just said that the function is mostly used by core.
I made a couple of small edits, but didn't change the sense of the change notice, so going to mark this as fixed.
Comment #54
Anonymous (not verified) commentedAnd reseting the other metadata.
Comment #56
xjmUntagging. Please remove the "Needs change notification" tag when the change notice task is complete.
Comment #57
xjmAIEEEEEEE