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

Uncaught TypeError: Unsupported operand types: string / int (societe.class.php:2370) #26205

Open grti-fr opened 1 year ago

grti-fr commented 1 year ago

Bug

I can't add "absolute discount" (remise fixe) because of an error 500.

Similar to #23713

The problem occurs in all of my Dolibarr instances, even in my fresh install from 18.0.1

Error in PHP logs :

Uncaught TypeError: Unsupported operand types: string / int in /htdocs/societe/class/societe.class.php:2370
Stack trace:
#0 /htdocs/comm/remx.php(180): Societe->set_remise_except()
#1 {main}
  thrown in /home/htdocs/societe/class/societe.class.php on line 2370

Environment Version

18.0.1, 18.0.2

Environment OS

o2switch

Environment Web server

No response

Environment PHP

8.1.23

Environment Database

mysql

Environment URL(s)

No response

Expected and actual behavior

No response

Steps to reproduce the behavior

Try to add an absolute discount for a customer

Attached files

No response

eluos commented 1 year ago

Getting the same error on Dolibarr v18.0.2 when adding a new currency.

Fatal error: Uncaught TypeError: Unsupported operand types: string + int in X:------------\htdocs\admin\dict.php:863 Stack trace: #0 {main} thrown in X:-------\htdocs\admin\dict.php on line 863

AurelienBISOTTI commented 1 year ago

Many functions are affected.

The bug only appears on PHP8 instances + Dolibarr v18 (I didn’t notice it elsewhere)

I’ve found two solutions:

Edit : also submited a fix in code. Waiting for approval

Lovinity commented 1 year ago

Many functions are affected.

The bug only appears on PHP8 instances + Dolibarr v18 (I didn’t notice it elsewhere)

I’ve found two solutions:

  • Remain in PHP8 and fill in all form fields (put 0 instead of an empty field)
  • Downgrade to PHP7

Edit : also submited a fix in code. Waiting for approval

FYI the first workaround above does not work when adding an absolute discount. A downgrade to PHP 7 is necessary in that case unless you are able to manually add entries into the database (not recommended especially for log keeping).

grti-fr commented 1 year ago

Thank you all for your replies. I've downgraded PHP to 7.4 and it works fine again.

nealjoos commented 6 months ago

Same error here on Dolibarr version 19.0.2 using PHP version 8.1.28 when adding an absolute discount. Is there a solution other than downgrading to PHP 7?

gertvermeersch commented 4 months ago

Ran into this issue today on 19.0.2 as well.