Skip to content

Odd behaviors when reusing user object instance #21242

@cconard96

Description

@cconard96

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Version

11.0

Bug description

Seen while bulk-creating a thousand users to test an issue reported on the forum, every other user created ended up having no password and those same users generated 4 errors in the log each.

When an item is added, the fields are loaded from the DB. When you reuse the instance to add a new user, the PasswordHistory::validatePassword method calls isNewItem and sees the previous ID. It continues and tries to check the current password from the fields array which would be null because it is a new item. This results in a series of failures which results in a user with a null password.

Relevant log output

[2025-10-01 23:56:55] glpi.INFO:   *** Deprecated: password_get_info(): Passing null to parameter #1 ($hash) of type string is deprecated at Auth.php line 379
  Backtrace :
  ./src/Auth.php:379                                 
  ./src/PasswordHistory.php:88                       Auth::checkPassword()
  ./src/User.php:6649                                PasswordHistory->validatePassword()
  ./src/User.php:892                                 User->validatePassword()
  ./src/CommonDBTM.php:1337                          User->prepareInputForAdd()
  ./front/test.php:71                                CommonDBTM->add()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

[2025-10-01 23:56:55] glpi.INFO:   *** Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at Auth.php line 383
  Backtrace :
  ./src/Auth.php:383                                 
  ./src/PasswordHistory.php:88                       Auth::checkPassword()
  ./src/User.php:6649                                PasswordHistory->validatePassword()
  ./src/User.php:892                                 User->validatePassword()
  ./src/CommonDBTM.php:1337                          User->prepareInputForAdd()
  ./front/test.php:71                                CommonDBTM->add()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

[2025-10-01 23:56:55] glpi.INFO:   *** Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at Auth.php line 385
  Backtrace :
  ./src/Auth.php:385                                 
  ./src/PasswordHistory.php:88                       Auth::checkPassword()
  ./src/User.php:6649                                PasswordHistory->validatePassword()
  ./src/User.php:892                                 User->validatePassword()
  ./src/CommonDBTM.php:1337                          User->prepareInputForAdd()
  ./front/test.php:71                                CommonDBTM->add()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

[2025-10-01 23:56:55] glpi.INFO:   *** Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated at Auth.php line 388
  Backtrace :
  ./src/Auth.php:388                                 
  ./src/PasswordHistory.php:88                       Auth::checkPassword()
  ./src/User.php:6649                                PasswordHistory->validatePassword()
  ./src/User.php:892                                 User->validatePassword()
  ./src/CommonDBTM.php:1337                          User->prepareInputForAdd()
  ./front/test.php:71                                CommonDBTM->add()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions