Index: branches/5.2.x/core/units/helpers/template_helper.php =================================================================== diff -u -N -r13840 -r14095 --- branches/5.2.x/core/units/helpers/template_helper.php (.../template_helper.php) (revision 13840) +++ branches/5.2.x/core/units/helpers/template_helper.php (.../template_helper.php) (revision 14095) @@ -1,6 +1,6 @@ Application->GetVar('block'); list ($this->_blockName, $this->_functionName) = explode(':', $block_info); @@ -111,26 +109,22 @@ */ function _parseTemplate(&$object, $append = '') { - // 1. set internal error handler to catch all parsing errors - $error_handlers = $this->Application->errorHandlers; - $this->Application->errorHandlers = Array ( - Array (&$this, '_saveError'), - ); + try { + // 1. parse template + $this->Application->InitParser( $this->_getThemeName() ); // we have no parser when saving block content - // 2. parse template - $this->Application->InitParser( $this->_getThemeName() ); // we have no parser when saving block content + $this->_getSourceTemplate(); - $this->_getSourceTemplate(); + // 2. design templates have leading "/" in the beginning + $this->Application->Parser->Run($this->_sourceTemplate . $append); + } + catch (ParserException $e) { + $this->_parseErrors[] = Array ('msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()); + } - // design templates have leading "/" in the beginning - $this->Application->Parser->Run($this->_sourceTemplate . $append); - - // 3. restore original error handler - $this->Application->errorHandlers = $error_handlers; - if ($this->_parseErrors) { if ($this->_isMainTemplate()) { - // 3.1. delete temporary file, that was parsed + // 2.1. delete temporary file, that was parsed $filename = $this->_getTemplateFile(false, $append . '.tpl'); if (!unlink($filename)) { $error_file = $this->_getTemplateFile(true, $append . '.tpl'); @@ -139,7 +133,7 @@ } } else { - // 3.2. restore backup + // 2.2. restore backup if (!rename($this->_getTemplateFile(false, '.tpl.bak'), $this->_getTemplateFile(false))) { $error_file = $this->_getTemplateFile(true); $object->SetError('FileContents', 'template_restore_failed', '+Failed to restore template "' . $error_file . '" from backup.'); @@ -440,20 +434,4 @@ return crc32($template_body) == crc32($new_template_body) ? true : $new_template_body; } - - function _saveError($errno, $errstr, $errfile, $errline, $errcontext) - { - if ($errno != E_USER_ERROR) { - // ignore all minor errors, except fatals from parser - return true; - } - - /*if (defined('E_STRICT') && ($errno == E_STRICT)) { - // always ignore strict errors here (specially when not in debug mode) - return true; - }*/ - - $this->_parseErrors[] = Array ('msg' => $errstr, 'file' => $errfile, 'line' => $errline); - return true; - } } \ No newline at end of file