Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 10-05-2009, 10:56 PM
al3bed's Avatar
al3bed al3bed is offline
 
Join Date: Sep 2006
Location: Bahrain
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default performance: postbit_display_complete hook

hello,

I face a performance problem with postbit_display_complete hook. this hook can't read from other hooks such as global_start and parse_templates? also this hook can't replace str from forum templates? I used a fetch_array function in parse_templates to declare variables fetching a template like below:

PHP Code:
/* ADS VARIABLES */
$vbulletin->db->hide_errors();
$ain_info $vbulletin->db->query_read("
SELECT id, type, content, slot, channel, width, height
FROM " 
TABLE_PREFIX "ainads AS ainads
ORDER BY id ASC  "
);

while (
$ain_data $vbulletin->db->fetch_array($ain_info))
{
    
$ainads_doneid $ain_data[id];
    eval(
'$ain_ads[$ainads_doneid] .= "' fetch_template('ain_showads') . '";');
}
$vbulletin->db->show_errors();
/* END ADS VARIABLES */ 
this will give me 3 queries executed in normal case if I have 3 raws of data.
but if i but this code in postbit hook will execute each time postbit show.. so
if I have a 10 posts within the page it's will give me 3*10= 30 queries! too much

how can I solve this? I want to use the variables templates called by postbit_display_complete, but they don't work if I don't but the code in the hook.

hope it's clear enough?
sorry for my bad english

thanks
Reply With Quote
  #2  
Old 10-06-2009, 12:02 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why use the postbit_display_complete hook if you don't want it run each time a postbit is displayed? I fyou only want it run once per page on a thread, then pic another hook location (a showthread_* one?). I don't see anything in that plugin that has to be run in the postbit hook location.
Reply With Quote
  #3  
Old 10-06-2009, 07:29 AM
al3bed's Avatar
al3bed al3bed is offline
 
Join Date: Sep 2006
Location: Bahrain
Posts: 190
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use postbit_display_complete becuase I need to execute some codes inside postbit

the only one I don't want to execute it each time a postbit displayed is the code above.

but still I need to execute it once.

Q. If I put the previous code in a showthread_* one I can use VARIABLES declared there in postbit_display_complete?
Reply With Quote
  #4  
Old 10-06-2009, 02:05 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would try putting that in a plugin that uses in the correct showthread_* hook location (one that is run after the postbit_* hook you are using to create the variables) and see what happens. You may have to use the variable $GLOBALS['yourvariable'], but I would try without doing that first.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:02 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03585 seconds
  • Memory Usage 2,184KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete