Fix ticket deletion

This commit is contained in:
Laurent Destailleur 2018-03-12 19:30:21 +01:00
parent 78b0585798
commit bf36d671ba
2 changed files with 18 additions and 19 deletions

View File

@ -332,9 +332,9 @@ class Ticketsup extends CommonObject
$sql .= "severity_code,"; $sql .= "severity_code,";
$sql .= "datec,"; $sql .= "datec,";
$sql .= "date_read,"; $sql .= "date_read,";
$sql .= "date_close"; $sql .= "date_close,";
$sql .= ", entity"; $sql .= "entity,";
$sql .= ", notify_tiers_at_create"; $sql .= "notify_tiers_at_create";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " " . (!isset($this->ref) ? '' : "'" . $this->db->escape($this->ref) . "'") . ","; $sql .= " " . (!isset($this->ref) ? '' : "'" . $this->db->escape($this->ref) . "'") . ",";
$sql .= " " . (!isset($this->track_id) ? 'NULL' : "'" . $this->db->escape($this->track_id) . "'") . ","; $sql .= " " . (!isset($this->track_id) ? 'NULL' : "'" . $this->db->escape($this->track_id) . "'") . ",";
@ -894,12 +894,12 @@ class Ticketsup extends CommonObject
if (!$error) { if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticketsup_logs"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticketsup_logs";
$sql .= " WHERE rowid=" . $this->id; $sql .= " WHERE fk_track_id = '" . $this->track_id . "'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
} }
if (!$error) { if (!$error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticketsup_mesgs"; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticketsup_msg";
$sql .= " WHERE rowid=" . $this->id; $sql .= " WHERE fk_track_id = '" . $this->track_id . "'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
} }

View File

@ -145,7 +145,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->create($user); $result=$localobject->create($user);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertEquals($result, -1, $localobject->error); $this->assertEquals(-1, $result, $localobject->error);
// Try to create one with correct values // Try to create one with correct values
$localobject=new \Ticketsup($this->savdb); $localobject=new \Ticketsup($this->savdb);
@ -153,7 +153,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->create($user); $result=$localobject->create($user);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0, $localobject->error); $this->assertGreaterThan(0, $result, $localobject->error);
return $result; return $result;
@ -180,7 +180,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -205,7 +205,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->markAsRead($user); $result=$localobject->markAsRead($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -231,7 +231,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->setProject($project_id); $result=$localobject->setProject($project_id);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -257,7 +257,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->setContract($contract_id); $result=$localobject->setContract($contract_id);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -283,7 +283,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->setProgression($percent); $result=$localobject->setProgression($percent);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -310,7 +310,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
; ;
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -337,7 +337,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
; ;
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -364,7 +364,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->createTicketLog($user, $message, $noemail); $result=$localobject->createTicketLog($user, $message, $noemail);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject; return $localobject;
} }
@ -388,7 +388,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->close(); $result=$localobject->close();
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $localobject->id; return $localobject->id;
} }
@ -404,7 +404,6 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
*/ */
public function testTicketsupDelete($id) public function testTicketsupDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
$conf=$this->savconf; $conf=$this->savconf;
$user=$this->savuser; $user=$this->savuser;
@ -416,7 +415,7 @@ class TicketsupTest extends \PHPUnit_Framework_TestCase
$result=$localobject->delete($user); $result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertGreaterThan(0, $result);
return $result; return $result;
} }
} }