Reply to thread

Related to; https://xenforo.com/community/threads/redundant-io-check-on-loading-phrase-group.195751/


In XF\Template\Templater::getTemplateDataFromSource, there is a file_exists check before an include call, which is redundant;


[CODE="php"]protected function getTemplateDataFromSource($type, $name)

{

   $file = $this->getTemplateFilePath($type, $name);

   if (!file_exists($file))

   {

      return false;

   }


   return include($file);

}[/CODE]


include returns false on if the file can't be accessed or readable (the warning is converted into an exception by XF), as such the file_exists check is redundant.


Rough prototyped replacement;

[CODE="php"]protected function getTemplateDataFromSource($type, $name)

{

   $file = $this->getTemplateFilePath($type, $name);

   try

   {

     return include($file);

   }

   catch (\Throwable $e)

   {

     return false;

   }

}[/CODE]


Back
Top Bottom