Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2011, 11:58 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Any way to turn off post cache when a particular bb code is used?

I have a BB Code that I modify the exact size of based off a custom user profile field.

I do this by using a hook on bbcode_parse_start, scanning the code for this bb code, and if found setting a custom height.

However while this seemed to work I notice now that the size is usually set by the first person to view it and I guess it's cached. Subsequent viewers don't see it at their specified height but that of whomever viewed it first's height.

This isn't an often used bb code so i figured disabling the post cache if this bb code was used wouldn't be a big deal.

However I'm not seeing how to do this... the code in class_bbcode.php to test if it is cachable is:
Code:
if ($this->options['cachable'])
So I tried just setting $this->options['cachable'] = false, but it doesn't seem to do anything at all.

Would there be some other way of turning off the post cache for a specific post?
Reply With Quote
  #2  
Old 01-13-2011, 09:59 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not completely sure if I know what's going on in the code, or if I get what you're asking, but I think there's different kinds of caching going on. One is to cache results during the processing of a page so that work isn't repeated, like parsing the same signatures over and over in the a thread. Then there's the post cache that survives between user requests. So I think that 'cachable' field in class_bbcode might be for caching signatures during one page request but not between (different users') requests. (I know this doesn't really help you solve your problem).
Reply With Quote
  #3  
Old 01-13-2011, 11:01 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Basically I have a BB Code... in the replacement code there used to be a part that said height="400" in an HTML tag.

But some users with high resolution screens asked for it to be taller than 400 pixels... So I made a custom user profile field where each user can specify the height they want for this particular BB Code.

In the BB Code replacement I changed it from height="400" to height="xxx" (for example) and then on the hook bbcode_parse_start I do a str_replace for "xxx" and swap in the value set by the user in their profile field. For the most part this works except sometimes it gets cached at a different user's value.

In class_bbcode.php there are the following lines around line 440...

Code:
		// save the cached post
		if ($this->options['cachable'])
		{
			$this->cached['text'] = $text;
			$this->cached['has_images'] = $has_img_tag;
		}

		// do [img] tags if the item contains images
		if(($do_bbcode OR $do_imgcode) AND $has_img_tag)
		{
			$text = $this->handle_bbcode_img($text, $do_imgcode, $has_img_tag);
		}

		($hook = vBulletinHook::fetch_hook('bbcode_parse_complete')) ? eval($hook) : false;

		return $text;
I *think* what I have to do is to make this condition false when a specific BB Code is present in $text. (Which is already converted to HTML at this point).

My main question is how can I change the value of $this->options['cachable'] because simply setting it equal to zero or false doesn't appear to have any affect.

Unless what you're telling me it might be working but it's cached somewhere else...
Reply With Quote
  #4  
Old 01-13-2011, 01:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
Unless what you're telling me it might be working but it's cached somewhere else...
Yeah, I guess I was saying that I think the cachable variable in class_bbcode isn't what controls caching of posts across different user requests (like you're describing). But in retrospect I probably shouldn't have replied at all unless I had a better answer than that.
Reply With Quote
  #5  
Old 01-13-2011, 01:58 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Yeah, I guess I was saying that I think the cachable variable in class_bbcode isn't what controls caching of posts across different user requests (like you're describing). But in retrospect I probably shouldn't have replied at all unless I had a better answer than that.
Your replies are ALWAYS welcome. :up:
Reply With Quote
  #6  
Old 02-13-2011, 10:58 AM
dartho dartho is offline
 
Join Date: Sep 2005
Location: Australia
Posts: 2,303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How did you go here BirdOfPrey5 - I'm looking for something similar ...
Reply With Quote
  #7  
Old 02-13-2011, 12:29 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I never did figure it out really... instead of doing the replacements on bbcode_parse_start and bbcode_parse_complete_precache I instead did them on postbit_display_complete, newpost_preview, and newreply_form_reviewbit and I didn't run into the cache issues with these hooks.

The down side is that I needed 3 plugins instead of 2 and it won't work if I ever needed to use the bb code outside a post (say in a social group or signature) but I won't so it's not a big deal- otherwise I'd need even more plugins for those locations.
Reply With Quote
Reply


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 04:24 PM.


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.04329 seconds
  • Memory Usage 2,222KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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