Post by straightlight » Sun Nov 04, 2018 9:47 pm

Currently, in v3.1.0.0x releases on GitHub, the admin GDPR cron task file suggests to load all customers which their GDPR expiration date has reached its limit point. However, since it uses a loop to validate this, the methodology currently provided might be good for the first few hundreds of users but may not be suggested to be used for stores that handles several thousands of them as it may decreasingly optimize your stores.

In order to rectify this issue, in your admin/controller/cron/gdpr.php file,

replace the entire file with the following, instead:

Code: Select all

<?php
class ControllerCronGdpr extends Controller {
	public function index($cron_id, $code, $cycle, $date_added, $date_modified) {
		$this->load->model('customer/gdpr');		

		$this->model_customer_gdpr->deleteExpiredCustomers();
	}
}
Then, in your admin/model/customer/gdpr.php file,

find:

Code: Select all

public function deleteGdpr($customer_id) {
		$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_gdpr` WHERE customer_id = '" . (int)$customer_id . "'");
	}
add below:

Code: Select all

public function deleteExpiredCustomers() {
		$expiry = (time() - 60 * 60 * 24 * (int)$this->config->get('config_gdpr_limit'));
		
		$this->db->query("DELETE FROM `" . DB_PREFIX . "customer`, `" . DB_PREFIX . "customer_gdpr` USING `customer`,`customer_gdpr` WHERE `customer_gdpr`.`customer_id` = `customer`.`customer_id` AND UNIX_TIMESTAMP(`customer_gdpr`.`date_added`) < '" . (int)$expiry . "' AND `customer_gdpr`.`status` = '1'");
	}
This should resolved the issue as only one simple query may be needed in order to validate all customers with GDPR without a loop statement.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 5 guests