From 8e82bb71482f12e28de447b7c01179d8d021e4a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Dec 2022 02:00:31 +0100 Subject: [PATCH 1/4] Clean code --- htdocs/adherents/card.php | 2 +- htdocs/product/card.php | 4 ++-- htdocs/societe/card.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 56e7868ec5a..9d0677a2fc9 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -565,7 +565,7 @@ if (empty($reshook)) { } if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); - setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); } $public = 0; if (isset($public)) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 173c96fd297..2bfe94f418a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -541,7 +541,7 @@ if (empty($reshook)) { if ($result < 0) { $error++; $mesg = 'Failed to get bar code type information '; - setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); + setEventMessages($mesg.$stdobject->error, $stdobject->errors, 'errors'); } $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; @@ -780,7 +780,7 @@ if (empty($reshook)) { if ($result < 0) { $error++; $mesg = 'Failed to get bar code type information '; - setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); + setEventMessages($mesg.$stdobject->error, $stdobject->errors, 'errors'); } $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index a7389c8949c..cb2b101307b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -570,11 +570,11 @@ if (empty($reshook)) { if (!empty($object->email) && !isValidEMail($object->email)) { $langs->load("errors"); $error++; - setEventMessages('', $langs->trans("ErrorBadEMail", $object->email), 'errors'); + setEventMessages($langs->trans("ErrorBadEMail", $object->email), null, 'errors'); } if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); - setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); } if (!empty($object->webservices_url)) { //Check if has transport, without any the soap client will give error From 3dfe09d1fee35d1de40411f6023d4b6d4b72c869 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Dec 2022 01:58:13 +0100 Subject: [PATCH 2/4] Fix doxygen --- htdocs/core/class/ldap.class.php | 8 ++++---- .../core/modules/stocktransfer/doc/pdf_eagle.modules.php | 2 +- .../mymodule/doc/pdf_standard_myobject.modules.php | 2 +- .../doc/pdf_standard_recruitmentjobposition.modules.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 011d8a380ef..3dc45c753bc 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1239,10 +1239,10 @@ class Ldap /** * Load all attribute of a LDAP user * - * @param User $user User to search for. Not used if a filter is provided. - * @param string $filter Filter for search. Must start with &. - * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) - * @return int >0 if OK, <0 if KO + * @param User|string $user Not used. + * @param string $filter Filter for search. Must start with &. + * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) + * @return int >0 if OK, <0 if KO */ public function fetch($user, $filter) { diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 22601d93dae..35a52f35bd8 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -895,7 +895,7 @@ class pdf_eagle extends ModelePdfStockTransfer /** * Show top header of page. * - * @param PDF $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index bd5348b1566..05486989e1d 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -879,7 +879,7 @@ class pdf_standard_myobject extends ModelePDFMyObject /** * Show top header of page. * - * @param Tcpdf $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 94e93c87baa..f4d2226d51d 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -798,7 +798,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio /** * Show top header of page. * - * @param Tcpdf $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output From b8092f1eae50f0bd987426564e6ad1930ca4ed77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Dec 2022 01:58:13 +0100 Subject: [PATCH 3/4] Fix doxygen and warnings --- htdocs/admin/modules.php | 4 ++-- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/modules/modHoliday.class.php | 4 ---- htdocs/fourn/commande/list.php | 2 +- .../class/api_knowledgemanagement.class.php | 2 +- htdocs/product/class/api_products.class.php | 6 +++--- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 93eb5524a1d..46b711875b8 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -844,10 +844,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } } else { $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a9c17a2edba..3f4579340d0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7720,7 +7720,7 @@ class Form } } if (!is_object($objecttmp)) { - dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING); + dol_syslog('Error bad setup of type for field '.join(',', $InfoFieldList), LOG_WARNING); return 'Error bad setup of type for field '.join(',', $InfoFieldList); } @@ -9870,7 +9870,7 @@ class Form method: "POST", dataType: "json", data: { fk_c_exp_tax_cat: $(this).val(), token: \''.currentToken().'\' }, - url: "'.(DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php?'.$params).'", + url: "'.(DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php?'.join('&', $params)).'", }).done(function( data, textStatus, jqXHR ) { console.log(data); if (typeof data.up != "undefined") { diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 61bdc0e8f98..57ffe62e005 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -78,10 +78,6 @@ class modHoliday extends DolibarrModules // Config pages $this->config_page_url = array("holiday.php"); - - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); - // Dependencies $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3d458247bcf..3080a184abb 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1208,7 +1208,7 @@ if ($resql) { include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } if ($massaction == 'createbills') { diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index ccf54b1d6d9..8232287b23b 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -114,7 +114,7 @@ class KnowledgeManagement extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve category list : '.array_merge(array($categories->error), $categories->errors)); + throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors))); } return $result; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 76ee11f727e..7a10293d7e4 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -595,7 +595,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve category list : '.array_merge(array($categories->error), $categories->errors)); + throw new RestException(503, 'Error when retrieve category list : '.join(',', array_merge(array($categories->error), $categories->errors))); } return $result; @@ -628,7 +628,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); + throw new RestException(503, 'Error when retrieve prices list : '.join(',', array_merge(array($this->product->error), $this->product->errors))); } return array( @@ -719,7 +719,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); + throw new RestException(503, 'Error when retrieve prices list : '.join(',', array_merge(array($this->product->error), $this->product->errors))); } return array( From 32c161e576f40ab4100f9d35200528a7ed7ab486 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Dec 2022 12:10:23 +0100 Subject: [PATCH 4/4] Fix warnings --- htdocs/accountancy/class/accountancycategory.class.php | 4 ++-- htdocs/api/index.php | 4 ++-- htdocs/blockedlog/class/authority.class.php | 2 +- htdocs/core/class/dolgeoip.class.php | 4 ++-- htdocs/emailcollector/class/emailcollector.class.php | 2 +- htdocs/mailmanspip/class/mailmanspip.class.php | 8 +++----- htdocs/product/class/html.formproduct.class.php | 6 ++---- htdocs/webservices/server_productorservice.php | 2 +- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 300ccff9c09..e6c4ff45922 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -446,7 +446,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -488,7 +488,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 085dd338e69..ba195b82c08 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -413,9 +413,9 @@ $result = $api->r->handle(); if (Luracast\Restler\Defaults::$returnResponse) { // We try to compress the data received data - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress') && defined('BROTLI_TEXT')) { header('Content-Encoding: br'); - $result = brotli_compress($result, 11, BROTLI_TEXT); + $result = brotli_compress($result, 11, constant('BROTLI_TEXT')); } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { header('Content-Encoding: bz'); $result = bzcompress($result, 9); diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 7240aaf0151..0b665fedc3e 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -304,7 +304,7 @@ class BlockedLogAuthority $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = getURLContent($url); - echo $block->signature.' '.$url.' '.$res.'
'; + echo $block->signature.' '.$url.' '.$res['content'].'
'; if ($res === 'blockalreadyadded' || $res === 'blockadded') { $block->setCertified(); } else { diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index b4218bbfd40..24726fec7c3 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -86,8 +86,8 @@ class DolGeoIP dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); return 0; } - } elseif (function_exists('geoip_open')) { - $this->gi = geoip_open($datfile, GEOIP_STANDARD); + } elseif (function_exists('geoip_open') && defined('GEOIP_STANDARD')) { + $this->gi = geoip_open($datfile, constant('GEOIP_STANDARD')); } elseif (function_exists('geoip_country_code_by_name')) { $this->gi = 'NOGI'; // We are using embedded php geoip functions //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 8d72666ad53..4d7ef042e69 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2305,7 +2305,7 @@ class EmailCollector extends CommonObject 'class' => 'compta/facture/class/facture.class.php', 'object' => 'Facture'), 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', ref_client), + 'fields' => array('ref', 'ref_client'), 'class' => 'fourn/class/fournisseur.facture.class.php', 'object' => 'FactureFournisseur'), 'produit' => array('table' => 'product', diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index bcfb1b83d6e..46701a459a6 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -77,7 +77,7 @@ class MailmanSpip */ public function isSpipEnabled() { - if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) { + if (getDolGlobalInt("ADHERENT_USE_SPIP") == 1) { return true; } @@ -91,10 +91,8 @@ class MailmanSpip */ public function checkSpipConfig() { - if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) { - if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') { - return true; - } + if (getDolGlobalString('ADHERENT_SPIP_SERVEUR') != '' && getDolGlobalString('ADHERENT_SPIP_USER') != '' && getDolGlobalString('ADHERENT_SPIP_PASS') != '' && getDolGlobalString('ADHERENT_SPIP_DB') != '') { + return true; } return false; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 75a929f53e5..b4da53f4635 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -781,9 +781,7 @@ class FormProduct */ public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array()) { - global $conf, $langs; - - dol_syslog(get_class($this)."::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot,$objectLines", LOG_DEBUG); + dol_syslog(get_class($this)."::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot", LOG_DEBUG); $out = ''; $productIdArray = array(); @@ -817,7 +815,7 @@ class FormProduct if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { $label = $arraytypes['entrepot_label'] . ' - '; $label .= $arraytypes['batch']; - $out .= ''; + $out .= ''; } } } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 25eeec6430f..bf46b063e64 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -962,7 +962,7 @@ function getListOfProductsOrServices($authentication, $filterproduct) * Get list of products for a category * * @param array $authentication Array of authentication information - * @param array $id Category id + * @param int $id Category id * @param Translate $lang Force lang * @return array Array result */