From fc63599d52b0baa5099682f445f625f4d123169d Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:03:57 +0100 Subject: [PATCH 1/2] Fix UpdateField with PostgreSQL --- htdocs/core/db/pgsql.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 069afeca4ff..3676eaf63ee 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1183,7 +1183,7 @@ class DoliDBPgsql extends DoliDB $sql = "ALTER TABLE ".$table." ADD ".$field_name." "; $sql .= $field_desc['type']; if (preg_match("/^[^\s]/i", $field_desc['value'])) { - if (!in_array($field_desc['type'], array('int', 'date', 'datetime')) && $field_desc['value']) { + if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) { $sql .= "(".$field_desc['value'].")"; } } @@ -1225,9 +1225,11 @@ class DoliDBPgsql extends DoliDB { // phpcs:enable $sql = "ALTER TABLE ".$table; - $sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type']; - if (in_array($field_desc['type'], array('double', 'varchar')) && $field_desc['value']) { - $sql .= "(".$field_desc['value'].")"; + $sql .= ' ALTER COLUMN "'.$field_name.'" TYPE '.$field_desc['type']; + if (preg_match("/^[^\s]/i", $field_desc['value'])) { + if (!in_array($field_desc['type'], array('smallint', 'int', 'date', 'datetime')) && $field_desc['value']) { + $sql .= "(".$field_desc['value'].")"; + } } if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL') { From f28405f7a99266aa0609c48280152b3fa66f5dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 21 Mar 2023 13:54:47 +0100 Subject: [PATCH 2/2] fix warning Undefined variable $now in htdocs\core\boxes\box_members_by_tags.php:222 --- htdocs/core/boxes/box_members_by_tags.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index d4e78f7efe9..6341fb9f899 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2015-2023 Frédéric France * Copyright (C) 2021-2022 Waël Almoman * * This program is free software; you can redistribute it and/or modify @@ -87,6 +87,7 @@ class box_members_by_tags extends ModeleBoxes include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $staticmember = new Adherent($this->db); + $now = dol_now(); $year = date('Y'); $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH");