Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.47k stars 2.8k forks source link

Adherent address update crashes when LDAP sync is active #30819

Open alarig opened 2 months ago

alarig commented 2 months ago

Bug

If I try to update a postal address, I get a blank page and the address isn’t changed. The error log is in the filed at the end of the form.

Dolibarr Version

19.0.2

Environment PHP

8.2

Environment Database

5.5.5-10.6.14-MariaDB-log

Steps to reproduce the behavior and expected behavior

Update a postal address from adherents/card.php

Attached files

2024/08/31 20:03:56 [error] 13069#13069: *3417218 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "" in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1359; PHP message: PHP Warning:  Trying to access array offset on value of type null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1359; PHP message: PHP Warning:  Undefined array key "" in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1360; PHP message: PHP Warning:  Trying to access array offset on value of type null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1360; PHP message: PHP Warning:  Undefined array key "" in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1362; PHP message: PHP Warning:  Trying to access array offset on value of type null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1362; PHP message: PHP Warning:  Undefined array key "useraccountcontrol" in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1364; PHP message: PHP Warning:  Trying to access array offset on value of type null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1364; PHP message: PHP Warning:  Undefined array key "badpasswordtime" in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1373; PHP message: PHP Warning:  Trying to access array offset on value of type null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/ldap.class.php on line 1373" while reading response header from upstream, client: 172.17.0.2, server: dolibarr.grif, request: "POST /index.php?mainmenu=home HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-dolibarr.sock:", host: "dolibarr.grif", referrer: "https://dolibarr.grif/"
2024/08/31 20:04:27 [error] 13069#13069: *3417218 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to read property "rowid" on null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/lib/functions.lib.php(9788) : eval()'d code on line 1" while reading upstream, client: 172.17.0.2, server: dolibarr.grif, request: "GET /adherents/card.php?rowid=350&save_lastsearch_values=1 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-dolibarr.sock:", host: "dolibarr.grif", referrer: "https://dolibarr.grif/"
2024/08/31 20:04:59 [error] 13069#13069: *3417218 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to read property "rowid" on null in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/lib/functions.lib.php(9788) : eval()'d code on line 1; PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method stdClass::_load_ldap_info() in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php:514
Stack trace:
#0 /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/interfaces.class.php(187): InterfaceLdapsynchro->runTrigger()
#1 /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/class/commonobject.class.php(6025): Interfaces->run_triggers()
#2 /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/adherents/class/adherent.class.php(949): CommonObject->call_trigger()
#3 /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/adherents/card.php(373): Adherent->update()
#4 {main}
  thrown in /var/www/localhost/htdocs/dolibarr-19.0.2/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php on line 514" while reading response header from upstream, client: 172.17.0.2, server: dolibarr.grif, request: "POST /adherents/card.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-dolibarr.sock:", host: "dolibarr.grif", referrer: "https://dolibarr.grif/"
IC-Mathieu commented 1 day ago

Hi, I've tested in a 19.0.2 and 21.0.0 beta above on a clean Dolibarr but I can't manage to replicate the bug you're mentioning maybe you have external module with trigger

alarig commented 23 hours ago

All the activated modules are those shipped in the tarball.

alarig commented 20 hours ago

I upgraded to the latest release and the bug is still there:

2024/11/15 20:25:59 [error] 25694#25694: *30503182 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to read property "rowid" on null in /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/core/lib/functions.lib.php(10448) : eval()'d code on line 1; PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method stdClass::_load_ldap_info() in /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php:515
Stack trace:
#0 /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/core/class/interfaces.class.php(193): InterfaceLdapsynchro->runTrigger()
#1 /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/core/class/commonobject.class.php(6128): Interfaces->run_triggers()
#2 /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/adherents/class/adherent.class.php(981): CommonObject->call_trigger()
#3 /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/adherents/card.php(375): Adherent->update()
#4 {main}
  thrown in /var/www/localhost/htdocs/dolibarr-20.0.2/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php on line 515" while reading response header from upstream, client: 192.168.5.1, server: dolibarr.grif, request: "POST /adherents/card.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm-dolibarr.sock:", host: "dolibarr.grif", referrer: "https://dolibarr.grif/adherents/card.php?rowid=350&action=edit&token=e88994371518f61dd1c3483dec6c8dfc"

I enabled the debug logs and the last lines are

2024-11-15 19:25:59 DEBUG   192.168.5.1       17256    121  Ldap::connectBind this->connection is ok
2024-11-15 19:25:59 DEBUG   192.168.5.1       17256    121  Ldap::connectBind try bindauth on ldaps://ldap01.grif user=blah
2024-11-15 19:25:59 DEBUG   192.168.5.1       17256    121  Ldap::connectBind 2
2024-11-15 19:25:59 ERR     192.168.5.1       17256    121  DoliDBMysqli::close Closing a connection with an opened transaction depth=1

So it narrows the bug to https://github.com/Dolibarr/dolibarr/blob/20.0.2/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php#L512

I guess that this clone should be outside of the if, as it was the case with https://github.com/Dolibarr/dolibarr/pull/480

alarig commented 19 hours ago

So, just to be clear: this issue isn’t closed at all

IC-Mathieu commented 18 hours ago

Sorry i don't see you have module LDAP activate, Try to deactivate this module and update your adherent for testing