Unable to install Dolibarr due to error on updating admin user password which begin with exclamation symbol!

@eldy tell me if i need to post something like this post on Github but i thought that here will probably be useful to other users not so technical like me or you.

I’m trying to install Dolibarr since the last 2-3 days in my new local ubuntu, for development purpose. And i got it finally, because i solved this bug:

  • in the step5 of the installation wizard, i got always the same error: go back (step 4) and put the right information (or something like this)
  • after try and try during 2 days several changes on the data introduced in the wizard, and the configuration of my mariadb database, i got it run finally!!
  • the problem was that i’m specifying a password for the admin user beginning with the exclamation symbol: !

Why is a problem? Eldy, the User class is the problem: the create() method hast this WRONG “IF” CONDITION:

$result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass);
if ($result < 0) {
  return -5;
}

The problem is that the setPassword() function returns the non-crypted password when the the result is successful and a negative integer (like -1) when the results is a failure.

And the the condition $result < 0 is TRUE when $result is something like: !mypassword1234 due to the initial exclamation symbol !

So, in this case this condition must be replaced with:

if (is_numeric($result) &&  $result < 0) {
  return -5;
}

I did it and it perfectly worked. Finally i finished the installation.

Extra considerations

  • i suppose that it happens with other symbols, so this bug can be quite annoying to set new user passwords, so it’s necessary to fix it asap
  • i’ve been always using this same kind of passwords, beginning with ! until now in Dolibarr and this time is the first time i have had this problem, so i think that it probably has been caused by be using PHP 8.1 in my local server. I know that it’s not recommended to use it, but well… maybe this is quite easy to fix or maybe it would be to replace all these collection of conditions of type $result < 0 around Dolibarr. Some of my hosting providers has forced to me to migrate to PHP +8.1 yes or yes… (ultimatum like).
  • @Eldy, let me know if you need i publish this in Github.

Cheers!
Sergi

Thanks for feedback and solution.
No need to create an issue, i have already pushed your fix on v17 branch.

1 Like

Eldy, take in account that in that file that “incomplete” IF condition appears 2 times. So it’s needed to apply this fix in 2 different lines in the same file.

Cheers!
Sergi