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:
authormattab <matthieu.aubry@gmail.com>2014-12-10 08:15:44 +0300
committermattab <matthieu.aubry@gmail.com>2014-12-10 08:15:44 +0300
commitc28f9d6e29fccc0e4d3b0d1c91a28667c620ee1e (patch)
tree5bb4844beddc73890cbcafd904bc98830046438f /core/DataTable.php
parentdab1ee71f1ced3abe28064145d39d8ca7f6eb5e9 (diff)
reuse $row->getSubtable() as much as possible instead of callng Manager::getInstance()->getTable which can throw exception refs #3414
Diffstat (limited to 'core/DataTable.php')
-rw-r--r--core/DataTable.php43
1 files changed, 20 insertions, 23 deletions
diff --git a/core/DataTable.php b/core/DataTable.php
index 61e8abb1eb..53686f2feb 100644
--- a/core/DataTable.php
+++ b/core/DataTable.php
@@ -356,10 +356,11 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
if ($this->enableRecursiveSort === true) {
foreach ($this->getRows() as $row) {
- if (($idSubtable = $row->getIdSubDataTable()) !== null) {
- $table = Manager::getInstance()->getTable($idSubtable);
- $table->enableRecursiveSort();
- $table->sort($functionCallback, $columnSortedBy);
+
+ $subTable = $row->getSubtable();
+ if ($subTable) {
+ $subTable->enableRecursiveSort();
+ $subTable->sort($functionCallback, $columnSortedBy);
}
}
}
@@ -868,8 +869,8 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
{
$totalCount = 0;
foreach ($this->rows as $row) {
- if (($idSubTable = $row->getIdSubDataTable()) !== null) {
- $subTable = Manager::getInstance()->getTable($idSubTable);
+ $subTable = $row->getSubtable();
+ if ($subTable) {
$count = $subTable->getRowsCountRecursive();
$totalCount += $count;
}
@@ -907,8 +908,9 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
$row->renameColumn($oldName, $newName);
if ($doRenameColumnsOfSubTables) {
- if (($idSubDataTable = $row->getIdSubDataTable()) !== null) {
- Manager::getInstance()->getTable($idSubDataTable)->renameColumn($oldName, $newName);
+ $subTable = $row->getSubtable();
+ if ($subTable) {
+ $subTable->renameColumn($oldName, $newName);
}
}
}
@@ -929,8 +931,9 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
foreach ($names as $name) {
$row->deleteColumn($name);
}
- if (($idSubDataTable = $row->getIdSubDataTable()) !== null) {
- Manager::getInstance()->getTable($idSubDataTable)->deleteColumns($names, $deleteRecursiveInSubtables);
+ $subTable = $row->getSubtable();
+ if ($subTable) {
+ $subTable->deleteColumns($names, $deleteRecursiveInSubtables);
}
}
if (!is_null($this->summaryRow)) {
@@ -1110,17 +1113,11 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
// but returns all serialized tables and subtable in an array of 1 dimension
$aSerializedDataTable = array();
foreach ($this->rows as $row) {
- if (($idSubTable = $row->getIdSubDataTable()) !== null) {
- $subTable = null;
- try {
- $subTable = Manager::getInstance()->getTable($idSubTable);
- } catch(TableNotFoundException $e) {
- // This occurs is an unknown & random data issue. Catch Exception and remove subtable from the row.
- $row->removeSubtable();
- // Go to next row
- continue;
- }
-
+ $subTable = $row->getSubtable();
+ if (!$subTable) {
+ // Not sure if this code is needed
+ $row->removeSubtable();
+ } else {
$depth++;
$aSerializedDataTable = $aSerializedDataTable + $subTable->getSerialized($maximumRowsInSubDataTable, $maximumRowsInSubDataTable, $columnToSortByBeforeTruncation);
$depth--;
@@ -1616,8 +1613,8 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
// we simply add it (cloning the subtable)
// if the row has the subtable already
// then we have to recursively sum the subtables
- if (($idSubTable = $row->getIdSubDataTable()) !== null) {
- $subTable = Manager::getInstance()->getTable($idSubTable);
+ $subTable = $row->getSubtable();
+ if ($subTable) {
$subTable->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME]
= $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$rowFound->sumSubtable($subTable);