This logic is rather broken:
http://api.drupal.org/api/function/menu_edit_item_validate/7
why do we look for an alias before testing if the link is external? And if it is external, we should still split of the query and fragment to they are handled properly. Also, we are trying to get all querystrings to be stored as arrays not strings - and right now they may be wither, so the above function is possibly wrong for not converting it to an array, and this function is broken:
since it will not handle a link with a query string that is an array (which we now expect)
http://api.drupal.org/api/function/menu_edit_item/7
Comments
Comment #1
pwolanin commentedThis PHP function may be useful for breaking the query string up http://www.php.net/manual/en/function.parse-str.php
Comment #2
bcn commentedHere's a start. We now have drupal_parse_url to use.
Comment #3
sunPatch looks good, but it seems we need tests here. :-/
Comment #4
pwolanin commentedPatch is not complete in terms of the problems, it's just a start.
Comment #5
sun1) Why should we store 'query' and 'fragment' in 'options' for external links? External links are external links. url() handles them properly, and in an edge-case scenario, a hook_menu_link_alter() implementation may want to store a query or fragment to extend/override the values in the external link (handled by url()). For external links, we're missing only the else condition, which should set
['options']['external'] => TRUE;2) Hence, we only need to parse the link in case it's not external. When it's not external, then we need 'query' and 'fragment' splitted up. drupal_parse_url() already does this.
3) Only for internal links we want to search for a system path.
4) menu_edit_item() needs to be updated to implode() 'query':
Comment #6
pwolanin commented@sun - if we set options['external'] here url() will not check for bad protocols
Also, your arguments about altering an extrernal link suggest exactly that we need to store the query and fragment in the options array - however, I'm willing to leave that part of the flow as-is (i.e. don't parse external links).
Comment #7
bcn commentedHow about this...
Comment #8
sunThis should use drupal_http_build_query().
I'm on crack. Are you, too?
Comment #9
bcn commentedEdited... Wrong patch.
Comment #10
bcn commentedHere's an update to use drupal_http_build_query()...
Needs works b/c there are still no tests.
Comment #11
sun.core commented@pwolanin: Any update on this? Not sure what you meant earlier by "incomplete"...
This doesn't seem to touch any critical functionality.