Project:File (Field) Paths
Version:5.x-1.3
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

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?

Comments

#1

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

i can confirm this problem.

i had to roll the module back a version.

Greg

#3

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

Hi Deciphered (and all),

Are there any new developments on this issue?

Thanks in advance

#5

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

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

#7

I replaced line 64 from:

if (file_exists($file = drupal_get_path('module', 'filefield_paths') .'/modules/'. $module .'.inc')) {

to:

if (file_exists($file = $_SERVER['DOCUMENT_ROOT'] . '/sites/all/modules/filefield_paths/modules/' . $module . '.inc')) {

So instead of calling drupal_get_path(), I replaced it with a hard-coded version of what that function would have returned. You just have to make sure your module is installed in that exact path, otherwise you'll need to change that line to point to the right place.

#8

Thanks much!

#9

Priority:normal» minor

Hi guys,

I had made the decision a while back that due to lack of time and personal use I would no longer be supporting Drupal 5.
I may consider committing the occasional patch if it is submitted correctly, and reviewed and tested by the community.

Cheers,
Deciphered.

#10

The following seems to work on my site.

Change this:
if (file_exists($file = drupal_get_path('module', 'filefield_paths') .'/modules/'. $module .'.inc')) {

to:
if (file_exists($file = dirname(drupal_get_filename('module', 'filefield_paths')) .'/modules/'. $module .'.inc')) {

Hopefully my patch works, this is my first one.

AttachmentSize
filefield_paths-drupal_get_path_issue.patch 498 bytes

#11

I was recently trying to investigate that too and I wonder, why is that in hook_init anyway? It seems, from the API documentation, that perhaps this should go to hook_menu instead? I didn't have time to test hook_menu yet, because I needed a quick and dirty solution, and I used the trick found in other modules to check whether the page is served from cache:

<?php
function filefield_paths_init() {
  if (
function_exists('drupal_set_content')) {
    foreach (
module_list() as $module) {
      if (
file_exists($file = drupal_get_path('module', 'filefield_paths') .'/modules/'. $module .'.inc')) {
      require_once
$file;
      }
    }
  }
}
?>

So far it works for me.

#12

Status:active» closed (won't fix)