Notice: Array to string conversion in module_hook()

Created on 5 December 2017, almost 7 years ago
Updated 24 April 2024, 6 months ago

When using PHP7.1.2 there is Notice in converting array to string on module.inc line 688.

This Notice can by avoided if string is explicit converted.

This is not a fix, just a workaround, so no patch provided:

file: includes/module.inc
line 688
remove
and add this
$string = print_r($hook_info[$hook]['group'],true);
module_load_include('inc', $module, $module . '.' . $string);

🐛 Bug report
Status

Active

Version

7.0 ⚰️

Component
Extension 

Last updated about 13 hours ago

No maintainer
Created by

🇵🇹Portugal jrochate

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    $hook_info[$hook]['group'] is expected to be a string, as described in hook_hook_info().

    group: A string defining the group to which the hook belongs. The module system will determine whether a file with the name $module.$group.inc exists, and automatically load it when required.

    $hook_info[$hook]['group'] can be an array only when two modules have a similar hook_hook_info() implementation.

    function my_custom_module_hook_info() {
      $hooks['token_info'] = array(
        'group' => 'token.info',
      );
    
      return $hooks;
    }
    
    function mymodule_hook_info() {
      $hooks['token_info'] = array(
        'group' => 'token_info',
      );
    
      return $hooks;
    }
    
Production build 0.71.5 2024