backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Undefined constant "LOG_LOCAL0" in system_update_1017()

Open docwilmot opened this issue 11 months ago • 4 comments

Description of the bug

On Windows, when doing a Drupal to Backdrop upgrade, I get this error. The line mentioned is $config->set('log_facility', update_variable_get('syslog_facility', LOG_LOCAL0)); LOG_LOCAL0 is not defined in Windows. In D7, in the place the syslog_facility variable is accessed, there is a check for if its defined. We missed this in Backdrop.

Steps To Reproduce

Uncertain; I get the error on WampServer on Windows 11. I dont think I have always had this error, so not sure if something about my current setup may be to blame.

In either case, we should fix this.

docwilmot avatar Mar 21 '24 22:03 docwilmot

@docwilmot unfortunately I'm not much of a help here - have no Windows install available. :shrug: (Not sorry :wink:)

But I'd like to suggest to simply set log_facility to an empty string. In "normal" Backdrop installs it's an empty string, in the D7 installs I checked, syslog_facility isn't set at all (variable doesn't exist).

I belief, it's a bug that this gets set to LOG_LOCAL0 in system_update_1017 (as fallback), and also shouldn't get set to LOG_USER. Or am I missing something?

indigoxela avatar Mar 22 '24 12:03 indigoxela

@indigoxela I think an empty string is the correct thing, in fact. Thanks, will change.

docwilmot avatar Mar 22 '24 13:03 docwilmot

Quick one, RTBC anyone?

docwilmot avatar Apr 14 '24 15:04 docwilmot

I checked the default value for log_facility in the system.core.json file. Effectively, it is an empty string.

It makes sense to use an empty string as default value also when migrating from a Drupal 7 site.

avpaderno avatar Apr 15 '24 08:04 avpaderno

Thanks @docwilmot, @indigoxela, and @kiamlaluno! This is a good fix. Avoiding constants when in update hooks is a good idea anyway, since often .module files are not loaded that may be needed for defining the constant. And like @kiamlaluno pointed out, it needs to be an actual value (even if it's an empty string) when it's written to config anyway.

I merged https://github.com/backdrop/backdrop/pull/4681 into 1.x and 1.27.x. Thanks folks!

quicksketch avatar Apr 26 '24 01:04 quicksketch

I'm not 100% onboard with this change here. It is OK as a temporary quick workaround (to stop errors during D7 to Backdrop updates), but not ideal. I have filed #6477 as a follow up to clean things up and fix this in a more appropriate manner.

klonos avatar Apr 26 '24 09:04 klonos