file_directory_path() doesn't exist in drupal 7 - except under certain conditions
I was just about to release the Drupal 7 version of Development Banner a few days ago, I got an error trying to install it on a local site during final testing:
Fatal error: Call to undefined function file_directory_path() in /var/www/html/sandbox/public/7.x/sites/all/modules/cowork/dev_banner/dev_banner.module on line 83
Ooops, I was using an older version that was before I replaced calls to file_directory_path() with file_default_scheme(). But this same version worked without an error on another server, using the same older version of the code.
Why didn't I get the error on the other server? I know file_directory_path() isn't part of Drupal 7, yet I got no error. Turns out the function is included under at least one certain condition. The culprit was that I had included the Code Review module, which does define this function in coder_upgrade.inc:
if (!function_exists('file_directory_path')) {
function file_directory_path($scheme = 'public') {
...
I understand why it's there, but it wasn't immediately obvious what was going on.
Lesson learned: when testing a module for release, use a minimal Drupal test site (ideally freshly installed).
I made minimal installs of both D6 and D7 and put them in a git repo, so I could pull them down for testing whenever I need one. But duh, I did my release testing on a built out side. Sometimes lessons are learned the hard way!
bloggity
-
22 Aug 2011
-
21 Jun 2011
-
18 Jun 2011
-
22 Apr 2011
-
22 Apr 2011
Curated Image
Tweeted
- too bad he's locked up, would make a great Joker http://t.co/1ReeSJeQ — 1 day 23 min ago
- best salad ever http://t.co/OlAtbuxp — 3 days 5 hours ago
- why did the Beatle cross the road? http://t.co/DncVSZDm — 1 week 1 day ago
- cat breading http://t.co/XxaO2G9i — 1 week 1 day ago
- Is it bad that every time I see a user registration with a hotmail address, I suspect a spammer? /via @akalsey: smacks of domainism — 1 week 5 days ago
- 1 of 64
- ››

