Got this error in update.php while running the update from 1.1 to 1.2 (web based update, no drush update):

Warning: require(sites/all/modules/insert/includes/file.inc): failed to open stream: No such file or directory in require() (Line 10 von sites/all/modules/insert/insert.module).
Status message U

Why is the module not using the variable DRUPAL_ROOT? Can this solve the bug?

require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'insert') . '/includes/file.inc');

Comments

hass’s picture

Note, the file is there in the filesystem. Maybe a core update module timing/ordering issue with extraction.

quicksketch’s picture

Category: bug » support
Priority: Major » Normal

I've seen this behavior in the past due to APC's buggy include_once_override option. For a short while there some distros had this option enabled by default, causing general havoc around the PHP world as it repeated broke sites.

Restarting your web server (or PHP instances if running as fcgi) will usually clear up these problems after a code change.

hass’s picture

I have no APC, but FCGI on this server. I cannot restart PHP as this is a shared host. I guess if I have installed manually I would not have seen this. I'm not sure if there is any problem now or the upgrade had troubles and may broke something. I never seen this before with any other module I've upgraded!? What's the reason? Looks like a one time situation. At least it's not permanent now. It's latest Debian 6 server...

quicksketch’s picture

So did you get the problem resolved by some other means, like downloading and re-installing the module manually? I don't think Insert module is at fault here, it very well may be a fault on PHP's side (they've got bugs too). Obviously the file exists and at least it's working for me. That line was completely unchanged between versions, as were the file locations.

hass’s picture

The update hooks completed and above the update result the drupal error message was shown. There was no outage. I'm myself not sure if the source may be the DRUPAL_ROOT or better an FCGI incompatibility with require dirname(__FILE__). Aside shouldn't this require_once? http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_... is not using __FILE__. Just guessing if this is the source of this issue.

Cannot be wrong to use (the Drupal way)... :-)

require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'insert') . '/includes/file.inc');
quicksketch’s picture

Title: Upgrade: failed to open stream: No such file or directory in require() » Switch includes to use DRUPAL_ROOT instead of dirname(__FILE__)
Category: support » feature

Yeah, it's a good idea nonetheless. dirname(__FILE__) probably requires disk access, or at least processing. DRUPAL_ROOT would certainly be superior. dirname(__FILE__) is left over from Drupal 6 when we didn't have DRUPAL_ROOT.

Oh... there's also was a problem in Drupal 6 where drupal_get_path() required use of the DB, thus causing installation profiles to fail... I'm guessing this is probably fixed in D7 too. May require a little testing.

hass’s picture

Is module_load_include(); better?

quicksketch’s picture

module_load_include() calls drupal_get_path(), which is the source of the problem I believe (in Drupal 6). Both are probably okay in D7 but I haven't investigated.

  • Snater committed 8ccafe0 on 7.x-1.x
    Issue #1779522: Changed references to required files
    
Snater’s picture

Issue summary: View changes
Status: Active » Fixed

Switched to DRUPAL_ROOT as that seems to be the more common practice.

Snater’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.