From 83ae21d087964490700d973c72ce4d5a925fbc1d Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Sun, 24 Apr 2016 22:14:55 +0000 Subject: [PATCH] orm: skip deleted items Add callback filter to standard iteration method to skip deleted items. --- include/class.orm.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/class.orm.php b/include/class.orm.php index 162b61f46..b784b6341 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -1904,14 +1904,13 @@ extends ModelResultSet { } /** - * Slight edit to the standard ::next() iteration method which will skip - * deleted items. + * Slight edit to the standard iteration method which will skip deleted + * items. */ - function next() { - do { - parent::next(); - } - while ($this->valid() && $this->current()->__deleted__); + function getIterator() { + return new CallbackFilterIterator(parent::getIterator(), + function($i) { return !$i->__deleted__; } + ); } /** -- GitLab