From 5451bef0f710dda77297f17d22f6038f97c927f1 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 13:58:19 +0200 Subject: [PATCH 01/10] scrutinizer CMailFile: undeclared variable --- htdocs/core/class/CMailFile.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index ba657f58087..b3ff0aae930 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -878,7 +878,11 @@ class CMailFile $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); + if (isset($supportedoauth2array)) { + $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); + } else { + $OAUTH_SERVICENAME = 'Unknown'; + } require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; From 349e33592db873c055a5ffb9bd20e112bd76c023 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 14:09:58 +0200 Subject: [PATCH 02/10] scrutinizer in accountancy/class/accountingaccount.class.php: variable not always defined --- .../class/accountingaccount.class.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index bf487d47c2c..95296624145 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -811,9 +811,9 @@ class AccountingAccount extends CommonObject $suggestedaccountingaccountfor = ''; if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code))) { // If buyer in same country than seller (if not defined, we assume it is same country) - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; @@ -821,36 +821,36 @@ class AccountingAccount extends CommonObject } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with VAT - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; $suggestedaccountingaccountfor = 'eecwithvat'; } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number - if ($type=='customer' && !empty($product->accountancy_code_sell)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell)) { $code_p = $product->accountancy_code_sell; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy)) { $code_p = $product->accountancy_code_buy; } $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { // European intravat sale - if ($type=='customer' && !empty($product->accountancy_code_sell_intra)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell_intra)) { $code_p = $product->accountancy_code_sell_intra; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy_intra)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_intra)) { $code_p = $product->accountancy_code_buy_intra; } $suggestedid = $accountingAccount['intra']; $suggestedaccountingaccountfor = 'eec'; } else { // Foreign sale - if ($type=='customer' && !empty($product->accountancy_code_sell_export)) { + if ($type == 'customer' && !empty($product->accountancy_code_sell_export)) { $code_p = $product->accountancy_code_sell_export; - } elseif ($type=='supplier' && !empty($product->accountancy_code_buy_export)) { + } elseif ($type == 'supplier' && !empty($product->accountancy_code_buy_export)) { $code_p = $product->accountancy_code_buy_export; } $suggestedid = $accountingAccount['export']; @@ -870,12 +870,12 @@ class AccountingAccount extends CommonObject // Manage Deposit if ($factureDet->desc == "(DEPOSIT)" || $facture->type == $facture::TYPE_DEPOSIT) { $accountdeposittoventilated = new self($this->db); - if ($type=='customer') { + if ($type == 'customer') { $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); - } elseif ($type=='supplier') { + } elseif ($type == 'supplier') { $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT, 1); } - if ($result < 0) { + if (isset($result) && $result < 0) { return -1; } From 034da214c01298281684ac5de01cc0b0307baec8 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 14:14:15 +0200 Subject: [PATCH 03/10] scrutinizer in takepos/send.php : string[] implicitely converted to a boolean --- htdocs/takepos/send.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 2003abaf1f1..918c218ad95 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -85,7 +85,7 @@ if ($action == "send") { $sendto = $email; $from = $mysoc->email; $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1); - if ($mail->error || $mail->errors) { + if ($mail->error || !empty($mail->errors)) { setEventMessages($mail->error, $mail->errors, 'errors'); } else { $result = $mail->sendfile(); From cabfc61ba3fb3f569d4d49ed89f2b3d32ec6b6d2 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 14:39:36 +0200 Subject: [PATCH 04/10] scrutinizer in bookmarks/bookmarks.lib.php: variable $Bookmark not defined for all paths --- htdocs/bookmarks/bookmarks.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 2abd90cf538..df42b8942a5 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -89,6 +89,7 @@ function printDropdownBookmarksList() $listbtn = ''; $listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').''; + $bookmarkList = ''; // Menu with list of bookmarks $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; From 1c561b75f0cc104db99a706a341946d09107c397 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 15:20:00 +0200 Subject: [PATCH 05/10] scrutinizer in holiday/card_group.php: doc of function sendMail incomplete --- htdocs/holiday/card_group.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index de10c3d72f6..8ebddf045a7 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -657,10 +657,12 @@ if (is_object($db)) { } /** * send email to validator for current leave represented by (id) - * @param $id validator for current leave represented by (id) - * @param $cancreate flag for user right - * @param $now date - * @param $autoValidation boolean flag on autovalidation + * + * @param int $id validator for current leave represented by (id) + * @param int $cancreate flag for user right + * @param int $now date + * @param int $autoValidation boolean flag on autovalidation + * * @return stdClass * @throws Exception */ From b66b71817c0c402b5d1994e13f2120d5ee955005 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 15:49:54 +0200 Subject: [PATCH 06/10] scrutinizer in core/lib/ftp.lib.php: $localpath never defiened for ftp_get, added it and modify consequently file where the function is called --- htdocs/core/lib/ftp.lib.php | 5 +++-- htdocs/ftp/index.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index 118c85e9b74..807bae63b0a 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -193,11 +193,12 @@ function dol_ftp_delete($connect_id, $file, $newsection) * Download a FTP file * * @param resource $connect_id Connection handler - * @param string $file File + * @param string $localfile The local file path + * @param string $file The remote file path * @param string $newsection $newsection * @return result */ -function dol_ftp_get($connect_id, $file, $newsection) +function dol_ftp_get($connect_id, $localfile, $file, $newsection) { global $conf; diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 857d41fc85b..6d06f501e8f 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -317,7 +317,7 @@ if ($action == 'download') { $newsection = $section; - $result = dol_ftp_get($connect_id, $file, $newsection); + $result = dol_ftp_get($connect_id, $localfile, $file, $newsection); if ($result) { From 44728ff93a9aac3484c98b0d8dd3add705fd1dfd Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 16:21:16 +0200 Subject: [PATCH 07/10] scrutinizer in core/class/notify.class.php : variable \labeltouse not defined for all paths --- htdocs/core/class/notify.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 3f26a98c728..b1e37ab1948 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -625,6 +625,8 @@ class Notify $mimefilename_list[] = $ref.".pdf"; } + $labeltouse = !empty($labeltouse) ? $labeltouse : ''; + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse); if (!isset($action)) { $action = ''; From 21274c94328b9df1f2e4be154adb1f0c2785089d Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 16:43:04 +0200 Subject: [PATCH 08/10] scrutinizer in core/class/html.formsetup.class.php: variable $valconst wasn't defined for all paths --- htdocs/core/class/html.formsetup.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index c2183653686..aef01514eba 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -758,6 +758,8 @@ class FormSetupItem $val = GETPOST($this->confKey, 'array'); if ($val && is_array($val)) { $val_const = implode(',', $val); + } else { + $val_const = ''; } } elseif ($this->type == 'html') { $val_const = GETPOST($this->confKey, 'restricthtml'); From 0819b04171e87b3a2c7a13aa4ac37d3faf14d26d Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 16:52:40 +0200 Subject: [PATCH 09/10] scrutinizer in asset/class/assetdepreciationoptions.class.php : variable $mode_info substituted by $field_info --- htdocs/asset/class/assetdepreciationoptions.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php index ce2ddd73c08..49efadca869 100644 --- a/htdocs/asset/class/assetdepreciationoptions.class.php +++ b/htdocs/asset/class/assetdepreciationoptions.class.php @@ -163,8 +163,8 @@ class AssetDepreciationOptions extends CommonObject } // Unset required option (notnull) if field disabled - if (!empty($mode_info['enabled_field'])) { - $info = explode(':', $mode_info['enabled_field']); + if (!empty($field_info['enabled_field'])) { + $info = explode(':', $field_info['enabled_field']); if ($this->deprecation_options[$info[0]][$info[1]] != $info[2] && isset($this->fields[$field_key]['notnull'])) { unset($this->fields[$field_key]['notnull']); } From 3cf7eda258f27160c207b981cd557a83e42a3cbb Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 10 Sep 2022 17:11:24 +0200 Subject: [PATCH 10/10] scrutinizer in core/modules/printing/printgcp.modules.php: var $printer_id not defined for all paths --- htdocs/core/modules/printing/printgcp.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 391f5b435d7..c04d3ac9ca5 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -332,6 +332,7 @@ class printing_printgcp extends PrintingDriver } $fileprint .= '/'.$file; $mimetype = dol_mimetype($fileprint); + $printer_id = ''; // select printer uri for module order, propal,... $sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$this->db->escape($module)."' AND driver='printgcp' AND userid=".((int) $user->id); $result = $this->db->query($sql);