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:
Sean Harvey 2009-05-19 23:11:38 +00:00
parent 83613ee0d3
commit a62cf00061

View File

@ -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;
}
}