Motivation

One should use module_load_include instead of require_once when want to load file in particular function as indicated here:
Loads a module include file.
The correct way to include files in your Drupal module - Learning from the Drupal API
Drupal: Use module_load_include(), not require_once.

Proposed resolution

I will try to use module_load_include() instead require_once() as below:

e.g: module_load_include('inc', 'my_module_name', 'my_module_name.admin');

One who cant apply path they can use below code:
Instead of

include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'email_verify') . '/windows_compat.inc';

use

module_load_include('inc', 'email_verify', 'windows_compat');
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dineshw’s picture

Added patch to use module_load_include instead of include_once

dineshw’s picture

Status: Active » Needs review
shyamkunkala’s picture

Code is good. Reviewed but there is trailing space error I got while applying the patch. So I am uploading the corrected patch.

gobinathm’s picture

Status: Needs review » Reviewed & tested by the community

provided patch works fine

  • oadaeh committed b4def9b on 7.x-1.x authored by dineshw
    Issue #2195119 by dineshw, shyamkunkala: Use of module_load_include...
oadaeh’s picture

Status: Reviewed & tested by the community » Fixed

This has been committed to the dev branch.

Status: Fixed » Closed (fixed)

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