In same cases require_once fails with following error:

( ! ) Fatal error: require_once() [function.require]: Failed opening required 'sites/all/modules/contributions/gallery/gallery_user.inc' (include_path='.;C:\php5\pear') in D:\bro\websites\pol\sites\all\modules\contributions\gallery\gallery.module on line 330

Probably line:

  require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');

Should be changed to:

  require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');

It happen especially when Drupal was started from different path (cron, etc.)

Comments

kenorb’s picture

Status: Needs review » Needs work

It happen when module registered shutdown function (i.e. with performance module - part of Devel module):

Call Stack
#	Time	Memory	Function	Location
1	6.1278	64905176	performance_shutdown( )	..\performance.module:0
2	6.1279	64906232	performance_log_details( $params = array ('timer' => 6110.42, 'path' => 'uk', 'mem' => 66060288, 'query_count' => 0, 'query_timer' => 0) )	..\performance.module:178
3	6.1279	64906552	drupal_get_title( )	..\performance.module:283
4	6.1279	64906688	menu_get_active_title( )	..\path.inc:188
5	6.1280	64906984	menu_get_active_trail( )	..\menu.inc:1589
6	6.1280	64906984	menu_set_active_trail( $new_trail = ??? )	..\menu.inc:1554
7	6.1281	64910008	menu_tree_page_data( $menu_name = 'navigation' )
...
10	6.1543	66744464	_menu_link_translate( $item = array ('load_functions' => 'a:1:{i:1;s:22:"user_uid_optional_load";}', 'to_arg_functions' => 'a:1:{i:1;s:24:"user_uid_optional_to_arg";}', 'access_callback' => 'user_view_access', 'access_arguments' => 'a:1:{i:0;i:1;}', 'page_callback' => 'panels_page_render_handler', 'page_arguments' => 'a:2:{i:0;s:12:"user_profile";i:1;i:1;}', 'title' => 'My account', 'title_callback' => 'panels_page_title_handler', 'title_arguments' => 'a:2:{i:0;s:12:"user_profile";i:1;i:1;}', 'type' => '4', 'description' => '', 'menu_name' => 'navigation', 'mlid' => '21', 'plid' => '0', 'link_path' => 'user/%', 'router_path' => 'user/%', 'link_title' => 'My account', 'options' => array ('attributes' => array ('title' => '')), 'module' => 'system', 'hidden' => '0', 'external' => '0', 'has_children' => '1', 'expanded' => '0', 'weight' => '-50', 'depth' => '1', 'customized' => '1', 'p1' => '21', 'p2' => '0', 'p3' => '0', 'p4' => '0', 'p5' => '0', 'p6' => '0', 'p7' => '0', 'p8' => '0', 'p9' => '0', 'updated' => '0', 'in_active_trail' => FALSE, 'href' => 'user/0') )	..\menu.inc:1007
11	6.1544	66746808	_menu_load_objects( $item = array ('load_functions' => 'a:1:{i:1;s:22:"user_uid_optional_load";}', 'to_arg_functions' => 'a:1:{i:1;s:24:"user_uid_optional_to_arg";}', 'access_callback' => 'user_view_access', 'access_arguments' => 'a:1:{i:0;i:1;}', 'page_callback' => 'panels_page_render_handler', 'page_arguments' => 'a:2:{i:0;s:12:"user_profile";i:1;i:1;}', 'title' => 'My account', 'title_callback' => 'panels_page_title_handler', 'title_arguments' => 'a:2:{i:0;s:12:"user_profile";i:1;i:1;}', 'type' => '4', 'description' => '', 'menu_name' => 'navigation', 'mlid' => '21', 'plid' => '0', 'link_path' => 'user/%', 'router_path' => 'user/%', 'link_title' => 'My account', 'options' => array ('attributes' => array ('title' => '')), 'module' => 'system', 'hidden' => '0', 'external' => '0', 'has_children' => '1', 'expanded' => '0', 'weight' => '-50', 'depth' => '1', 'customized' => '1', 'p1' => '21', 'p2' => '0', 'p3' => '0', 'p4' => '0', 'p5' => '0', 'p6' => '0', 'p7' => '0', 'p8' => '0', 'p9' => '0', 'updated' => '0', 'in_active_trail' => FALSE, 'href' => 'user/0'), $map = array (0 => 'user', 1 => 0) )	..\menu.inc:650
12	6.1544	66748520	user_uid_optional_load( $arg = 0 )	..\menu.inc:410
13	6.1545	66748568	user_load( $array = 0 )	..\user.module:1125
14	6.1553	66755312	user_module_invoke( $type = 'load', $array = array ('uid' => 0), $user = class stdClass { public $uid = '0'; public $name = ''; public $pass = ''; public $mail = ''; public $mode = '0'; public $sort = '0'; public $threshold = '0'; public $theme = ''; public $signature = ''; public $created = '0'; public $access = '0'; public $login = '0'; public $status = '0'; public $timezone = NULL; public $language = ''; public $picture = ''; public $init = ''; public $data = NULL; public $timezone_name = ''; public $roles = array (1 => 'anonymous user'); public $user_post_count = '2464'; public  public $nodes = array () }, $category = ??? )	..\user.module:183
15	6.1573	66776376	gallery_user( $op = 'load', $edit = array ('uid' => 0), $user = class stdClass { public $uid = '0'; public $name = ''; public $pass = ''; public $mail = ''; public $mode = '0'; public $sort = '0'; public $threshold = '0'; public $theme = ''; public $signature = ''; public $created = '0'; public $access = '0'; public $login = '0'; public $status = '0'; public $timezone = NULL; public $language = ''; public $picture = ''; public $init = ''; public $data = NULL; public $timezone_name = ''; public $roles = array (1 => 'anonymous user'); public $user_post_count = '2464'; public $nodes = array () }, $category = NULL )	..\user.module:22

So require_once() should be moved inside the case section apart of 'load' operation.

There is similar issue with Pathauto - #337615: require_once failure on cron with modules that have a register_shutdown_function
and it was fixed here: http://drupal.org/files/issues/pathauto_include_optimization.patch
So it can be fixed in similar way.

kenorb’s picture

Status: Needs work » Needs review

I've fixed in this way:

function gallery_user($op, &$edit, &$user, $category = NULL) {
  switch ($op) {
    case 'login':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      gallery_login();
      break;
    case 'logout':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      gallery_logout();
      break;
    case 'view':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      return gallery_user_view($user);
    case 'insert':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      return gallery_user_insert($edit, drupal_clone($user));
    case 'update':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      return gallery_user_update($edit, drupal_clone($user));
    case 'delete':
      require_once('./'.drupal_get_path('module', 'gallery') .'/gallery_user.inc');
      return gallery_user_delete($user);
  }
}

Or if somebody have better solution.

kenorb’s picture

Status: Needs review » Active
kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Version 6.x is no longer supported due to Drupal 6 End of Life.