drupal_get_path

JDSaward - August 7, 2009 - 03:22
Project:FileField Paths
Version:5.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

function filefield_paths_init calls drupal_get_path.

With caching enabled that returns an error - 'Call to undefined function drupal_get_path()'.

Should the call be moved to hook_menu?

#1

noahterp - August 11, 2009 - 11:25

I can confirm that this bug results in a White-Screen-of-Death for FileField Paths 5.x-1.3 under these conditions:

  1. Turn on Normal caching in the Performance settings.
  2. Logout and view any page anonymously. Caching would then create an entry within the cache_page table.
  3. Reload that page — you will just get a blank screen.

The specific PHP error message this function generates is:

PHP Fatal error: Call to undefined function drupal_get_path() in /var/www/vhosts/yourdomain.com/httpdocs/sites/all/modules/filefield_paths/filefield_paths.module on line 63

Any idea why drupal_get_path() isn't working at this point? I even used Module Weight to try to delay loading this module to no luck.

A temporary solution I created was to manually specify the path. So that function call is just replaced in the module with:
$_SERVER['DOCUMENT_ROOT'] . '/sites/all/modules/filefield_paths/modules/' . $module . '.inc'

That'll have to do until someone can help come up with a patch.

#2

tomhung - August 14, 2009 - 15:48

i can confirm this problem.

i had to roll the module back a version.

Greg

#3

Deciphered - August 19, 2009 - 21:02

Hi Guys,

Unfortunately (for you) I've been on holidays for the last week or so, so haven't had time to look into this yet.
Will look into it ASAP.

Cheers,
Deciphered.

#4

asanvicente1 - November 4, 2009 - 21:28

Hi Deciphered (and all),

Are there any new developments on this issue?

Thanks in advance

#5

royerd - November 29, 2009 - 15:33

I'm also getting this white page under the same conditions. I don't know how to view my PHP error, but when I view any page anonymously and reload that page, I get a blank screen. If I am logged in as Admin, I'm fine. I have to turn off the module to get my site to work again.

Should I be using noahterp's solution?

Dan

#6

royerd - November 29, 2009 - 15:39

Noahterp:

Could you help me a little bit with this? The code you are referring to is, I think, here:

/**
* Implementation of hook_init().
*/
function filefield_paths_init() {
foreach (module_list() as $module) {
if (file_exists($file = drupal_get_path('module', 'filefield_paths') .'/modules/'. $module .'.inc')) {
require_once $file;
}
}
}

And you are saying that a fix is to put this piece of code in there--but can you tell me where? Or just recode that block for me and paste it here in this note?

$_SERVER['DOCUMENT_ROOT'] . '/sites/all/modules/filefield_paths/modules/' . $module . '.inc'

Thanks in advance. I really appreciate any help you can give me.

Dan

 
 

Drupal is a registered trademark of Dries Buytaert.