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

V18.0.4 turning on debug module crashes Dolibarr with Fatal error: Uncaught Error: Undefined constant "DOL_DATA_ROOT/dolibarr.log" #27280

Open
dleigh opened this issue Jan 2, 2024 · 3 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@dleigh
Copy link

dleigh commented Jan 2, 2024

Bug

I had the debug log on under PHP 7.4, Dolibar v15. Upgrading to v18.0.4 and then moving to PHP v8.1 created the crash (home directory redacted):

`
Fatal error: Uncaught Error: Undefined constant "DOL_DATA_ROOT/dolibarr.log" in
/home//sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php:120 Stack trace: #0
/home/
/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php(120): constant() #1
/home//sites/doliUSA/core/lib/functions.lib.php(1876): mod_syslog_syslog->export() #2
/home/
/sites/doliUSA/main.inc.php(973): dol_syslog() #3
/home//sites/doliUSA/admin/modules.php(37): require('
/home/
/si...') #4 {main} thrown in
/home/********/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php on line 120

Fatal error: Uncaught Error: Undefined constant "DOL_DATA_ROOT/dolibarr.log" in
/home//sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php:120 Stack trace: #0
/home/
/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php(120): constant() #1
/home//sites/doliUSA/core/lib/functions.lib.php(1876): mod_syslog_syslog->export() #2
/home/
/sites/doliUSA/core/lib/functions.lib.php(502): dol_syslog() #3 [internal function]: dol_shutdown() #4 {main} thrown in
/home/********/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php on line 120`

If I have just "File" logging enabled it seems to be fine, but with "syslogd" enabled the crash occurs.

Environment Version

18.0.4

Environment OS

Linux citron.o2switch.net 4.18.0-425.19.2.lve.el7h.x86_64 #1 SMP Thu Apr 6 13:40:55 UTC 2023 x86_64

Environment Web server

Apache 2.4.58

Environment PHP

8.1

Environment Database

10.6.16-MariaDB

Environment URL(s)

https://davidolius.leighweb.com

Expected and actual behavior

I would expect that it wouldn't crash.

Steps to reproduce the behavior

Have the syslogd checked in the log module and then change the PHP version to 18.0.4

Attached files

No response

@dleigh dleigh added the Bug This is a bug (something does not work as expected) label Jan 2, 2024
@mdeweerd
Copy link
Contributor

I suppose that the value for the SYSLOG_FACILITY is not set to a correct value (one out of the facilities found here https://www.php.net/manual/en/function.openlog.php ).

image

I suggest that you verify what you have on your page https://davidolius.leighweb.com/admin/syslog.php .

I suspect that my "/custom" value is also invalid - you can try to set LOG_USER which is the default when the value is not set.

@dleigh
Copy link
Author

dleigh commented Feb 6, 2024

From: https://www.php.net/manual/en/function.openlog.php, I tried LOG_SYSLOG for syslogd, but that returned:

Fatal error: Uncaught Error: Undefined constant "DOL_DATA_ROOT/LOG_SYSLOG" in /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php:90 Stack trace: #0 /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php(90): constant() #1 /home/dleigh/sites/doliUSA/admin/syslog.php(119): mod_syslog_syslog->checkConfiguration() #2 {main} thrown in /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php on line 90

Then I tried LOG_USER and that returned: Fatal error: Uncaught Error: Undefined constant "DOL_DATA_ROOT/LOG_USER" in /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php:90 Stack trace: #0 /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php(90): constant() #1 /home/dleigh/sites/doliUSA/admin/syslog.php(119): mod_syslog_syslog->checkConfiguration() #2 {main} thrown in /home/dleigh/sites/doliUSA/core/modules/syslog/mod_syslog_syslog.php on line 90

If I uncheck the syslogd, then I'm ok. Perhaps it's my environment?

@mdeweerd
Copy link
Contributor

mdeweerd commented Feb 6, 2024

As I understand from the code (line 90), the global setting would have to provide the value "DOL_DATA_ROOT/LOG_USER" in your case, while before it provided "DOL_DATA_ROOT/dolibarr.log" so the impact went in the right direction. Question is now, how did DOL_DATA_ROOT/ get prefixed.

https://github.com/Dolibarr/dolibarr/blob/18.0.4/htdocs/core/modules/syslog/mod_syslog_syslog.php#L84-L103

You could check the llx_const table in the database for the SYSLOG_FACILITY value to check that it is only LOG_USER or already DOL_DATA_ROOT/LOG_USER - in the latter case, you could change it to LOG_USER. It does not fix the root cause, but you could already validate that the DB entry is valid or invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

2 participants