Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

avoid offset -1 error on tests etc #892

Merged
merged 2 commits into from Oct 9, 2012

Conversation

Projects
None yet
3 participants
Member

dereuromark commented Oct 9, 2012

Undefined offset: -1

Stack trace:
E:...\lib\Cake\Routing\Router.php : 642
...

@ceeram ceeram and 1 other commented on an outdated diff Oct 9, 2012

lib/Cake/Routing/Router.php
@@ -633,8 +633,8 @@ public static function getRequest($current = false) {
* @return array Parameter information
*/
public static function getParams($current = false) {
- if ($current) {
- return self::$_requests[count(self::$_requests) - 1]->params;
+ if ($current && ($count = count(self::$_requests)) > 0) {
@ceeram

ceeram Oct 9, 2012

Member

You can check this also with:

-               if ($current) {
+               if ($current && self::$_requests) {

Just wondering how you did get the error?

@dereuromark

dereuromark Oct 9, 2012

Member

oh, thats true

$this->Controller = new MobileComponentTestController(new CakeRequest(null, false), new CakeResponse());
$this->Controller->constructClasses();
$this->Controller->startupProcess();

triggers it.
it tries to read the params in components initialize

markstory added a commit that referenced this pull request Oct 9, 2012

Merge pull request #892 from dereuromark/router-fix
avoid offset -1 error on tests etc

@markstory markstory merged commit 2e15689 into cakephp:master Oct 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment