I'm using Views Aggregator 8.x-1.x-dev (Jan, 3, 2018) with Drupal 8.4.4. The error.log is flooded with "PHP Fatal error: Call to undefined function module_load_include() in .../views_aggregator/views_aggregator.module on line 12".
The function module_load_include() is marked as deprecated for Drupal-9. But it seems, this function isn't available in Drupal 8.4.4 anymore. I replaced Line 12 with
\Drupal::moduleHandler()->loadInclude('views_aggregator', 'inc', 'views_aggregator_functions');
and the error.log flooding stops.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2939228-6.patch | 446 bytes | tr |
Comments
Comment #2
tr commentedmodule_load_include () is NOT deprecated yet, because ModuleHandler can't do everything that is currently done by module_load_include(). In fact, module_load_include() is still used more than 50 times throughout core.
So while replacing module_load_include() is something that will need to be done eventually, it absolutely should not be causing a fatal error on your site. That indicates a much bigger problem on your site. module_load_include() is in core/includes/module.inc, and it is loaded in index.php by DrupalKernel - you can't get much more basic than that in Drupal. This function should always be available at all times.
Comment #3
uwe mindrup commentedThank you for your fast response. With an exact local copy of the site (php7.1 copy vs. php5.6 orignal) the function module_load_include() works as expected. Strange.
I try to find out the difference.
Comment #4
mlncn commentedAs the original reporter can't reproduce the error... i think we're good to close this!
Comment #5
attisanas the documentation on https://api.drupal.org/api/drupal/core%21includes%21module.inc/function/... clearly states, this call should be replaced
... Do not use this function in a global context since it requires Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file' instead.
when using drupal from an outside script (bootstrap from script) an Error will be thrown on accessing
module_load_include.tia
Comment #6
tr commented@attisan pointed out an important fact in the documentation. The attached patch uses require_once instead of module_load_include().
In the long run, the functions that are being loaded here should be plugins so we don't have to include them explicitly.
Comment #8
tr commentedCommitted #6.