Wrong AppController called when 2 projects are accessed simultaneously

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Wrong AppController called when 2 projects are accessed simultaneously

Julien Duhain
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Wrong AppController called when 2 projects are accessed simultaneously

Andras Kende
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 <[hidden email]> 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 [hidden email].
> To post to this group, send email to [hidden email].
> 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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Wrong AppController called when 2 projects are accessed simultaneously

Julien Duhain
Thanks a mil Andras!!
I actually had to change the prefix for _cake_core_ 

Cache::config('_cake_core_', array(
'engine' => $engine,
//        'prefix' => 'cake_core_',
'prefix' => 'project1_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));

but your advice put me on the right track.
Have a great day.

On Wednesday, August 21, 2013 10:51:07 AM UTC+2, Andras Kende wrote:
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_qdRudchn-sJ">julien...@...> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_qdRudchn-sJ">cake-php+u...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_qdRudchn-sJ">cake...@....
> 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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.