diff options
-rw-r--r-- | core/Archive/Single.php | 2 | ||||
-rw-r--r-- | core/ArchiveProcessing.php | 8 | ||||
-rw-r--r-- | core/ArchiveProcessing/Period.php | 11 | ||||
-rw-r--r-- | core/Db/Schema.php | 6 | ||||
-rw-r--r-- | core/Db/Schema/Myisam.php | 13 | ||||
-rw-r--r-- | core/Piwik.php | 5 | ||||
-rw-r--r-- | core/TablePartitioning.php | 3 | ||||
-rw-r--r-- | core/Tracker/Action.php | 13 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 3 | ||||
-rw-r--r-- | plugins/Actions/Actions.php | 2 |
10 files changed, 30 insertions, 36 deletions
diff --git a/core/Archive/Single.php b/core/Archive/Single.php index 8f5fcecacc..65d90c78be 100644 --- a/core/Archive/Single.php +++ b/core/Archive/Single.php @@ -254,7 +254,7 @@ class Piwik_Archive_Single extends Piwik_Archive } $db = Zend_Registry::get('db'); - $value = $db->fetchOne("/* SHARDING_ID_SITE = ".$this->site->getId()." */ SELECT value + $value = $db->fetchOne("SELECT value FROM $table WHERE idarchive = ? AND name = ?", diff --git a/core/ArchiveProcessing.php b/core/ArchiveProcessing.php index 0a47e30a4e..4f6c3b70e2 100644 --- a/core/ArchiveProcessing.php +++ b/core/ArchiveProcessing.php @@ -452,8 +452,7 @@ abstract class Piwik_ArchiveProcessing protected function postCompute() { // delete the first done = ERROR - Piwik_Query("/* SHARDING_ID_SITE = ".$this->idsite." */ - DELETE FROM ".$this->tableArchiveNumeric->getTableName()." + Piwik_Query("DELETE FROM ".$this->tableArchiveNumeric->getTableName()." WHERE idarchive = ? AND name = 'done'", array($this->idArchive) ); @@ -547,9 +546,8 @@ abstract class Piwik_ArchiveProcessing protected function loadNextIdarchive() { $db = Zend_Registry::get('db'); - $id = $db->fetchOne("/* SHARDING_ID_SITE = ".$this->idsite." */ - SELECT max(idarchive) - FROM ".$this->tableArchiveNumeric->getTableName()); + $id = $db->fetchOne("SELECT max(idarchive) + FROM ".$this->tableArchiveNumeric->getTableName()); if(empty($id)) { $id = 0; diff --git a/core/ArchiveProcessing/Period.php b/core/ArchiveProcessing/Period.php index 53d78b5782..9cc3cf2536 100644 --- a/core/ArchiveProcessing/Period.php +++ b/core/ArchiveProcessing/Period.php @@ -291,6 +291,14 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing Piwik_PostEvent('ArchiveProcessing_Period.compute', $this); } + /** + * Processes number of unique visitors for the given period + * + * This is the only metric we process from the logs directly, + * since unique visitors cannot be summed like other metrics. + * + * @return int + */ protected function computeNbUniqVisitors() { $query = " @@ -343,8 +351,7 @@ class Piwik_ArchiveProcessing_Period extends Piwik_ArchiveProcessing foreach($result as $row) { $idArchivesToDelete[] = $row['idarchive']; } - $query = "/* SHARDING_ID_SITE = ".$this->idsite." */ - DELETE + $query = "DELETE FROM %s WHERE idarchive IN (".implode(',',$idArchivesToDelete).") "; diff --git a/core/Db/Schema.php b/core/Db/Schema.php index 38b154872d..48278e94a8 100644 --- a/core/Db/Schema.php +++ b/core/Db/Schema.php @@ -241,9 +241,9 @@ class Piwik_Db_Schema * @param string $idSite * @return array Tables installed */ - public function getTablesInstalled($forceReload = true, $idSite = null) + public function getTablesInstalled($forceReload = true) { - return $this->getSchema()->getTablesInstalled($forceReload, $idSite); + return $this->getSchema()->getTablesInstalled($forceReload); } /** @@ -276,6 +276,6 @@ interface Piwik_Db_Schema_Interface public function dropTables( $doNotDelete = array() ); public function getTablesNames(); - public function getTablesInstalled($forceReload = true, $idSite = null); + public function getTablesInstalled($forceReload = true); public function hasTables(); } diff --git a/core/Db/Schema/Myisam.php b/core/Db/Schema/Myisam.php index 5d0b1ffc8c..8c54ea26a1 100644 --- a/core/Db/Schema/Myisam.php +++ b/core/Db/Schema/Myisam.php @@ -339,7 +339,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface * @param string $idSite * @return array Tables installed */ - public function getTablesInstalled($forceReload = true, $idSite = null) + public function getTablesInstalled($forceReload = true) { if(is_null($this->tablesInstalled) || $forceReload === true) @@ -361,15 +361,8 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface // at this point we have only the piwik tables which is good // but we still miss the piwik generated tables (using the class Piwik_TablePartitioning) - $idSiteInSql = "no"; - if(!is_null($idSite)) - { - $idSiteInSql = $idSite; - } - $allArchiveNumeric = $db->fetchCol("/* SHARDING_ID_SITE = ".$idSiteInSql." */ - SHOW TABLES LIKE '".$prefixTables."archive_numeric%'"); - $allArchiveBlob = $db->fetchCol("/* SHARDING_ID_SITE = ".$idSiteInSql." */ - SHOW TABLES LIKE '".$prefixTables."archive_blob%'"); + $allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_numeric%'"); + $allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_blob%'"); $allTablesReallyInstalled = array_merge($tablesInstalled, $allArchiveNumeric, $allArchiveBlob); diff --git a/core/Piwik.php b/core/Piwik.php index 8d76a40304..1bb242e2d2 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -1979,11 +1979,10 @@ class Piwik * Get list of tables installed * * @param bool $forceReload Invalidate cache - * @param string $idSite * @return array Tables installed */ - static public function getTablesInstalled($forceReload = true, $idSite = null) + static public function getTablesInstalled($forceReload = true) { - return Piwik_Db_Schema::getInstance()->getTablesInstalled($forceReload, $idSite); + return Piwik_Db_Schema::getInstance()->getTablesInstalled($forceReload); } } diff --git a/core/TablePartitioning.php b/core/TablePartitioning.php index 97a26309cb..a649cc141f 100644 --- a/core/TablePartitioning.php +++ b/core/TablePartitioning.php @@ -70,7 +70,7 @@ abstract class Piwik_TablePartitioning { if(is_null(self::$tablesAlreadyInstalled)) { - self::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = false, $this->idSite); + self::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = false); } if(!in_array($this->generatedTableName, self::$tablesAlreadyInstalled)) @@ -81,7 +81,6 @@ abstract class Piwik_TablePartitioning $config = Zend_Registry::get('config'); $prefixTables = $config->database->tables_prefix; $sql = str_replace( $prefixTables . $this->tableName, $this->generatedTableName, $sql); - $sql = "/* SHARDING_ID_SITE = ".$this->idSite." */ ".$sql; $db->query( $sql ); self::$tablesAlreadyInstalled[] = $this->generatedTableName; diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index 81b3ee126f..3ab1bbb117 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -216,8 +216,8 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface { return; } - $idAction = Piwik_Tracker::getDatabase()->fetchAll("/* SHARDING_ID_SITE = ".$this->idSite." */ - SELECT idaction, type + $idAction = Piwik_Tracker::getDatabase()->fetchAll( + "SELECT idaction, type FROM ".Piwik_Common::prefixTable('log_action') ." WHERE " ." ( hash = CRC32(?) AND name = ? AND type = ? ) " @@ -242,9 +242,8 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface } } - $sql = "/* SHARDING_ID_SITE = ".$this->idSite." */ - INSERT INTO ". Piwik_Common::prefixTable('log_action'). - "( name, hash, type ) VALUES (?,CRC32(?),?)"; + $sql = "INSERT INTO ". Piwik_Common::prefixTable('log_action'). + "( name, hash, type ) VALUES (?,CRC32(?),?)"; if( is_null($this->idActionName) && !is_null($this->getActionNameType()) ) @@ -287,8 +286,8 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface { $idActionName = 0; } - Piwik_Tracker::getDatabase()->query("/* SHARDING_ID_SITE = ".$this->idSite." */ - INSERT INTO ".Piwik_Common::prefixTable('log_link_visit_action') + Piwik_Tracker::getDatabase()->query( + "INSERT INTO ".Piwik_Common::prefixTable('log_link_visit_action') ." (idvisit, idaction_url, idaction_name, idaction_url_ref, time_spent_ref_action) VALUES (?,?,?,?,?)", array($idVisit, $this->getIdActionUrl(), $idActionName , $idRefererAction, $timeSpentRefererAction) diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 6497133ad8..9e0b481762 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -331,8 +331,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface $sqlBind[] = $value; } - $sqlQuery = "/* SHARDING_ID_SITE = ". $this->idsite ." */ - UPDATE ". Piwik_Common::prefixTable('log_visit')." + $sqlQuery = "UPDATE ". Piwik_Common::prefixTable('log_visit')." SET $sqlActionUpdate ".implode($updateParts, ', ')." WHERE idsite = ? AND idvisit = ? diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 038b4fd100..b33fe2676d 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -338,7 +338,7 @@ class Piwik_Actions extends Piwik_Plugin $archiveProcessing->insertBlobRecord('Actions_actions', $s); destroy($dataTable); - unset($this->actionsTablesByType); + destroy($this->actionsTablesByType); } protected function deleteInvalidSummedColumnsFromDataTable($dataTable) |