Skip to content

Errors when loading extension files should not halt the inspection #3

@mglaman

Description

@mglaman

An example is the Mandrill module.

// Load Mandrill library if found in module's /lib directory.
if (file_exists(drupal_get_path('module', 'mandrill') . '/lib/mandrill/src/Mandrill.php')) {
  require drupal_get_path('module', 'mandrill') . '/lib/mandrill/src/Mandrill.php';
}

This is due to drupal_get_path which calls drupal_get_filename and taps into the service container.

It is fixed with

                try {
                    require $module_dir . '/' . $module->getExtensionFilename();
                } catch (\Throwable $e) {
                    // Something prevent the extension file from loading.
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions