Wednesday, August 21, 2013

Re: Wrong AppController called when 2 projects are accessed simultaneously

try to change prefix to unique ...

core.php
// Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts.
$prefix = 'myapp_';



Andras Kende
http://www.kende.com

On Aug 21, 2013, at 12:48 AM, JD <julien.duhain@gmail.com> wrote:

> 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
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/ConnectionManager.php line 94 → ConnectionManager::_getConnectionObject(string)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Model.php line 3158 → ConnectionManager::getDataSource(string)
> • /opt/repos/PROJECT1/trunk/app/Model/AppModel.php line 87 → Model->setDataSource(string)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/Session/DatabaseSession.php line 141 → AppModel->deleteAll(array, boolean, boolean)
> • [internal function] → DatabaseSession->gc(integer)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 617 → session_start()
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 189 → CakeSession::_startSession()
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Model/Datasource/CakeSession.php line 361 → CakeSession::start()
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Controller/Component/SessionComponent.php line 70 → CakeSession::read(string)
> • /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/Component/AuthaclComponent.php line 207 → SessionComponent->read(string)
> • /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 25 → AuthaclComponent->getGroupNames()
> • /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 62 → AppController->_authConfig()
> • /opt/repos/PROJECT1/trunk/app/Controller/AppController.php line 13 → AppController->_auth()
> • /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/AuthaclAppController.php line 7 → AppController->beforeFilter()
> • /opt/repos/CakePHP/trunk/plugins/Authacl/Controller/UserController.php line 591 → AuthaclAppController->beforeFilter()
> • [internal function] → UserController->beforeFilter(CakeEvent)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Event/CakeEventManager.php line 246 → call_user_func(array, CakeEvent)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Controller/Controller.php line 670 → CakeEventManager->dispatch(CakeEvent)
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Routing/Dispatcher.php line 184 → Controller->startupProcess()
> • /opt/repos/CakePHP/cakephp-2.2.1/lib/Cake/Routing/Dispatcher.php line 162 → Dispatcher->_invoke(UserController, CakeRequest, CakeResponse)
> • 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.

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