Wednesday, August 21, 2013

Wrong AppController called when 2 projects are accessed simultaneously

Hi,
I am using CakePHP 2.2.1, and running 2 cake projects on my machine.
Both projects use the same plugins, i.e. I have simlinks in the app/Plugin folders of both project that link to CakePHP/trunk/plugins/

If I access either project separately I don't have any issues but if I access both projects around the same time, the beforeFilter of the wrong AppController is called.

example: 
1) log into PROJECT1
2) log into PROJECT2 from different tab or browser or machine
3) The following error appears in the PROJECT2 browser:

The datasource configuration "master" was not found in database.php

Stack Trace
  1. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/ConnectionManager.php line 94 → ConnectionManager::_getConnectionObject(string)
  2. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Model.php line 3158 → ConnectionManager::getDataSource(string)
  3. /opt/repos/PROJECT1/trunk/app/Model/AppModel.php line 87 → Model->setDataSource(string)
  4. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/Session/DatabaseSession.php line 141 → AppModel->deleteAll(array, boolean, boolean)
  5. [internal function] → DatabaseSession->gc(integer)
  6. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 617 → session_start()
  7. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 189 → CakeSession::_startSession()
  8. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 361 → CakeSession::start()
  9. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Controller/Component/SessionComponent.php line 70 → CakeSession::read(string)
  10. /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/Component/AuthaclComponent.php line 207 → SessionComponent->read(string)
  11. /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 25 → AuthaclComponent->getGroupNames()
  12. /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 62 → AppController->_authConfig()
  13. /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 13 → AppController->_auth()
  14. /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/AuthaclAppController.php line 7 → AppController->beforeFilter()
  15. /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/UserController.php line 591 → AuthaclAppController->beforeFilter()
  16. [internal function] → UserController->beforeFilter(CakeEvent)
  17. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Event/CakeEventManager.php line 246 → call_user_func(array, CakeEvent)
  18. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Controller/Controller.php line 670 → CakeEventManager->dispatch(CakeEvent)
  19. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Routing/Dispatcher.php line 184 → Controller->startupProcess()
  20. /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Routing/Dispatcher.php line 162 → Dispatcher->_invoke(UserController, CakeRequest, CakeResponse)
  21. ROOT/webroot/index.php line 101 → Dispatcher->dispatch(CakeRequest, CakeResponse)
At lines 3, 11, 12 and 13, we can see that the AppController in PROJECT1 is called, even though this error page is appearing in PROJECT2!
In this case the error is a missing datasource configuration because cake seem to expect a "master" configuration in PROJECT2, even though this configuration only exists in PROJECT1. A similar problem occurs if I login PROJECT2 first and PROJECT1 second.

The sessions are configured as follow in app/Config/core.php

for PROJECT1:
  Configure::write('Session', array(
'defaults' => 'database',
'cookie' => 'PROJECT1',
'timeout' => '144000',
'cookieTimeout' => '144000',
'checkAgent' => false,
'autoRegenerate' => false,
'handler' => array(
'database' => 'master',
'model' => 'Session'
)
  ));

For PROJECT2:
Configure::write('Session', array(
'defaults' => 'database',
'cookie' => 'PROJECT2',
'timeout' => 60,
'cookieTimeout' => 60,
'checkAgent' => false,
'autoRegenerate' => false,
'handler' => array(
'database' => 'default',
'model' => 'Session'
)
));

How can I force the correct appController to be called? Please help.

--
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/groups/opt_out.

No comments: