From d5343cfedbe5decee84c451ceefa9d59d1267c1d Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sun, 19 Nov 2023 00:52:16 +0100 Subject: [PATCH] fix: phpstan (#26721) * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix: phpstan * fix: phpstan --- htdocs/core/class/commoninvoice.class.php | 17 ++++++++++++----- htdocs/core/class/commonobject.class.php | 11 +++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index a08357071b5..80082dcd9cd 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -142,6 +142,13 @@ abstract class CommonInvoice extends CommonObject public $close_note; + /** + * ! Populate by Payment module like stripe + * @var string message return by Online Payment module + */ + public $postactionmessages; + + /** * Standard invoice */ @@ -689,13 +696,13 @@ abstract class CommonInvoice extends CommonObject { $subtypeLabel = ''; if ($table === 'facture' || $table === 'facture_fourn') { - $sql = "SELECT s.label FROM " . MAIN_DB_PREFIX . $table . " AS f"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_invoice_subtype AS s ON f.subtype = s.rowid"; + $sql = "SELECT s.label FROM " . $this->db->prefix() . $table . " AS f"; + $sql .= " INNER JOIN " . $this->db->prefix() . "c_invoice_subtype AS s ON f.subtype = s.rowid"; $sql .= " WHERE f.ref = '".$this->db->escape($this->ref)."'"; } elseif ($table === 'facture_rec' || $table === 'facture_fourn_rec') { - $sql = "SELECT s.label FROM " . MAIN_DB_PREFIX . $table . " AS f"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_invoice_subtype AS s ON f.subtype = s.rowid"; - $sql .= " WHERE f.titre = '".$this->db->escape($this->titre)."'"; + $sql = "SELECT s.label FROM " . $this->db->prefix() . $table . " AS f"; + $sql .= " INNER JOIN " . $this->db->prefix() . "c_invoice_subtype AS s ON f.subtype = s.rowid"; + $sql .= " WHERE f.titre = '".$this->db->escape($this->title)."'"; } else { return -1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 76afb8a22d0..e4c8e1f7a47 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1780,7 +1780,14 @@ abstract class CommonObject $result = $this->db->fetch_object($query); - return $this->fetch($result->rowid); + if (method_exists($this, 'fetch')) { + return $this->fetch($result->rowid); + } else { + $this->error = 'Fetch method not implemented on '.get_class($this); + dol_syslog(get_class($this).'::fetchOneLike Error='.$this->error, LOG_ERR); + array_push($this->errors, $this->error); + return -1; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -9550,7 +9557,7 @@ abstract class CommonObject $fieldvalues['fk_user_creat'] = $user->id; } if (array_key_exists('pass_crypted', $fieldvalues)) { - $fieldvalues['pass_crypted'] = dol_hash($object->pass); + $fieldvalues['pass_crypted'] = dol_hash($this->pass); } unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. if (array_key_exists('ref', $fieldvalues)) {