diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 70c0cbc5d0c..828e537505d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -335,7 +335,7 @@ class Mailing extends CommonObject $sql .= ", evenunsubscribe = ".((int) $this->evenunsubscribe); $sql .= ", note_public = '".$this->db->escape($this->note_public)."'"; $sql .= ", note_private = '".$this->db->escape($this->note_private)."'"; - $sql .= ", fk_project = '".((int) $this->fk_project)."'"; + $sql .= ", fk_project = ".((int) $this->fk_project); $sql .= " WHERE rowid = ".(int) $this->id; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/comm/mailing/class/mailing_targets.class.php b/htdocs/comm/mailing/class/mailing_targets.class.php index b3c08cdc8f7..84321f4a71b 100644 --- a/htdocs/comm/mailing/class/mailing_targets.class.php +++ b/htdocs/comm/mailing/class/mailing_targets.class.php @@ -1,6 +1,7 @@ + * Copyright (C) 2026 MDW * * 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 @@ -408,16 +409,16 @@ class MailingTarget extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET fk_mailing = '".((int) $this->fk_mailing)."'"; - $sql .= ", fk_contact = '".((int) $this->fk_contact)."'"; + $sql .= " SET fk_mailing = ".((int) $this->fk_mailing); + $sql .= ", fk_contact = ".((int) $this->fk_contact); $sql .= ", lastname = '".$this->db->escape($this->lastname)."'"; $sql .= ", firstname = '".$this->db->escape($this->firstname)."'"; $sql .= ", email = '".$this->db->escape($this->email)."'"; $sql .= ", other = '".$this->db->escape($this->other)."'"; $sql .= ", tag = '".$this->db->escape($this->tag)."'"; - $sql .= ", statut = '".((int) $this->statut)."'"; + $sql .= ", statut = ".((int) $this->statut); $sql .= ", source_url = '".$this->db->escape($this->source_url)."'"; - $sql .= ", source_id = '".((int) $this->source_id)."'"; + $sql .= ", source_id = ".((int) $this->source_id); $sql .= ", source_type = '".$this->db->escape($this->source_type)."'"; if ($this->date_envoi) { $sql .= ", date_envoi = '".$this->db->idate($this->date_envoi)."'"; diff --git a/htdocs/core/class/cemailtemplate.class.php b/htdocs/core/class/cemailtemplate.class.php index 0e7f7d70835..0cb0cd91106 100644 --- a/htdocs/core/class/cemailtemplate.class.php +++ b/htdocs/core/class/cemailtemplate.class.php @@ -272,7 +272,7 @@ class CEmailTemplate extends CommonObject if (is_null($this->fk_user)) { $sql .= " NULL,"; } else { - $sql .= " '".((int) $this->fk_user)."',"; + $sql .= " ".((int) $this->fk_user).","; } if (is_null($this->datec)) { $sql .= " '".$this->db->idate($now)."',"; @@ -284,12 +284,12 @@ class CEmailTemplate extends CommonObject if (is_null($this->enabled)) { $sql .= " 1,"; } else { - $sql .= " '".((int) $this->enabled)."',"; + $sql .= " ".((int) $this->enabled).","; } if (is_null($this->active)) { $sql .= " 1,"; } else { - $sql .= " '".((int) $this->active)."',"; + $sql .= " ".((int) $this->active).","; } if (is_null($this->email_from)) { $sql .= " NULL,"; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 116a118adcb..f5be8bf7cb8 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -114,9 +114,9 @@ class Comment extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->description)."'"; $sql .= ", ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); - $sql .= ", '".(isset($this->fk_element) ? ((int) $this->fk_element) : "null")."'"; + $sql .= ", ".(isset($this->fk_element) ? ((int) $this->fk_element) : "null"); $sql .= ", '".$this->db->escape($this->element_type)."'"; - $sql .= ", '".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null")."'"; + $sql .= ", ".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null"); $sql .= ", ".((int) $user->id); $sql .= ", ".(!empty($this->entity) ? ((int) $this->entity) : '1'); $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index cd19e4ffe8b..51926fc17ba 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -477,9 +477,9 @@ interface Database * Encrypt sensitive data in database * Warning: This function includes the escape and add the SQL simple quotes on strings. * - * @param string $fieldorvalue Field name or value to encrypt - * @param int $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). - * @return string XXX(field) or XXX('value') or field or 'value' + * @param string $fieldorvalue Field name or value to encrypt + * @param int<1,1> $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). + * @return string XXX(field) or XXX('value') or field or 'value' */ public function encrypt($fieldorvalue, $withQuotes = 1); diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 855f691a156..f8905a07c87 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -629,9 +629,9 @@ class DoliDBMysqli extends DoliDB * Encrypt sensitive data in database * Warning: This function includes the escape and add the SQL simple quotes on strings. * - * @param string $fieldorvalue Field name or value to encrypt - * @param int $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). - * @return string XXX(field) or XXX('value') or field or 'value' + * @param string $fieldorvalue Field name or value to encrypt + * @param int<1,1> $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). + * @return string XXX(field) or XXX('value') or field or 'value' */ public function encrypt($fieldorvalue, $withQuotes = 1) { diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index a0b8109dc94..c1d61886c63 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -885,9 +885,9 @@ class DoliDBPgsql extends DoliDB * Encrypt sensitive data in database * Warning: This function includes the escape and add the SQL simple quotes on strings. * - * @param string $fieldorvalue Field name or value to encrypt - * @param int $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). - * @return string XXX(field) or XXX('value') or field or 'value' + * @param string $fieldorvalue Field name or value to encrypt + * @param int<1,1> $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). + * @return string XXX(field) or XXX('value') or field or 'value' */ public function encrypt($fieldorvalue, $withQuotes = 1) { diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index e119e67018e..6ae6142d4b8 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -766,9 +766,9 @@ class DoliDBSqlite3 extends DoliDB * Encrypt sensitive data in database * Warning: This function includes the escape and add the SQL simple quotes on strings. * - * @param string $fieldorvalue Field name or value to encrypt - * @param int $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). - * @return string XXX(field) or XXX('value') or field or 'value' + * @param string $fieldorvalue Field name or value to encrypt + * @param int<1,1> $withQuotes Return string including the SQL simple quotes. This param must always be 1 (Value 0 is bugged and deprecated). + * @return string XXX(field) or XXX('value') or field or 'value' */ public function encrypt($fieldorvalue, $withQuotes = 1) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index ae6986ae94a..d227f0b165d 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1912,9 +1912,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if ($row[0] == 0) { // If not found $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, type, value, note, visible, entity)"; $sql .= " VALUES ("; - $sql .= $this->db->encrypt($name); + $sql .= $this->db->encrypt($name); // Note: encrypt returns SQL expression or quoted string $sql .= ", '".$this->db->escape($type)."'"; - $sql .= ", ".(($val != '') ? $this->db->encrypt($val) : "''"); + $sql .= ", ".(($val != '') ? $this->db->encrypt($val) : "''"); // Note: encrypt returns SQL expression or quoted string $sql .= ", ".($note ? "'".$this->db->escape($note)."'" : "null"); $sql .= ", '".$this->db->escape($visible)."'"; $sql .= ", ".((int) $entity); diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 906ead80db3..1a386b667fe 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -102,7 +102,7 @@ class CdavLib if ($ouri === false) { $sql .= ' AND a.id = '.((int) $oid); } else { - $sql .= ' AND (a.id = '.((int) $oid)." OR ac.uuidext = '".((int) $ouri)."')"; + $sql .= ' AND (a.id = '.((int) $oid)." OR ac.uuidext = ".((int) $ouri).")"; } } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 63b7644e8c5..4fb89e6ea05 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -796,7 +796,7 @@ class EcmDirectory extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql .= " cachenbofdoc = '".count($filelist)."'"; + $sql .= " cachenbofdoc = ".count($filelist); if (empty($all)) { // By default $sql .= " WHERE rowid = ".((int) $this->id); } else { diff --git a/htdocs/expedition/ajax/interface.php b/htdocs/expedition/ajax/interface.php index 94aa3f60fc4..c784f31ef42 100644 --- a/htdocs/expedition/ajax/interface.php +++ b/htdocs/expedition/ajax/interface.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Lionel Vessiller + * Copyright (C) 2026 MDW * * 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 @@ -84,7 +85,7 @@ if ($action == 'updateselectbatchbywarehouse' && $permissiontowrite) { } $sql .= " WHERE ps.fk_product = ".((int) $product_id); if ($warehouse_id > 0) { - $sql .= " AND fk_entrepot = '".((int) $warehouse_id)."'"; + $sql .= " AND fk_entrepot = ".((int) $warehouse_id); } $sql .= " ORDER BY e.ref, pb.batch"; diff --git a/htdocs/mrp/ajax/interface.php b/htdocs/mrp/ajax/interface.php index b92fc07393b..7f9c0df78d7 100644 --- a/htdocs/mrp/ajax/interface.php +++ b/htdocs/mrp/ajax/interface.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2026 MDW * * 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 @@ -75,7 +76,7 @@ if ($action == 'updateselectbatchbywarehouse' && $permissiontoproduce) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (" . getEntity('stock') . ")"; $sql .= " WHERE ps.fk_product = " .((int) $fk_product); if ($warehouse_id > 0) { - $sql .= " AND fk_entrepot = '" . ((int) $warehouse_id) . "'"; + $sql .= " AND fk_entrepot = " . ((int) $warehouse_id); } $sql .= " ORDER BY e.ref, pb.batch"; diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 598f5c7a641..bc75fbf0cce 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2026 MDW */ /* * This program is free software; you can redistribute it and/or modify @@ -90,10 +90,10 @@ if ($action == "existbarcode" && !empty($barcode) && $user->hasRight('stock', 'l $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; } if (!empty($fk_entrepot)) { - $sql .= " AND ps.fk_entrepot = '".((int) ($fk_entrepot))."'"; + $sql .= " AND ps.fk_entrepot = ".((int) ($fk_entrepot)); } if (!empty($fk_product)) { - $sql .= " AND ps.fk_product = '".((int) ($fk_product))."'"; + $sql .= " AND ps.fk_product = ".((int) ($fk_product)); } $result = $db->query($sql); if ($result) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c4ec0261ea3..c618f511a2f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -649,7 +649,7 @@ if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1 $sql .= " AND p.tobuy = ".((int) $search_tobuy); } if (isset($search_stockable_product) && dol_strlen($search_stockable_product) > 0 && $search_stockable_product != -1) { - $sql .= " AND p.stockable_product = '". ((int) $search_stockable_product) . "'"; + $sql .= " AND p.stockable_product = ". ((int) $search_stockable_product); } if (isset($search_tobatch) && dol_strlen($search_tobatch) > 0 && $search_tobatch != -1) { $sql .= " AND p.tobatch = ".((int) $search_tobatch); diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index d71682c9dae..5348bf0cbc3 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -523,7 +523,7 @@ class Salary extends CommonObject $sql .= ", entity"; $sql .= ") "; $sql .= " VALUES ("; - $sql .= "'".((int) $this->fk_user)."'"; + $sql .= ((int) $this->fk_user); //$sql .= ", '".$this->db->idate($this->datep)."'"; //$sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", ".((float) $this->amount); @@ -537,7 +537,7 @@ class Salary extends CommonObject $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->idate($this->datesp)."'"; $sql .= ", '".$this->db->idate($this->dateep)."'"; - $sql .= ", '".((int) $user->id)."'"; + $sql .= ", ".((int) $user->id); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", NULL"; $sql .= ", ".((int) $conf->entity); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 41850caf50b..2635dc406ef 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1049,7 +1049,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio // Define if customer/prospect or supplier status is set or not if (GETPOST("type", 'aZ') != 'f') { - $object->client = -1; + $object->client = 0; if (getDolGlobalString('THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT')) { $object->client = 3; } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 48686ef2394..fc2713e7288 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -476,9 +476,9 @@ class CompanyBankAccount extends Account $sql .= ",bic='".$this->db->escape($this->bic)."'"; $sql .= ",iban_prefix = '".$this->db->escape(dolEncrypt($this->iban))."'"; $sql .= ",currency_code = '".$this->db->escape($this->currency_code)."'"; - $sql .= ",fk_country = '".((int) $this->fk_country)."'"; - $sql .= ",state_id = '".((int) $this->state_id)."'"; - $sql .= ",status = '".((int) $this->status)."'"; + $sql .= ",fk_country = ".((int) $this->fk_country); + $sql .= ",state_id = ".((int) $this->state_id); + $sql .= ",status = ".((int) $this->status); $sql .= ",domiciliation = '".$this->db->escape($this->address)."'"; $sql .= ",proprio = '".$this->db->escape($this->owner_name)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3f7f9b38be9..f90dded97f8 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1261,7 +1261,7 @@ class User extends CommonObject // les charactis for the module, permissions and sub-permission of this permission. $sql = "SELECT module, perms, subperms"; $sql .= " FROM ".$this->db->prefix()."rights_def"; - $sql .= " WHERE id = '".((int) $rid)."'"; + $sql .= " WHERE id = ".((int) $rid); $sql .= " AND entity IN (".$this->db->sanitize($entity, 0, 0, 0, 0).")"; $result = $this->db->query($sql); @@ -2349,8 +2349,8 @@ class User extends CommonObject $sql .= ", address = '".$this->db->escape($this->address)."'"; $sql .= ", zip = '".$this->db->escape($this->zip)."'"; $sql .= ", town = '".$this->db->escape($this->town)."'"; - $sql .= ", fk_state = ".((!empty($this->state_id) && $this->state_id > 0) ? "'".((int) $this->state_id)."'" : "null"); - $sql .= ", fk_country = ".((!empty($this->country_id) && $this->country_id > 0) ? "'".((int) $this->country_id)."'" : "null"); + $sql .= ", fk_state = ".((!empty($this->state_id) && $this->state_id > 0) ? ((int) $this->state_id) : "null"); + $sql .= ", fk_country = ".((!empty($this->country_id) && $this->country_id > 0) ? ((int) $this->country_id) : "null"); $sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'"; $sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; @@ -2371,10 +2371,10 @@ class User extends CommonObject $sql .= ", note_public = '".$this->db->escape($this->note_public)."'"; $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); $sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null"); - $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".((int) $this->fk_user)."'" : "null"); - $sql .= ", fk_user_modif = ".($this->user_modification_id > 0 ? "'".((int) $this->user_modification_id)."'" : "null"); - $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".((int) $this->fk_user_expense_validator)."'" : "null"); - $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".((int) $this->fk_user_holiday_validator)."'" : "null"); + $sql .= ", fk_user = ".($this->fk_user > 0 ? ((int) $this->fk_user) : "null"); + $sql .= ", fk_user_modif = ".($this->user_modification_id > 0 ? ((int) $this->user_modification_id) : "null"); + $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? ((int) $this->fk_user_expense_validator) : "null"); + $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? ((int) $this->fk_user_holiday_validator) : "null"); if (isset($this->thm) || $this->thm != '') { $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null"); }