Installing dolibarr 14.0.4 with php 8.1.1 (deprecated strftime)

Hi! Happy new year!

We have found a deprecated message installing the 14v with php 8.1.1

Deprecated : Function strftime() is deprecated in /var/www/html/core/modules/syslog/mod_syslog_file.php on line 176

We have created a small patch to fix it… Enjoy it!!!

Processing: mod_syslog_file.patch…
mod_syslog_file.txt (857 Bytes)

Hello,

Thank you but you will have a lot more than this one. Dolibarr V14 is not compatible php V8

Hi!

It works fine with php 8.1.1 for me
I use official docker image in production mode.

This is an example of dockerfile

FROM php:8.1.1-apache

RUN \
  apt-get update && \
  apt-get install -y libzip-dev zlib1g-dev libpng-dev libonig-dev libicu-dev

RUN docker-php-ext-install calendar mysqli gd zip mbstring intl

ENV dolibarr_version 14.0.4

COPY dolibarr-${dolibarr_version}.tgz /tmp
RUN tar -xzf /tmp/dolibarr-${dolibarr_version}.tgz -C /var/www/html --strip 2 dolibarr-14.0.4/htdocs
RUN rm /tmp/dolibarr-${dolibarr_version}.tgz

COPY patch/mod_syslog_file.patch /tmp
RUN patch /var/www/html/core/modules/syslog/mod_syslog_file.php < /tmp/mod_syslog_file.patch
RUN rm /tmp/*.patch

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN chown -R www-data.www-data /var/www/html

i have the same issue with the date / time stamp

but how to fix this with patch , im new with php.

Hello,

if you want to use Dolibarr in a production environment (i.e. not just for testing), it is strongly recommended to use a version of php which is in the recommended range. For current releases this is between version 5.6 and 7.4.

Run this command.

patch /var/www/html/core/modules/syslog/mod_syslog_file.php < [patch file name]

Thank you for your comment.
But…

Active support for php 7.4 ended on Nov 28, 2021, and security patches will be discontinued on Nov 28, 2022. https://www.php.net/supported-versions.php

So I can take the risk that there is a small bug in php 8, compared to having a serious security problem due to old software.

Dolibarr V15 will be compatible PHP V8, should be out end of this month

This is Great!!!

Thank you!

sorry for the question, run from where

Hi, no problem.

You should execute this command inside your linux server.

Another possibility, you could change manually the file core/modules/syslog/mod_syslog_file.php changing the line:

$message = strftime("%Y-%m-%d %H:%M:%S", time()).$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ?str_pad('', $this->ident, ' ') : '').$content['message'];

by the new

$message = date("Y-m-d H:i:s", time()).$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ?str_pad('', $this->ident, ' ') : '').$content['message'];

i did changeline but not changed any thing