Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
26 Apr 2009 at 04:36 UTC
Updated:
23 May 2009 at 06:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
nevets commentedWhy not just have drupal_get_path_alias() handle a null path, using $_GET['q] if the path is null. Removes the need for yet another function.
Comment #2
mcrittenden commentedI think nevets' idea is a good one, just have to make sure it's documented extremely well so that knowledge of that functionality doesn't get lost in the haze.
Comment #3
akahn commentedWhat do people think of having drupal_get_path_alias() default to using the current path? The function signature could be something like
drupal_get_path_alias($path = $_GET['q'], $path_language = ''). (Or, assuming #431976: Add wrapper function for current url (i.e., $_GET['q']) gets committed,drupal_get_path_alias($path = current_path(), $path_language = '').)Comment #4
mcrittenden commentedakahn: so far, that's three of us in agreement. Caktux?
Comment #5
caktux commentedDefinitely +1 for that, simply using actual functions more logically. I don't think it would break anything and, well it would probably just mean patching drupal_get_path_alias with your current code and test..
Comment #6
caktux commentedComment #7
akahn commentedHere's a patch with the above ideas. Any feedback is appreciated.
Comment #9
mcrittenden commentedAkahn: Why not just set $path = $_GET['q'] in the function's param rather than setting to NULL and resetting? Am I missing something?
Comment #10
akahn commentedI think PHP does not allow using a variable as a default value for a parameter.
Comment #11
mcrittenden commentedOh, DUH! In that case, the only problem I see is that the first comment is multi-line and has more than one sentence. From http://drupal.org/node/1354
So I'd say fix the comment and reroll to match head and we're good to go.
Comment #12
akahn commentedThanks for the catch. The note about using the current page when there is no path argument is now in its own paragraph.
Comment #13
mcrittenden commentedBot likes it, and it looks good to me.
Comment #14
chx commentedThats good.
Comment #15
caktux commentedAwesome :D Thanks guys!
Comment #16
caktux commentedComment #17
webchickNice! :) Committed to HEAD.
The only adjustment I made was I switched "An optional internal Drupal path" back to "An internal Drupal path." Both the comment above and the = NULL implies that it's optional, IMO. I did leave the langcode the same as it was (with the word "optional") because that's not the primary focus of this function, so it really is optional.
I also wrapped the "If no path is provided..." at 80 chars.
I wonder if we should maybe look at some point at harmonizing the names of current_path(), base_path(), and drupal_get_path_alias() so it's more clear they are related.
Comment #18
caktux commentedAnother big thanks from me guys! :D How about we add path_alias() which would be a simple wrapper for drupal_get_path_alias()? Somehow it would group the three functions while keeping the "older" drupal_get_path_alias() intact ;)