Problem/Motivation
Found frequent occurrences of the following error on a live site using the legal module:
Parameter 2 to legal_user() expected to be a reference, value given in .../includes/module.inc on line 497.
This is caused by the following code in the legal_user() function of legal/legal.module:
module_invoke_all('user', 'logout', NULL, $user);
The module_invoke_all() function should never be used to invoke hook_user(). The user_module_invoke() function should be used instead. Additionally, the $edit (second) parameter to hook_user() is required to be an array reference. Passing NULL would cause a PHP warning even if user_module_invoke() were used.
Proposed resolution
The call to module_invoke_all() should be replaced by a call to user_module_invoke() and a temporary $edit variable passed as the second parameter.
Remaining tasks
A patch needs to be written, reviewed, and applied.
User interface changes
None.
API changes
The Drupal API would be used correctly.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | legal-user_module_invoke-1533018-1.patch | 1.09 KB | pillarsdotnet |
Comments
Comment #1
pillarsdotnet commentedTrivial patch attached:
Comment #2
pillarsdotnet commentedComment #3
thedavidmeister commentedErrors are gone for me with patch in #1. Thank god.
Patch makes sense to me too and rolls nicely against 6.x-8.5
Comment #3.0
thedavidmeister commentedPatch submitted.
Comment #4
pillarsdotnet commentedNote that
user_module_invoke()will be removed in Drupal 8.See #200344: Remove user_module_invoke() and rename user_login_block() to user_login_block_form()
Comment #5
thedavidmeister commentedsure, good to know. This patch should still work well for d6 and d7 though. I was seeing a warning error for every single module that implements hook_user() (which is quite a few).
Comment #5.0
thedavidmeister commentedPatch reviewed.
Comment #7
robert castelo commentedNo longer supporting Drupal 6 version of Legal, so closing this old issue.