Closed (duplicate)
Project:
Privatemsg
Version:
4.7.x-1.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Aug 2007 at 23:14 UTC
Updated:
12 Jan 2009 at 19:25 UTC
By inserting an error_log() statement in the _privatemsg_get_new_messages(), I saw that the database query (SELECT COUNT(*) FROM {privatemsg} WHERE recipient = %d AND newmsg = 1 AND recipient_del = 0) was being run whether I was logged in or not.
This doesn't make sense. There's no point in doing this query if the user is anonymous/not logged in.
I have written a patch to fix this. I'm sure there's a more "Drupal" way to do this, but I don't know all the ins and outs. This works, and maybe with a cleanup or two we can be on our way to saving privatemsg.module users a TON of unecessary db queries.
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| privatemsg_no_db_query_for_anonymous_user.patch | 751 bytes | apotek |
Comments
Comment #1
czarphanguye commentednice.
Comment #2
Roman S commentedThis problem still exists in the latest code. Moreover, every call to a non-page resource on the server (using private files) hits the DB as well!
Comment #3
Roman S commentedChanging version back, since that's what the original patch was for...
Comment #4
apotek commentedOkay, I submitted a patch for the 5.x-3.0 version instead. So this is now an out-of-date duplicate of that bug. Please see http://drupal.org/node/357783