diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-07-28 18:30:38 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-06 17:23:54 +0300 |
commit | e30de3346a74ea908ee1e9944dbc5686016e11a4 (patch) | |
tree | 9c688acc7f0094fcaa37d02811ac20e7fbcea4de /core/DataTable/Filter/ColumnDelete.php | |
parent | a4f06699c5c6ea11e64733e283686e9447e3a860 (diff) |
A Row implementation that is based on ArrayObject which is faster
Diffstat (limited to 'core/DataTable/Filter/ColumnDelete.php')
-rw-r--r-- | core/DataTable/Filter/ColumnDelete.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/DataTable/Filter/ColumnDelete.php b/core/DataTable/Filter/ColumnDelete.php index a0fba5a963..60e53fd7dd 100644 --- a/core/DataTable/Filter/ColumnDelete.php +++ b/core/DataTable/Filter/ColumnDelete.php @@ -103,6 +103,10 @@ class ColumnDelete extends BaseFilter if (!empty($this->columnsToRemove)) { foreach ($table as $index => $row) { foreach ($this->columnsToRemove as $column) { + if (!array_key_exists($column, $row)) { + continue; + } + if ($this->deleteIfZeroOnly) { $value = $row[$column]; if ($value === false || !empty($value)) { @@ -115,11 +119,13 @@ class ColumnDelete extends BaseFilter } $recurse = true; + } // remove columns not specified in $columnsToKeep if (!empty($this->columnsToKeep)) { foreach ($table as $index => $row) { + $columnsToDelete = array(); foreach ($row as $name => $value) { $keep = false; // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP @@ -133,9 +139,14 @@ class ColumnDelete extends BaseFilter && $name != 'label' // label cannot be removed via whitelisting && !isset($this->columnsToKeep[$name]) ) { - unset($table[$index][$name]); + // we cannot remove row directly to prevent notice "ArrayIterator::next(): Array was modified + // outside object and internal position is no longer valid in /var/www..." + $columnsToDelete[] = $name; } } + foreach ($columnsToDelete as $columnToDelete) { + unset($table[$index][$columnToDelete]); + } } $recurse = true; |