static function executeCompilation($tpl, &$textElements, $key, &$resourceData, $rootNamespace, $currentNamespace) { if (!eZTemplateCompiler::isCompilationEnabled()) { return false; } if (!eZTemplateCompiler::isExecutionEnabled()) { return false; } $cacheFileName = eZTemplateCompiler::compilationFilename($key, $resourceData); $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled(); $directory = eZTemplateCompiler::compilationDirectory(); $phpScript = eZDir::path(array($directory, $cacheFileName)); if (file_exists($phpScript)) { $text = false; $helperStatus = eZTemplateCompiler::executeCompilationHelper($phpScript, $text, $tpl, $key, $resourceData, $rootNamespace, $currentNamespace); if ($helperStatus) { $textElements[] = $text; return true; } else { eZDebug::writeError("Failed executing compiled template '{$phpScript}'", 'eZTemplateCompiler::executeCompilation'); } } else { eZDebug::writeError("Unknown compiled template '{$phpScript}'", 'eZTemplateCompiler::executeCompilation'); } return false; }
/** * Tries to execute the compiled template. Returns true if successful, * returns false if the compilation is disabled or the compiled template * does not exist. * * @param eZTemplate $tpl * @param array $textElements * @param string $key * @param array $resourceData * @param $rootNamespace * @param $currentNamespace * * @throws eZTemplateFailedExecutingCompiledTemplate if the compiled * template could not be executed * @return bool */ static function executeCompilation($tpl, &$textElements, $key, &$resourceData, $rootNamespace, $currentNamespace) { if (!eZTemplateCompiler::isCompilationEnabled()) { return false; } if (!eZTemplateCompiler::isExecutionEnabled()) { return false; } $cacheFileName = eZTemplateCompiler::compilationFilename($key, $resourceData); $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled(); $directory = eZTemplateCompiler::compilationDirectory(); $phpScript = eZDir::path(array($directory, $cacheFileName)); if (file_exists($phpScript)) { $text = false; $helperStatus = eZTemplateCompiler::executeCompilationHelper($phpScript, $text, $tpl, $key, $resourceData, $rootNamespace, $currentNamespace); if ($helperStatus) { $textElements[] = $text; return true; } else { eZDebug::writeError("Failed executing compiled template '{$phpScript}'," . " if this file is valid, then the error is probably" . " related to APC usage, try restarting the webserver", __METHOD__); throw new eZTemplateFailedExecutingCompiledTemplate("Failed executing a compiled template, see error.log for details"); } } else { eZDebug::writeError("Unknown compiled template '{$phpScript}'", __METHOD__); } return false; }