Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add items to invoice unter PHP8.0 and 8.1 #23339

Open
will2877 opened this issue Dec 26, 2022 · 7 comments
Open

Can't add items to invoice unter PHP8.0 and 8.1 #23339

will2877 opened this issue Dec 26, 2022 · 7 comments
Labels
Bug need more information This bug needs more information to be processed

Comments

@will2877
Copy link

Bug

I setup a new instance of Dolibarr 16.0 and tried to create an invoice.
The part to add positions doesn't appear for some reason.
If I switch to PHP7.4 it works fine.

I had the same issue on a long running Dolibarr 14.0.5.

Environment Version

16.0.3 & 14.0.5

Environment OS

freeBSD

Environment Web server

Apache

Environment PHP

8.0 & 8.1

Environment Database

MariaDB

Environment URL(s)

No response

Expected and actual behavior

No response

Steps to reproduce the behavior

No response

Attached files

No response

@will2877 will2877 added the Bug This is a bug (something does not work as expected) label Dec 26, 2022
@milenmk
Copy link
Contributor

milenmk commented Dec 28, 2022

V16 doesn't support fully PHP8. Try with PHP 7.4 OR look at your Dolibarr log and post the error here.

@ksar-ksar
Copy link
Contributor

Hello,

Could you send us the error.log from Apache ?

@ksar-ksar ksar-ksar added Bug need more information This bug needs more information to be processed and removed Bug This is a bug (something does not work as expected) labels Jan 2, 2023
@will2877
Copy link
Author

will2877 commented Jan 2, 2023

stderr: PHP Fatal error: Uncaught ValueError: Missing format specifier at end of string in /core/class/translate.class.php:641
stderr: Stack trace:
stderr: #0 /home/z/www/x/erp/public/core/class/translate.class.php(641): sprintf('%', '', '', '', '')
stderr: #1 /home/z/www/x/erp/public/core/tpl/objectline_create.tpl.php(136): Translate->trans('ReductionShort')
stderr: #2 /home/z/www/x/erp/public/core/class/commonobject.class.php(4837): include('/home/awegeduz/...')
stderr: #3 /home/z/www/x/erp/public/compta/facture/card.php(5365): CommonObject->formAddObjectLine(1, Object(Societe), Object(Societe))
stderr: #4 {main}
stderr: thrown in /home/z/www/x/erp/public/core/class/translate.class.php on line 641

@nydeggerm
Copy link

nydeggerm commented Jul 14, 2023

Same here. I'm Swiss German and found the source of the problem: "ReductionShort" and "ReductionsShort" ist not translated and contains an "%"
I guess this happens also in other languages. I haven't checked them.

Swiss German: "ReductionShort" and "ReductionsShort" must be "Rabatt"

ReductionShort=%

ReductionsShort=%

German:

ReductionShort=Rabatt

ReductionsShort=Rabatt

Workaround:
I've changed the two strings it manually in my Dolibarr installation via web GUI on the page /admin/translation.php and the error disappeared.

@emheyarssi
Copy link
Contributor

emheyarssi commented Jul 14, 2023

This should be fixed in Transifex, not directly in source code.
Is ok as a quick fix but a next update the file will be overwrited.

@n15c
Copy link
Contributor

n15c commented Aug 8, 2023

Had the same issue under Dolibarr 17.0.3 after switching to PHP 8.x

@sarusani
Copy link

sarusani commented Jan 29, 2024

The problem is not that the string is not translated correctly. The current translation "%" (Prozent) is a perfectly valid short translation of the word Rabatt.

The problem is that Dolibarr can't handle a string when it contains a single %. This should not be fixed in Transifex, it should be handled correctly in translate.class.php.

(In PHP7 sprintf() returned false when a error occured. In PHP8 it returns a ValueError. Hence the different behavior.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug need more information This bug needs more information to be processed
Projects
None yet
Development

No branches or pull requests

7 participants