From 52e2253e209da95905b087d9eb78cc13d0563458 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2012 18:39:41 +0100 Subject: [PATCH] Fix: A delete must always be done on a fully loaded object. --- htdocs/compta/facture.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 54e03b64127..80803d6d714 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -141,7 +141,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> { if ($user->rights->facture->supprimer) { - $result = $object->delete($id); + $result = $object->fetch($id); + $result = $object->delete(); if ($result > 0) { Header('Location: '.$_SERVER["PHP_SELF"]); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 506c60327e8..b60d0a095b6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1119,7 +1119,7 @@ class Facture extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function delete($rowid, $notrigger=0) + function delete($rowid=0, $notrigger=0) { global $user,$langs,$conf; @@ -1131,7 +1131,7 @@ class Facture extends CommonObject $error=0; $this->db->begin(); - + if (! $error && ! $notrigger) { // Appel des triggers @@ -1143,7 +1143,7 @@ class Facture extends CommonObject } // Fin appel triggers } - + if (! $error) { // Delete linked object