Hi,

I got the following error when moving this module to a subfolder in sites/all/modules, even after using Registry Rebuild. It might be preferable to use module_load_include() instead of require_once or include statements, as described here.

[17-Sep-2013 16:48:52 UTC] PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/path/to/drupal/sites/all/modules/media/file_entity/file_entity.file_api.inc' (include_path='.:/Applications/MAMP/bin/php/php5.3.14/lib/php') in /path/to/drupal/sites/all/modules/media/file_entity/file_entity.module on line 13
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alberto56’s picture

Here is a patch that does this.

alberto56’s picture

Status: Active » Needs review
alberto56’s picture

Here's another version with more calls changed from require_once to module_load_include.

osopolar’s picture

Issue summary: View changes
Status: Needs review » Needs work

The patch works in may case after I had moved the module to a different place. But I don't think that it is the correct way to solve the issue, as the documentation for module_load_include() says:

Do not use this function in a global context since it requires Drupal to be fully bootstrapped...

alberto56’s picture

Good point. I am assuming we are loading external files because we don't want the media.module to be get too big. My approach normally is to use autoload classes, so we might have something like this...

# file media.info
...
files[] = includes/MediaVariable.inc
# file includes/MediaVariable.inc
class MediaVariable {
  static function Get($variable) {
    ...
  }
}
# file media.module
function media_admin_paths() {
  ...
  $dialog_theme = MediaVariable::Get('dialog_theme');
  ...
}

That way we're achieving the same result, while Drupal, not the module, is dealing with file management.

Chris Matthews’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs work » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team