diff options
author | diosmosis <benaka@piwik.pro> | 2015-02-09 21:48:05 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-02-09 21:48:05 +0300 |
commit | e084b065d0b8abd8684fb74be4d1e0e66db33f74 (patch) | |
tree | 94db76c9479482a59b45c19a440a58d38cc3d7ed /plugins/CoreAdminHome | |
parent | a85b33a81a82651107e745ed8dbea78f8db21e1d (diff) |
Refs #7112, do not access database in DuplicateActionRemover constructor.
Diffstat (limited to 'plugins/CoreAdminHome')
-rw-r--r-- | plugins/CoreAdminHome/Model/DuplicateActionRemover.php | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/plugins/CoreAdminHome/Model/DuplicateActionRemover.php b/plugins/CoreAdminHome/Model/DuplicateActionRemover.php index 51a93bab47..03cc529284 100644 --- a/plugins/CoreAdminHome/Model/DuplicateActionRemover.php +++ b/plugins/CoreAdminHome/Model/DuplicateActionRemover.php @@ -48,7 +48,7 @@ class DuplicateActionRemover * * @var string[] */ - private $idactionColumns; + private $idactionColumns = null; /** * Constructor. @@ -67,8 +67,6 @@ class DuplicateActionRemover $logger = StaticContainer::get('Psr\Log\LoggerInterface'); } $this->logger = $logger; - - $this->idactionColumns = $this->getIdActionTableColumnsFromMetadata(); } /** @@ -120,7 +118,8 @@ class DuplicateActionRemover */ public function fixDuplicateActionsInTable($table, $realIdAction, $duplicateIdActions) { - $idactionColumns = array_values($this->idactionColumns[$table]); + $idactionColumns = $this->getIdActionTableColumnsFromMetadata(); + $idactionColumns = array_values($idactionColumns[$table]); $table = Common::prefixTable($table); $inFromIdsExpression = $this->getInFromIdsExpression($duplicateIdActions); @@ -149,7 +148,8 @@ class DuplicateActionRemover */ public function getSitesAndDatesOfRowsUsingDuplicates($table, $duplicateIdActions) { - $idactionColumns = array_values($this->idactionColumns[$table]); + $idactionColumns = $this->getIdActionTableColumnsFromMetadata(); + $idactionColumns = array_values($idactionColumns[$table]); $table = Common::prefixTable($table); $sql = "SELECT idsite, DATE(server_time) as server_time FROM $table "; @@ -159,18 +159,20 @@ class DuplicateActionRemover private function getIdActionTableColumnsFromMetadata() { - $result = array(); - foreach (self::$tablesWithIdActionColumns as $table) { - $columns = $this->tableMetadataAccess->getIdActionColumnNames(Common::prefixTable($table)); + if ($this->idactionColumns === null) { + $this->idactionColumns = array(); + foreach (self::$tablesWithIdActionColumns as $table) { + $columns = $this->tableMetadataAccess->getIdActionColumnNames(Common::prefixTable($table)); - $this->logger->debug("Found following idactions in {table}: {columns}", array( - 'table' => $table, - 'columns' => implode(',', $columns) - )); + $this->logger->debug("Found following idactions in {table}: {columns}", array( + 'table' => $table, + 'columns' => implode(',', $columns) + )); - $result[$table] = $columns; + $this->idactionColumns[$table] = $columns; + } } - return $result; + return $this->idactionColumns; } private function getWhereToGetRowsUsingDuplicateActions($idactionColumns, $fromIdActions) |