From fbbe0b4b390e67d1dcacac7acb29628e7925659b Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 15 Oct 2010 03:08:39 +0000 Subject: [PATCH] BUGFIX: prevented HTTPRequest->shift() throwing notices when shifting multiple elements. APICHANGE: SS_HTTPRequest->shift($multiple) no longer returns an array of size $multiple spaced with nulls, it returns an array up to the size of $multiple. (from r107090) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112548 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/HTTPRequest.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/control/HTTPRequest.php b/core/control/HTTPRequest.php index eaf4047f6..af5ba2878 100755 --- a/core/control/HTTPRequest.php +++ b/core/control/HTTPRequest.php @@ -452,10 +452,25 @@ class SS_HTTPRequest implements ArrayAccess { /** * Shift one or more parts off the beginning of the URL. * If you specify shifting more than 1 item off, then the items will be returned as an array + * + * @param int $count Shift Count + * + * @return String|Array */ function shift($count = 1) { + $return = array(); + if($count == 1) return array_shift($this->dirParts); - else for($i=0;$i<$count;$i++) $return[] = array_shift($this->dirParts); + + for($i=0;$i<$count;$i++) { + $value = array_shift($this->dirParts); + + if(!$value) break; + + $return[] = $value; + } + + return $return; } /**