From 3119d77565ba8f37292053b6117cb95cd271a693 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2016 16:36:48 +0200 Subject: [PATCH] Add warning on deprecated param --- htdocs/categories/class/categorie.class.php | 13 +++++-------- htdocs/core/class/html.form.class.php | 8 +++++++- htdocs/core/class/html.formother.class.php | 8 +++++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b602bc0076d..672ea7b6408 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -48,14 +48,13 @@ class Categorie extends CommonObject const TYPE_CUSTOMER = 2; const TYPE_MEMBER = 3; const TYPE_CONTACT = 4; - const TYPE_USER = 4; // categorie contact and user are same - // bank account - const TYPE_ACCOUNT = 5; + const TYPE_USER = 4; // categorie contact and user are same ! + const TYPE_ACCOUNT = 5; // bank account /** * @var array ID mapping from type string * - * @note Move to const array when PHP 5.6 will be our minimum target + * @note This array should be remove in future, once previous constants are moved to the string value. */ private $MAP_ID = array( 'product' => 0, @@ -1274,14 +1273,12 @@ class Categorie extends CommonObject * Should be named getListOfCategForObject * * @param int $id Id of element - * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode - * (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category * labels, 'id'= Get array of category IDs - * * @return mixed Array of category objects or < 0 if KO */ - function containing($id,$type,$mode='object') + function containing($id, $type, $mode='object') { $cats = array(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dcf593e6ccd..70a4738366d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3145,7 +3145,7 @@ class Form /** * Return list of categories having choosed type * - * @param int $type Type de categories (0=product, 1=supplier, 2=customer, 3=member) + * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element) * @param string $htmlname HTML field name * @param int $maxlength Maximum length for labels @@ -3161,6 +3161,12 @@ class Form include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + } + $cat = new Categorie($this->db); $cate_arbo = $cat->get_full_arbo($type,$excludeafterid); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index f446caa12a2..3664424764d 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -302,7 +302,7 @@ class FormOther /** * Return select list for categories (to use in form search selectors) * - * @param int $type Type of categories (0=product, 1=supplier, 2=customer, 3=member, 4=contact) + * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" @@ -315,6 +315,12 @@ class FormOther global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + // For backward compatibility + if (is_numeric($type)) + { + dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); + } + // Load list of "categories" $static_categs = new Categorie($this->db); $tab_categs = $static_categs->get_full_arbo($type);