Saturday, February 4, 2012

CakePHP shows a blank page on PHP errors when using Security component

Hello,

I'm trying to investigate a problem with CakePHP ver. 2.0.5 - when
there is an error in controller class (i.e. trying to create an object
from nonexistent class) I get a blank page rendered, no errors,
warnings or sql dumps. Debug level is set to 2 in Config/core.php.
Problem appears only when Security component is included in
AppController.php.

Here is sample code:

/*file app/Controller/AppController.php*/
<?php
class AppController extends Controller {

public $helpers = array(
'Html',
'Js' => array('Jquery'),
'Form',
'Session'
);

public $components = array(
'Security'
'RequestHandler',
'Session',
'Acl'
);

public function blackhole ($type) {
pr('Security blackhole ' . $type);
}

public function beforeFilter ($noAction = false) {
parent::beforeFilter();
$this->Security->blackHoleCallback = 'blackhole';
}

public function beforeRender() {
parent::beforeRender();
}

public function afterFilter() {
parent::afterFilter();
}
}
?>

/*file app/Controller/CustomerDetailsController.php*/
class CustomerDetailsController extends AppController{

public $name = 'CustomerDetails';

public function beforeFilter() {
parent::beforeFilter();
}

public function create(){
$this->autoRender = false; //Just for testing purpose - Cake doesn't
render the view
pr('controller action'); //Never showed
$xfgb = new sfg; //Nonexistent class
}
}
?>

/*file app/Model/CustomerDetail.php*/
<?php
class CustomerDetail extends AppModel{

public $name='CustomerDetail';

}
?>

Removing the Security component from the $components array makes the
trick - the application shows PHP error:
Fatal error: Class 'sfg' not found in APP/Controller/
CustomerDetailsController.php on line 14,
but with Security component enabled page is completely blank making
debugging hard (I can see the PHP error in apache logs though).

Another oddity is that restarting the apache web server causes error
to appear just once - the first load of the page app/CustomerDetails/
create is with raised error on it, but all reloads after that end with
blank page. Restarting apache and voila - error is here again only on
first page load.

I've created a simple PHP script with object instance of nonexistent
class outside CakePHP and it works as expected - every call ends with
PHP fatal error that class **** was not found.

Any help will be appreciated.
Regards,
Niki


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate