diff options
author | haertl.mike <> | 2009-02-11 15:24:27 +0000 |
---|---|---|
committer | haertl.mike <> | 2009-02-11 15:24:27 +0000 |
commit | f6a77cd876890c71285574480d61f836bf204421 (patch) | |
tree | 45650975490ff77888a3cbf6be5ac5173ba8ea4c | |
parent | c8861d5cfc5779d2c7edd450a66d60b590364fc5 (diff) |
Added caching of message files to TException
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | framework/Exceptions/TException.php | 21 |
2 files changed, 15 insertions, 9 deletions
@@ -1,7 +1,8 @@ Version 3.1.5 (to be released) ============================== BUG: URL wildcard patterns didn't work with subfolders -BUG: Issue~107 - typo in TDbConnection::getCharset() (Christophe) +BUG: Issue#107 - typo in TDbConnection::getCharset() (Christophe) +ENH: Added caching of message files to TException (Michael) Version 3.1.4 January 11, 2009 ============================== diff --git a/framework/Exceptions/TException.php b/framework/Exceptions/TException.php index c6a87b4d..073b587d 100644 --- a/framework/Exceptions/TException.php +++ b/framework/Exceptions/TException.php @@ -35,6 +35,7 @@ class TException extends Exception
{
private $_errorCode='';
+ static $_messageCache=array(); /**
* Constructor.
@@ -64,16 +65,20 @@ class TException extends Exception protected function translateErrorMessage($key)
{
$msgFile=$this->getErrorMessageFile();
- if(($entries=@file($msgFile))!==false)
- {
- foreach($entries as $entry)
+ + // Cache messages + if (!isset(self::$_messageCache[$msgFile])) + { + if(($entries=@file($msgFile))!==false)
{
- @list($code,$message)=explode('=',$entry,2);
- if(trim($code)===$key)
- return trim($message);
+ foreach($entries as $entry)
+ {
+ @list($code,$message)=explode('=',$entry,2);
+ self::$_messageCache[$msgFile][trim($code)]=trim($message); + }
}
- }
- return $key;
+ } + return isset(self::$_messageCache[$msgFile][$key]) ? self::$_messageCache[$msgFile][$key] : $key;
}
/**
|