diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-03-31 05:23:50 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-04-01 00:36:21 +0300 |
commit | 8f9b07d7dd4c70117df785d5b22416a325f2a342 (patch) | |
tree | ad75bd25cdea32d4933a31eb59cb3e04e25c149e /core/DataTable.php | |
parent | 1b545d301d8248118243dd21e33a3e1aca285f6c (diff) |
refs #7458 fix memory error in API Live.getLastVisitsDetails when filter_offset is large
Diffstat (limited to 'core/DataTable.php')
-rw-r--r-- | core/DataTable.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/DataTable.php b/core/DataTable.php index c4cfb95730..a9be60d98c 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -265,6 +265,13 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess protected $queuedFilters = array(); /** + * List of disabled filter names eg 'Limit' or 'Sort' + * + * @var array + */ + protected $disabledFilters = array(); + + /** * We keep track of the number of rows before applying the LIMIT filter that deletes some rows * * @var int @@ -471,6 +478,10 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess return; } + if (in_array($className, $this->disabledFilters)) { + return; + } + if (!class_exists($className, true)) { $className = 'Piwik\DataTable\Filter\\' . $className; } @@ -546,6 +557,23 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess } /** + * Disable a specific filter to run on this DataTable in case you have already applied this filter or if you will + * handle this filter manually by using a custom filter. Be aware if you disable a given filter, that filter won't + * be ever executed. Even if another filter calls this filter on the DataTable. + * + * @param string $className eg 'Limit' or 'Sort'. Passing a `Closure` or an `array($class, $methodName)` is not + * supported yet. We check for exact match. So if you disable 'Limit' and + * call `->filter('Limit')` this filter won't be executed. If you call + * `->filter('Piwik\DataTable\Filter\Limit')` that filter will be executed. See it as a + * feature. + * @ignore + */ + public function disableFilter($className) + { + $this->disabledFilters[] = $className; + } + + /** * Applies all filters that were previously queued to the table. See {@link queueFilter()} * for more information. */ |