Hi everyone,
I wasn’t quite sure which forum to put this in, but I am having issues parsing a few templates and wanted to see if anyone had the same issue. I have a few templates that do not render at all – the page loads completely blank. They used to load on my EE2 site, but no longer do on EE3. (I am in the middle of taking a site from EE 2.9.0 to EE 3.5.10.) There are no PHP errors (setting “debug = 1” in index.php and admin.php do not make a difference) nor are there errors in the console.
I think I’ve tracked down the issue: it has to do with how the template is parsed. This is from system/ee/EllisLab/ExpressionEngine/Library/Parser/Conditional/Parser.php
public function parse()
{
$this->openBuffer();
do
{
$this->next();
$this->template();
}
while (count($this->tokens));
$this->expect('EOS');
$out = $this->closeBuffer(FALSE);
return preg_replace('/^\n?(.*?)\n?$/is', '$1', $out);
}
For these templates that do not load, the preg_replace
function returns null instead of a string. This comment from the PHP manual was helpful to me: http://php.net/manual/en/function.preg-replace.php#84285 Basically, I think there is too much content in the page markup, so the preg_replace command fails and returns NULL. I have tested out changing the regex to be not greedy (preg_replace('/^\n?(.*?)\n?$/isU', '$1', $out);
) and the templates render successfully. Is this a bug? Or would changing the regex to be non-greedy break other things on the site?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.