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.

CommentFileSizeAuthor
#6 2939228-6.patch446 bytestr

Comments

Uwe Mindrup created an issue. See original summary.

tr’s picture

Category: Bug report » Task
Priority: Normal » Minor

module_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.

uwe mindrup’s picture

Thank 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.

mlncn’s picture

Status: Active » Closed (cannot reproduce)

As the original reporter can't reproduce the error... i think we're good to close this!

attisan’s picture

Status: Closed (cannot reproduce) » Needs work

as 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

tr’s picture

Category: Task » Bug report
Status: Needs work » Needs review
StatusFileSize
new446 bytes

@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.

  • TR committed 21bd254 on 8.x-1.x
    Issue #2939228 by attisan, TR: Call to undefined function...
tr’s picture

Status: Needs review » Fixed

Committed #6.

Status: Fixed » Closed (fixed)

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