API page: http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_g...
Enter a descriptive title (above) relating to drupal_get_path, then describe the problem you have found:
There is no mention of what happens when the file is not found. A quick test shows the file function returns a binary zero and that makes dirname return an empty string.
drupal_get_path('module', 'sdkjghfsdjklghfsdkjghfds');
returns an empty string.
There may be other possibilities in the code.
Comment | File | Size | Author |
---|---|---|---|
#11 | common.inc-documentation-1908194-11.patch | 522 bytes | richard.c.allen2386 |
#4 | common.inc-documentation-1908194-4.patch | 510 bytes | richard.c.allen2386 |
#2 | common.inc-documentation-1908194-2.patch | 521 bytes | richard.c.allen2386 |
Comments
Comment #1
jhodgdonThanks -- we should document this in 8.x first and then backport to 7.x.
Comment #2
richard.c.allen2386 CreditAttribution: richard.c.allen2386 commentedHere you go, this should be good?
Comment #3
jhodgdonThanks! Can you clean up the grammar and combine the two possibilities? Something like:
@return
Blah blah blah, or foo if (whatever, but include a verb).
Comment #4
richard.c.allen2386 CreditAttribution: richard.c.allen2386 commentedre-rolled, wasn't quite clear on the second part nor was anyone else in the office. maybe we're all terrible at grammar!
Comment #5
richard.c.allen2386 CreditAttribution: richard.c.allen2386 commentedComment #6
jhodgdonHow about "... if the file is not found" for the second part?
Comment #7
mitron CreditAttribution: mitron commentedIt is less clear to call a module a "file" than an "item" so perhaps something like "....or an empty string if the item is not found." Perhaps something like the following:
Comment #8
jhodgdon#7 seems fine to me. Just make sure the line wraps if it goes over 80 characters. Thanks!
Comment #9
mitron CreditAttribution: mitron commentedLooks like drupal_get_filename() returns NULL not an empty string when the file does not exist. There should be a test that asserts this.
Comment #10
peterx CreditAttribution: peterx commentedMy quick test: http://petermoulding.com/test_drupal_functions
Comment #11
richard.c.allen2386 CreditAttribution: richard.c.allen2386 commentedI re-rolled using the comment from #7. The test function in #10 seems to indicate that it is an empty string.
Comment #12
jhodgdonThanks! I'll get this committed when the test result turns green.
Comment #13
mitron CreditAttribution: mitron commentedDoes the backport for V7 go in this issue too?
Comment #14
jhodgdonIt will, but wait until the 8.x version is committed. Often the same patch can be applied and no one has to do any more work backporting it. :)
Comment #15
jhodgdonThanks again -- Committed to both 8.x and 7.x (no port required).
Comment #16
jhodgdon