Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burgess <88810029+bx80@users.noreply.github.com>2022-03-29 11:18:52 +0300
committerGitHub <noreply@github.com>2022-03-29 11:18:52 +0300
commit5654ebf1b5563c27982e91167a6ff63795fe6fb5 (patch)
tree56182297c97a631585bbdd7d876358cd0a44faf0 /plugins/PrivacyManager
parent2c7a80fe933f423be62f376287d264798d3fde7f (diff)
Call deleteLogDataForm once for each deleted site (#19014)
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r--plugins/PrivacyManager/Model/DataSubjects.php17
-rw-r--r--plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php1
2 files changed, 14 insertions, 4 deletions
diff --git a/plugins/PrivacyManager/Model/DataSubjects.php b/plugins/PrivacyManager/Model/DataSubjects.php
index 0e9acd71a5..3c63448a90 100644
--- a/plugins/PrivacyManager/Model/DataSubjects.php
+++ b/plugins/PrivacyManager/Model/DataSubjects.php
@@ -70,10 +70,19 @@ class DataSubjects
}
$logTables = $this->getLogTablesToDeleteFrom();
- $results = array_merge($results, $this->deleteLogDataFrom($logTables, function ($tableToSelectFrom) use ($idSitesNoLongerExisting) {
- $idSitesNoLongerExisting = array_map('intval', $idSitesNoLongerExisting);
- return [$tableToSelectFrom . '.idsite in ('. implode(',', $idSitesNoLongerExisting).')', []];
- }));
+ // It's quicker to call the delete queries one site at a time instead of using the IN operator and potentially
+ // creating a huge result set
+ foreach ($idSitesNoLongerExisting as $idSiteNoLongerExisting) {
+ $r = $this->deleteLogDataFrom($logTables, function($tableToSelectFrom) use ($idSiteNoLongerExisting) {
+ return [$tableToSelectFrom . '.idsite = '. $idSiteNoLongerExisting, []];
+ });
+ foreach ($r as $k => $v) {
+ if (!array_key_exists($k, $results)) {
+ $results[$k] = 0;
+ }
+ $results[$k] += $v;
+ }
+ }
krsort($results); // make sure test results are always in same order
return $results;
diff --git a/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php b/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
index b81364cdb5..922b87c620 100644
--- a/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
+++ b/plugins/PrivacyManager/tests/Integration/Model/DataSubjectsTest.php
@@ -24,6 +24,7 @@ use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* Class DataSubjectsTest
*
+ * @group DataSubjectsTest
* @group Plugins
*/
class DataSubjectsTest extends IntegrationTestCase