If one installs components which do not have a registered path in the system table in the database, then drupal_get_filename() will not find them.

example: install smarty engine in 'sites/all/themes/engines' and it will fail because it cannot find it's own library.

fix: add the sites/all paths into the path search loop for drupal_get_filename()

 ** root@ethel ** /usr/local/www/drupal6 ** Mon Dec 08 16:17:00
# diff -c includes/bootstrap.inc~ includes/bootstrap.inc
*** includes/bootstrap.inc~	Sat Oct 25 11:05:16 2008
--- includes/bootstrap.inc	Mon Dec  8 16:15:23 2008
***************
*** 413,420 ****
      $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s");
      $file = (($type == 'theme_engine') ? "$name.engine" : "$name.$type");
  
!     foreach (array("$config/$dir/$file", "$config/$dir/$name/$file", "$dir/$file", "$dir/$name/$file") as $file) {
!       if (file_exists($file)) {
          $files[$type][$name] = $file;
          break;
        }
--- 413,427 ----
      $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s");
      $file = (($type == 'theme_engine') ? "$name.engine" : "$name.$type");
  
!     foreach (array(
!                "$config/$dir/$file",
!                "$config/$dir/$name/$file",
!                "sites/all/$dir/$file",
!                "sites/all/$dir/$name/$file",
!                "$dir/$file",
!                "$dir/$name/$file",
!                ) as $file) {
!       if (file_exists('./'. $file)) {
          $files[$type][$name] = $file;
          break;
        }

discussion: I'm new to Drupal; so I don't have the history to know whether there is a larger reason why the sites/all path is excluded. I am also worried that hard coding the sites/all path is poor practice; but I don't know where that might be stored as a constant or variable.

versions:

os
FreeBSD FreeBSD 7.0-RELEASE-p3
apache
2.2.9 FreeBSD patch level 5
php
5.2.6 FreeBSD patch level 2
drupal
6.6 (but the same problem appears in the CVS DRUPAL-6 version of bootstrap.inc)

drupal root: /usr/local/www/drupal6

Comments

dave reid’s picture

Status: Active » Closed (won't fix)

That code block is ONLY used if there is not an active database connection, which is typically during install or update, in which the theme will always be set to minnelli.

dave reid’s picture

Status: Closed (won't fix) » Closed (works as designed)

I guess it would be more appropriate to mark this as 'by design.'

ericxb’s picture

It gets used when loading the smarty engine because there are no records in table 'system.' Is it the case then, that the engine should be installing paths in table 'system' during some sort of install phase? I was not aware that engines had an install mechanism like themes and modules.

dave reid’s picture

I was looking into this a little more, and it doesn't look like engines are put into the system table at all. Can you point me to a Smarty Drupal template so I can help test this?

ericxb’s picture

I've been using Smarty for several years; and without any disparaging remarks I really didn't want to face the phptemplate syntax; so I've been trying to install the smarty engine and ran into problems. I do not have a valid smarty-template. However, I've been working with the drupal 5 template garland-smarty as a starting point.

It's broken; but it will still illustrate this problem. When smarty.engine initializes, it searches for the path to the Smarty class definition as [smarty.engine line 97]:

$smarty_path = drupal_get_path('theme_engine', 'smarty') . '/libs/Smarty.class.php';

Ultimately, this gets to drupal_get_filename() in bootstrap.inc which, in turn, performs a search for:

SELECT filename FROM {system} WHERE name = 'smarty' AND type = 'theme_engine'

There is probably no reason why that record could not be in {system}, but I think that implies support for a smarty.install in themes/engines/[whatever]?

In any event, since there is no record, drupal_get_path() drops thru to the file system search for smarty.engine every time a page is displayed. This probably works fine (less efficiently) if you install smarty.engine in themes/engines or sites/[mysite]/themes/engines but fails if you install it in sites/all/themes/engines because that root path is not searched by drupal_get_path.

I'm thinking that the "correct" solution is probably inserting the engine path record into {system}; but if there is no install support for engines (alternative templating engines do not appear to be popular) it might not be worth the coding time. A reasonable work-around might be a recommendation to engine authors that this record be inserted by hand (in INSTALL.txt) but with the addition of the sites/all paths to drupal_get_path() ultimately unnecessary.

dave reid’s picture

Version: 6.6 » 6.x-dev
Status: Closed (works as designed) » Active

Hmm...I'll have to investigate this some more. Un-marking 'by design' for now.

XRaptor’s picture

I just ran into the same problem when playing with smarty http://drupal.org/node/346475 . (I found this report after I posted... oops) But is there a reason to not search the "sites/all" folder for unregistered files?

kars-t’s picture

Hi,

for example the phpmailer module can't be activated during install due to this. It checks the needed phpmail files through this function and as the modules resides in sites/all the check fails.

Is this old issue still active?
Shouldn't sites/all be added to the path check if no database is active as the function description on a.d.o says?

I believe D7 uses drupal_system_listing to achieve this?
#626688: Add caching for system_list()

Or maybe this issue is releated / a duplicate of
#341140: drupal_get_filename() when database is down, does not deal with phptemplate themes

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.