![]() |
Unnecessary query?
In global.php
$show['modcplink'] is being set (for the ModCP-Link in template footer). This seems to trigger a query in can_moderate() if the user is not an admin or supermod - for every page being generated. I wonder if it wouldn't be possible to use some cache (datastore) instead to avoid this query and if this could improve performance? |
the first if does just use the permission cache, so no query is done until:
PHP Code:
|
> just if the cache has not been created, it will do a query.
That's the point. $imodcache is being build in cache_moderators() which itself gets called from forumdisplay.php, index.php, search.php & usercp.php - after processing global.php. And what about the others like showthread.php, newreply.php and so on? |
Seeing as cache_moderators() requires a query and so does can_moderate() using can_moderate() would be prefered as its doing less work. It does seem that in my RC3 copy that they have 'forgotten/not included yet' the caching in the can_moderate() function, the $modcache variable is there, yet its never set, which causes extra queries every time can_moderate() is called where it could quite possibly return a cached value instead.
|
*bump*
Now that RC4 is available it seems like this doesn't have changed :( Example ----------- If a thread is being displayed (by a normal user, 40 posts/page) and can_moderate() is being called from the postbit I get 42 (!) times the same query: Code:
SELECT moderatorid, permissions FROM moderator WHERE userid = 3 |
ugh you querry freaks :P
|
So you have 42+ queries on that page? Thats not good. I'm sure some caching is ment to be used in the function, create a bug report at vB.com.
|
Quote:
|
@Faranth
It's very easy to reproduce: 1) Take a vanilla vB3 RCwhatever 2) Enable debug mode (to see # of queries) 3) Put an <if condition="can_moderate()"></if> at the start of template postbit 4) Display a thread with > 40 posts as a normal user (setting display-mode to 40 posts/page) |
you should definitely report it.
vb.com will surely look into it :) |
http://www.vbulletin.com/forum/bugs....iew&bugid=2224
Status: Closed (Fixed) But no reply :( So I guess i'll have to wait for the next RC ... |
yes you have...
btw, you're showing up unlicensed now... |
I do? I don't get that "You're unlicensed remider"
Anyway, that's bollox :) I've had problems to get rid of that "you're unlicensed" at vB-germany.com and they suggested to remove my email from the member area and afterwards add it again. I did so ... that could be the reason. |
Either way its worked and you appear licenced again. Good to see this nasty bug fixed too :)
|
yes, that would explain the short unlicensed period ;)
|
To confirm, does the bug report showing fixed in RC4 mean that it was reported under RC4 ? or fixed for RC4 ?
|
Quote:
PHP Code:
|
Quote:
|
Good thing it was fixed...I relied on this function for a lot of stuff in custom templates I develop.
|
Where would you add that code at?
|
@Bob: in the can_moderate function in functions.php
good thing, i used my selfwritten ismod() function for such things which remained from vb2 times ^^ |
In place of this? Or is there some more?
PHP Code:
|
correct just that one :)
|
Thank you, sir. ;)
|
Thanks for the clarification :)
|
I reported this bug back in beta 5 or so already, and then they just told me "you shouldn't use can_moderate() in a postbit" :|
|
All times are GMT. The time now is 04:30 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|