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!

Comments

charlie1volley created an issue. See original summary.

lugir’s picture

Version: 8.x-1.0-rc2 » 8.x-1.0-rc4
StatusFileSize
new1.26 KB

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

lugir’s picture

StatusFileSize
new1.15 KB
jayelless’s picture

Status: Active » Needs review
StatusFileSize
new10.63 KB

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

  • f24938d committed on 8.x-1.x
    Issue #3223043 by Lugir, jlscott: Error on initialise
    
jayelless’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new11.7 KB

Picked up an additional change required.

jayelless’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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