Problem/Motivation
The Event Logger module assumes that a form will provide the structure $form['#submit] and throws a PHP error when the $form['action']['submit] structure is used. This issue is being encountered by using the Context module.
See elogger.module line 87.
// Skip the elogger exposed form from elogging events triggering.
if ($form['#id'] != $elogger_exposed_form) {
array_unshift($form['#submit'], '_add_form_submit_log');
}
}
Steps to reproduce
- Install the Context module.
- Add a Condition based on a URL Request.
- Add a Reaction to place a Block.
- Click the 'Place Block' button to place a block in a region.
Result:The "Place Button" form submit causes the Event Logger module to throw a PHP error:
TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() (line 87 of /Users/myuser/Sites/mysite/docroot/modules/contrib/elogger/elogger.module)
Proposed resolution
Review the Forms API and Forms AJAX API to determine the correct format, OR, modify the conditional statement to handle multiple form array formats.
https://www.drupal.org/docs/drupal-apis/form-api/introduction-to-form-api
https://www.drupal.org/docs/drupal-apis/javascript-api/ajax-forms
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3310192-5.patch | 480 bytes | narendra.rajwar27 |
Issue fork elogger-3310192
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
smustgrave commentedTried replicating this but wasn't able to generate the error.
Could you provide more specific steps? What version of Drupal are you on?
Comment #3
andrei.vesterliLet me check it...
Comment #4
andrei.vesterliComment #5
narendra.rajwar27Adding patch.
Comment #6
andrei.vesterliHello @narendra.rajwar27
Good to see a patch here but it seems that it's not fixing the actual issue that was described. We need to focus on this line:
array_unshift($form['#submit'], '_add_form_submit_log');I need to find some time to fix it...
We need to handle the case when there is no
$form['#submit']key, also when we have this key$form['action']and maybe others.Regards,
Andrei
Comment #7
andrei.vesterliComment #8
smustgrave commentedFixing credit
Comment #9
narendra.rajwar27We need to handle the case when there is no $form['#submit'] key, also when we have this key $form['action'] and maybe others@andrei.vesterli, sure. Thanks!!
Till the time the above patch can be used. As i have checked and tested that place block option is working with condition and reaction which was not working earlier.
Comment #11
andrei.vesterliComment #13
andrei.vesterliComment #14
andrei.vesterli