Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently it seems that the include_once statement in a feature's *.module file is generated as
include_once 'MYFEATURE.features.inc';
My IDE (EA Extended plugin for PhpStorm) complains that this is bad practice ("Untrusted files inclusion") - and I agree.
Why depend on include path, if we can instead use __DIR__ or dirname(__FILE__) to be more reliable and transparent?
include_once __DIR__ . '/MYFEATURE.features.inc';
or if we want to support PHP < 5.3 (no idea if we care):
include_once dirname(__FILE__) . '/MYFEATURE.features.inc';
Comments
Comment #2
donquixote CreditAttribution: donquixote as a volunteer commentedAnd, just saying (for random visitors):
If anyone considers module_load_include() for this: Don't.
This function is only useful for inclusion of *other* modules. If we are already within the same module, __DIR__ is faster and more reliable and transparent.