Child pages
  • [template parser] Inefficient parser template compilation [5.3.0-B1]
Skip to end of metadata
Go to start of metadata

The 2 major components of each In-Portal-based website are:

  • events - PHP code, that handles form submits and similar actions on server-side
  • templates - files with TPL extension (are compiled into PHP files for better performance), that contain HTML of website pages

The compilation of templates happens like this:

  1. find all <inp2:SampleTagName/> (non-pair) and <inp2:SampleTagName> ... </inp2:SampleTagName> (pair) tags (anything can be in "SampleTagName" place)
  2. check if "_Tag_SampleTagName" class name exists:
    1. if it does, then use ask it to provide compiled PHP code for a given tag
    2. if it doesn't exist, then use generic compiled PHP code for a given tag
  3. repeat for every other tag in template

It all works perfectly, but under the hood problem is with 2nd step: class existence checking (the "class_exists" function):

nparser.php
$tag['is_closing'] = $tag['opening'] == '</' || $tag['closing'] == '/>';
if (class_exists('_Tag_'.$tag['name'])) { // block tags should have special handling class
   if ($tag['opening'] == '<') {
      $class = '_Tag_'.$tag['name'];

The problem is with "class_exists" function, that in case of missing class calls all registered auto-loaders to check if they can load that class. Because 100% of non-pair tags don't use special "_Tag_" class this creates a delay during template compilation.

Solution

  1. wait for Introduce base-class based sub-class discovery [5.3.0-B1] to be implemented
  2. at template parser class creation time query all sub-classes of "_Tag" class and store them in template parser property
  3. replace the "class_exists" check with check on previously store class property

That should seriously decrease time, needed to compile a template with a lot of tags.

Related Tasks

INP-1430 - Getting issue details... STATUS