mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #3777 DataObjectSet_Iterator->getOffset() shouldn't die if trying to seek past the set (mobiusnz)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77270 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
83613ee0d3
commit
a62cf00061
@ -1105,15 +1105,20 @@ class DataObjectSet_Iterator implements Iterator {
|
||||
/**
|
||||
* Return the object in this set offset by $offset from the iterator pointer.
|
||||
* @param int $offset The offset.
|
||||
* @return DataObject
|
||||
* @return DataObject|boolean DataObject of offset item, or boolean FALSE if not found
|
||||
*/
|
||||
public function getOffset($offset) {
|
||||
$keys = array_keys($this->items);
|
||||
foreach($keys as $i => $key) {
|
||||
if($key == key($this->items)) break;
|
||||
}
|
||||
$requiredKey = $keys[$i + $offset];
|
||||
return $this->items [$requiredKey];
|
||||
|
||||
if(isset($keys[$i + $offset])) {
|
||||
$requiredKey = $keys[$i + $offset];
|
||||
return $this->items[$requiredKey];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user