Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP cacheHelper - appController not found error

I added CacheHelper to my app. In my APP/Config/core.php I have

Configure::write('Cache.check', true);

In APP/Config/bootstrap.php I have

Configure::write('Dispatcher.filters', array(
  'AssetDispatcher',
  'CacheDispatcher'
));

In my controller I have:

public $helpers = array('Text', 'Cache');
public $cacheAction = "1 hour";

I don't have any callbacks directly in this controller nor in the AppController. The problem is that each page loads only one time (for example – after cache is cleared). On second request I'm getting back

Fatal Error

Error: Class 'AppController' not found  

If cache is turned off everything works well.

CakePHP version is 2.2.3

Debug Log:

 2012-12-24 12:21:00 Error: Fatal Error (1): Class 'AppController' not found in    [/Volumes/../app/Controller/NewsController.php, line 2]
 2012-12-24 12:21:00 Error: [FatalErrorException] Class 'AppController' not found
 #0 /Volumes/../lib/Cake/Error/ErrorHandler.php(161): ErrorHandler::handleFatalError(1,     'Class 'AppContr...', '/Volumes/Data/D...', 2)
 #1 [internal function]: ErrorHandler::handleError(1, 'Class 'AppContr...', '/Volumes/../D...', 2, Array)
 #2 /Volumes/../lib/Cake/Core/App.php(926): call_user_func('ErrorHandler::h...', 1, 'Class 'AppContr...', '/Volumes/../D...', 2, Array)
 #3 /Volumes/../lib/Cake/Core/App.php(899): App::_checkFatalError()
 #4 [internal function]: App::shutdown()
 #5 {main}

NewsController:

<?php
class NewsController extends AppController {
public $components = array('Security', 'ImageTool', 'Uploader');
public $paginate = array(
        'fields' => array('News.id', 'News.created'),
        'limit' => 5,
        'contain' => array(),
        'order' => array('News.id' => 'DESC'));

public $helpers = array('Text', 'Cache');
public $cacheAction = "1 hour";
like image 750
user1327 Avatar asked Dec 24 '12 07:12

user1327


1 Answers

And the winner is... App::uses('AppController', 'Controller'); at the top of controller code.

App::uses('AppController', 'Controller');

class NewsController extends AppController {
public $helpers = array('Cache');
public $cacheAction = array(
    'index'  => 48000
);

public function index() {

}
public function clear() {
    clearCache();
}
}

I don't know why this is not yet included in the Cookbook.

like image 186
user1327 Avatar answered Sep 29 '22 09:09

user1327