This is an old revision of the document!


Uninitialized PHP variables in injected blocks

Some customized themes may reference user initialized global PHP variables in injected blocks. When those ESI blocks render, null pointer errors will occur as those variables may have been initialized earlier but the injected block has no way of recognizing them.

For example, for SNS themes: the footer template may fail to output due to the variable “$var_snstheme” actually being initialized in the header block.

Solution: Find the code where this variable is initialized copy this logic to the template of the injected block. For example, adding the following 2 lines:

global $var_snstheme;
if (empty($var_snstheme)) {
    include (dirname(dirname(__FILE__)).'/sns/sns.php');
}

Similarly, for SM themes (such as sm-maxshop yttheme):

if (empty($var_yttheme)) {
        include (dirname(dirname(__FILE__)).'/sm/yt_prepar.php');
}

Alternatively you can remove footer block injection. This however will slow down page loading time as well as increase cache size and is hence not recommended.

  • Admin
  • Last modified: 2016/05/06 14:10
  • by Michael Alegre