Friday, January 9, 2015

Reflectionclass loading class from wrong directory

Hi All

After several hours trying to debug an issue that I was having been having with my project, I discovered that _getController in Dispatcher.php is loading the wrong controller (i.e. it's loading a controller from an entirely different project) (the red is debugging):

protected function _getController($request, $response) {
        $ctrlClass = $this->_loadController($request);
        if (!$ctrlClass) {
            return false;
        }
        $reflection = new ReflectionClass($ctrlClass);
    print_r($reflection);
    print_r("<pre>");
    print_r($request);
    print_r("</pre>");
    print_r(dirname($reflection->getFileName()));
    exit();

        if ($reflection->isAbstract() || $reflection->isInterface()) {
            return false;
        }
        return $reflection->newInstance($request, $response);
    }

Here are my debug details:

ReflectionClass Object ( [name] => HomeController )
CakeRequest Object  (      [params] => Array          (              [plugin] =>               [controller] => home              [action] => index              [named] => Array                  (                  )                [pass] => Array                  (                  )            )        [data] => Array          (          )        [query] => Array          (          )        [url] =>       [base] => /MiBubble/RD_20150109/WEB      [webroot] => /MiBubble/RD_20150109/WEB/      [here] => /MiBubble/RD_20150109/WEB/      [_detectors:protected] => Array          (              [get] => Array                  (                      [env] => REQUEST_METHOD                      [value] => GET                  )                [post] => Array                  (                      [env] => REQUEST_METHOD                      [value] => POST                  )                [put] => Array                  (                      [env] => REQUEST_METHOD                      [value] => PUT                  )                [delete] => Array                  (                      [env] => REQUEST_METHOD                      [value] => DELETE                  )                [head] => Array                  (                      [env] => REQUEST_METHOD                      [value] => HEAD                  )                [options] => Array                  (                      [env] => REQUEST_METHOD                      [value] => OPTIONS                  )                [ssl] => Array                  (                      [env] => HTTPS                      [value] => 1                  )                [ajax] => Array                  (                      [env] => HTTP_X_REQUESTED_WITH                      [value] => XMLHttpRequest                  )                [flash] => Array                  (                      [env] => HTTP_USER_AGENT                      [pattern] => /^(Shockwave|Adobe) Flash/                  )                [mobile] => Array                  (                      [env] => HTTP_USER_AGENT                      [options] => Array                          (                              [0] => Android                              [1] => AvantGo                              [2] => BlackBerry                              [3] => DoCoMo                              [4] => Fennec                              [5] => iPod                              [6] => iPhone                              [7] => iPad                              [8] => J2ME                              [9] => MIDP                              [10] => NetFront                              [11] => Nokia                              [12] => Opera Mini                              [13] => Opera Mobi                              [14] => PalmOS                              [15] => PalmSource                              [16] => portalmmm                              [17] => Plucker                              [18] => ReqwirelessWeb                              [19] => SonyEricsson                              [20] => Symbian                              [21] => UP\.Browser                              [22] => webOS                              [23] => Windows CE                              [24] => Windows Phone OS                              [25] => Xiino                          )                    )                [requested] => Array                  (                      [param] => requested                      [value] => 1                  )            )        [_input:protected] =>   )  
/var/www/MiBubble/RD/WEB/app/Controller

What I'm trying to do is access the HomeController from RD_20150109 project, however it's loading from RD.

Can anybody help me with a solution...

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: