vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   performance: postbit_display_complete hook (https://vborg.vbsupport.ru/showthread.php?t=224651)

al3bed 10-05-2009 09:56 PM

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

Lynne 10-05-2009 11:02 PM

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.

al3bed 10-06-2009 06:29 AM

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?

Lynne 10-06-2009 01:05 PM

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.


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

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01483 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete