• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 3.x Series
    • Bug
    • weird template include problem

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: weird template include problem

    • Issue Tools
      • View Changes
    1. issueid=2512 October 22, 2011 11:03 AM
      Lord Doys Lord Doys is offline
      Junior Member
      weird template include problem

      I found a weird template include problem, ill try to explain whats going on.

      i have reproduced it on
      https://www.vaultwiki.org/demo/TestArjan?redirect=no

      I have a template, lets say: [template]seperator[/template]
      When i use this in a page to seperate text, everything goes well. (first display on TestArjan)

      When i include it in a template, all goes well (third display on TestArjan)

      BUT
      When a template already HAS a template include (see seccond display on TestArjan) the seccond template include gets ignored??
      (many many of my templates and templatecalls have other templates included..)
    Issue Details
    Issue Number 2512
    Issue Type Bug
    Project VaultWiki 3.x Series
    Category Templates
    Status Fixed
    Priority 3 - Loss of Functionality
    Affected Version 3.0.14
    Fixed Version 3.0.15
    Milestone (none)
    Software DependencyAny
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. October 23, 2011 6:49 PM
      pegasus pegasus is offline
      VaultWiki Team
      Okay, took me a while to figure this out, but it's not that the template includes another template. It's that a template is passed as a parameter into another template. I thought this was supported a while back, but it looks like some vulnerability patches broke the functionality.

      What happens is that only the current template level is checked for replacements. In this case the passed templates are resolved in level 1, but they are included in level 2, and the replacement can't occur in level 2 because it was already registered for level 1. In order to fix this, we need to find the template instance by searching the current and upper levels in reverse (still reject templates from a deeper level). Also, we need to modify the way template instances are numbered internally to prevent collisions across levels.

      In vault/class/bbcode/template.php, find:
      Code:
      			if (!isset($threadinfo['templates'][$this->parser->recursion['template'] - 1]["$match[1]"]["$match[2]"]))
      Replace with:
      Code:
      			$args = $this->get_instance($match[1], $match[2]);
      
      			if ($args === null)
      Find and remove:
      Code:
      			$args = $threadinfo['templates'][$this->parser->recursion['template'] - 1]["$title"]["$match[2]"];
      Find:
      Code:
      	function validate_recursion($set, $find)
      Add before:
      Code:
      	function get_instance($title, $pos)
      	{
      		global $threadinfo;
      
      		$i = $this->parser->recursion['template'] - 1;
      
      		for ($c = $i; $c > -1; $c--)
      		{
      			if (isset($threadinfo['templates']["$c"]["$title"]["$pos"]))
      			{
      				return $threadinfo['templates']["$c"]["$title"]["$pos"];
      			}
      		}
      
      		return null;
      	}
      In vault/class/bbcode.php, find:
      Code:
      			$instance = count($threadinfo['templates'][$this->recursion['template']]["$templatelow"]);
      Replace with:
      Code:
      			static $template_count;
      
      			$template_count["$templatelow"]++;
      			$instance = $template_count["$templatelow"];
      Reply Reply  
    2. October 24, 2011 3:39 PM
      Lord Doys Lord Doys is offline
      Junior Member
      when changing the code like above, my live server doesnt include the template tables anymore, and on localhost it does not seem to work.
      I have noticed by previous fixes as well.. wondering why the fix didnt work, and uploaded the new build.. and tadaaa

      this is not a showstopper for me, so it can wait untill next build
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 4:31 AM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.