Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent deleting data when non-existing customer #78

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions psgdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,10 @@ public function deleteCustomer($delete, $value)
switch ($delete) {
case 'customer':
$customer = new Customer((int)$value);
$this->deleteDataFromModules($customer);
$this->deleteDataFromPrestashop($customer);
if (Validate::isLoadedObject($customer)) {
$this->deleteDataFromModules($customer);
$this->deleteDataFromPrestashop($customer);
}
break;
case 'email':
$data = array('email' => $value);
Expand All @@ -848,8 +850,17 @@ public function deleteCustomer($delete, $value)
}
}

/**
* @param Customer $customer
*
* @return bool
*/
public function deleteDataFromPrestashop($customer)
{
if (!Validate::isLoadedObject($customer)) {
return false;
}
Quetzacoalt91 marked this conversation as resolved.
Show resolved Hide resolved

$queries = array();

// assign order to an anonymous account in order to keep stats -> let customer->delete() do the job
Expand Down Expand Up @@ -890,7 +901,8 @@ public function deleteDataFromPrestashop($customer)
}

GDPRLog::addLog((int)$customer->id, 'delete', 0, 0);
$customer->delete(); // delete the customer

return $customer->delete(); // delete the customer
}

public function deleteDataFromModules($customer)
Expand Down