Problem/Motivation
Hi,
I get the following error and warning on initialise database:
TypeError: Argument 1 passed to Drupal\user_history\Entity\UserHistory::setUserInit() must be of the type string, null given, called in /home/customer/www/test.rms2.net/public_html/modules/contrib/user_history/user_history.batch.inc on line 216 in Drupal\user_history\Entity\UserHistory->setUserInit() (line 468 of /home/customer/www/test.rms2.net/public_html/modules/contrib/user_history/src/Entity/UserHistory.php)
Warning: array_filter() expects parameter 1 to be array, null given in Drupal\user_history\Form\UserHistoryInitialiseForm->submitForm() (line 131 of /home/customer/www/test.rms2.net/public_html/modules/contrib/user_history/src/Form/UserHistoryInitialiseForm.php)
Steps to reproduce
Drupal 9.1.2
Composer require either User History version 8.x-1.0-rc2 or 8.x-1.x-dev (tried both)
Install module
Initialise (batch 100)
Proposed resolution
Resolve error. Searched issues and couldn't identify something related, sorry if I missed. I can provide the full trace on the error if need, just didn't want to clutter up the initial submission.
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | user_history-3223043-5.patch | 11.7 KB | jayelless |
| #4 | user_history-3223043-4.patch | 10.63 KB | jayelless |
| #3 | user_history-3223043.patch | 1.15 KB | lugir |
Comments
Comment #2
lugir commentedFor an installed site, some users may not have mail, init or timezone value, so UserHistory::setUserInit(), setUserMail() and setUserTimezone() should allow NULL as the input argument.
The patch attached.
Comment #3
lugir commentedComment #4
jayelless commentedI think that the correct approach it to ensure that all calls to set properties on the user_history entity are passing valid values. I have therefore changes the code that is generating user_history entities during the initialise or update process, plus the restore from an archive, to always pass a valid value.
Comment #6
jayelless commentedPicked up an additional change required.
Comment #7
jayelless commentedCommitted.