2012-09-15 60 views
0

退房線#2,#3,從底部開始:FOSUserBundle被查詢兩次獲得用戶

[2012-09-11 16:44:55] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] request.INFO: Matched route "myapp_main_default_index" (parameters: "_controller": "Myapp\MainBundle\Controller\DefaultController::indexAction", "_route": "myapp_main_default_index") [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] security.DEBUG: Read SecurityContext from the session [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] security.DEBUG: Reloading user from user provider. [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] doctrine.INFO: MongoDB query: {"find":true,"query":{"_id":{"$id":"504f548c8c2d892617000000"}},"fields":[],"db":"myapp_db","collection":"User"} [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] doctrine.INFO: MongoDB query: {"limit":true,"limitNum":1,"query":{"_id":{"$id":"504f548c8c2d892617000000"}},"fields":[]} [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] doctrine.INFO: MongoDB query: {"limit":true,"limitNum":1,"query":{"_id":{"$id":"504f548c8c2d892617000000"}},"fields":[]} [] {"token":"504f6a8727898"} 
[2012-09-11 16:44:55] security.DEBUG: Username "test" was reloaded from user provider. [] {"token":"504f6a8727898"} 

我看來,像它使一個重複的查詢。

我該怎麼辦?

+0

如果沒有提供代碼,很難追蹤到。 大多數IDE支持使用xDebug進行調試,您可以按照執行的每一行執行。 PHPStorm,Eclipse ..選擇你的武器並追蹤下來:) – weyandch

+0

你可以啓用MongoDB [profiler](http://www.mongodb.org/display/DOCS/Database+Profiler)級別爲2(所有查詢)來確認是否有實際的雙重查詢,或者這只是一個日誌異常。我對FOSUserBundle並不熟悉,但它可能會將多個(重複)查詢作爲其邏輯的一部分。 – Stennie

回答

0

現在我認爲它不是多次查詢,它只是如何記錄。在其他查詢中,查詢的每個部分都有1個日誌行,但開發工具欄顯示爲1個查詢,所以它必須是正確的。