Tuesday, October 21, 2014

Cakephp error handling goes haywire after Controller::viewVars and filtered through htmlentities

Using Cakephp 2.5.4 on a fresh cake code base.
I have my AppController Setup as follows.

class AppController extends Controller {
   
public function beforeRender() {
       
// Filter all output
        array_walk_recursive
($this->viewVars, [$this, 'escapeOutput']);
       
// throw new NotFoundException('invalid url');
   
}

   
public function escapeOutput(&$value, $key) {
        $value
= htmlentities($value);
   
}
}

This works as expected. However if I now throw an error (uncomment the line after array_walk) cake throws an extra error as follows.

Fatal error: Call to a member function getMessage() on a non-object in **/lib/Cake/View/Errors/fatal_error.ctp on line 21

Could someone explain what is going on?

--
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: