From 8cfb183152a35db97c1daf7c5851c0db533a887c Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Tue, 21 Nov 2023 18:49:33 +0100 Subject: [PATCH 1/2] discount: add errorsToString() $localobject->errorsToString() is available in most objects using $db or other systems generating errors because they inherit from CommonObject. However, DiscountAbsolute didn't inherit from it. Extending CommonObject allows to implement the usual behaviour for core objects like referencing the user doing the action. --- htdocs/core/class/discount.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index abb82dd9e2e..65d1471f456 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2024 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,11 +23,12 @@ * \brief File of class to manage absolute discounts */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * Class to manage absolute discounts */ -class DiscountAbsolute +class DiscountAbsolute extends CommonObject { /** * @var DoliDB Database handler. From e3e2dd348dcf5f9a639c995a64834f2ae053e946 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Fri, 5 Jan 2024 14:55:00 +0100 Subject: [PATCH 2/2] discount: remove now duplicated fields Now that DiscountAbsolute is a CommonObject, some fields are duplicated in the definition of the class and already defined in the CommonObject class. --- htdocs/core/class/discount.class.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 65d1471f456..029bbbab5a8 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -30,26 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class DiscountAbsolute extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error; - - /** - * @var string[] Array of error strings - */ - public $errors = array(); - - /** - * @var int ID discount - */ - public $id; - /** * @var int Thirdparty ID * @deprecated