问题
We just upgraded some of our apps (from 1.3) to cakephp 2.2 and refactored the code. our basic server setup looks like
- htdocs/subdomain.domain/cakeapp1/...
- htdocs/subdomain.domain/cakeapp2/...
sometimes we receive errors, which are due to the problem, that cake internally decides to call code from within another app folder. so, we call a route from cakeapp1 and all of a sudden, in the middle of the stack trace, cake calls files from cakeapp2.
so, although no code in cakeapp1 references the "client" table for example, we receive following error:
Missing Database Table
Table clients for model Client was not found in datasource default.
Stack Trace
/home/www/subdomain.domain/cakeapp2/lib/Cake/Model/Model.php line 3180 → Model->setSource(string)
/home/www/subdomain.domain/cakeapp2/lib/Cake/Model/Model.php line 2631 → Model->getDataSource()
/home/www/subdomain.domain/cakeapp2/app/Model/AppModel.php line 22 → Model->find(string, array)
/home/www/subdomain.domain/cakeapp2/app/Controller/AppController.php line 237 → AppModel->find(string, array)
/home/www/subdomain.domain/cakeapp2/app/Controller/AppController.php line 41 → AppController->__initializeAppSettings()
[internal function] → AppController->beforeFilter(CakeEvent)
/home/www/subdomain.domain/cakeapp2/lib/Cake/Event/CakeEventManager.php line 246 → call_user_func(array, CakeEvent)
/home/www/subdomain.domain/cakeapp2/lib/Cake/Controller/Controller.php line 670 → CakeEventManager->dispatch(CakeEvent)
/home/www/subdomain.domain/cakeapp2/lib/Cake/Routing/Dispatcher.php line 183 → Controller->startupProcess()
/home/www/subdomain.domain/cakeapp2/lib/Cake/Routing/Dispatcher.php line 161 → Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse)
APP/webroot/index.php line 92 → Dispatcher->dispatch(CakeRequest, CakeResponse)
Another error is, that a plugin (debugkit) is not found. debugkit is embeded in cakeapp1, but not used in cakeapp2, so it's obvious, that an error is raised in this app. the error itself is saved to cakeapp2/tmp/log/error.log - and NOT to cakeapp1, where the original code should be executed.
has anyone else experienced same problems? the huge problem is, that the error occurs doesn't occur on every page view. but it's reproduceable on different browsers/machines. after calling another url, and re-calling the errored url again, everything's fine again.
was there any change in cakephp2 concerning the usage of cakephp in a subfolder hosting-scenario?
回答1:
You have APC enabled thus causing Cake to use APC as cache engine by default. Currently you haven't changed the $prefix used for cache configs in your app/Config/core.php causing same settings to be used by both apps. Change them to unique values and your issue will be solved.
来源:https://stackoverflow.com/questions/12004740/dispatcher-calls-code-from-another-app-occasionally