Why all three lines are returning TRUE, if YII_DEBUG constant is actually set to FALSE (which I can observe by how exceptions messages are being displayed).
Why second line is just displaying “true” (omitting 'YII_DEBUG = ’ part)?
Why exception messages are displayed in English (“CDbConnection failed to open the DB connection”) when YII_DEBUG is set to FALSE and in Polish (“Obiekt CDbConnection: błąd przy otwieraniu połączenia do bazy danych”)? Application is configured to use Polish (‘language’=>‘pl’).
EDIT: Should be if(YII_DEBUG == TRUE) (without quotes!) in the last line of course, but it doesn’t change anything here - still showing TRUE, when YII_DEBUG is set to FALSE!
You cannot change the value of Yii_debug once it is set, as it is a constant.
You should change it in the index.php, where it is setted:
Change from:
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
To:
// remove the following lines when in production mode
//defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
//defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
I was not trying to change it! I was trying to read its value.
It was my mistake. Found out that mistakenly took PHP’s defined as function for reading constant value while it is used to check, whether it is only defined.
But I still can’t understand, why error messages gets auto-magically translated back to English (or to be more precise - are NOT being translated into Polish) when YII_DEBUG is set to FALSE?
I noticed this only on DB connection exception message, but believe, it will be related to any exception. As I wrote earlier:
I’m getting “CDbConnection failed to open the DB connection”, when YII_DEBUG is set to FALSE, why I should get Polish translation of this message (as I’m getting, when YII_DEBUG is set to TRUE) since application language is defined to ‘pl’.
Well, I know that I have some false reports in the history of this forum! :] But, believe me, I wouldn’t report something that I wouldn’t be so sure about…
I agree that I slightly modified translation files to suit my needs, but these was only string or text-based changes (translation tune-up) and I don’t believe they could influence current situation in any way.
Take a look at attached screen-shots.
1221
1222
Situation, as described above. When YII_DEBUG is set to TRUE, I see translated message (as excepted) plus additional information returned from DB driver. When YII_DEBUG is set to FALSE, message is not translated (this is the same message - i.e. the same error or exception, tested in the same situation) and (also as excepted) no additional information from DB driver added, as it isn’t added in production mode.
First of all - I don’t know what happened or what I did in my project as up until yesterday I wasn’t using YII_DEBUG set to False. All the time my application went in debug mode.
These screenshots are comming from my older version of error handler, before I introduced this solution proposed by Yii.
This is the code of my Controller::onBeginRequest, where I previously holded my error handler:
public static function beginRequest()
{
try
{
if(Yii::app()->db->active)
{
if(!Yii::app()->user->isGuest)
{
//Send current user ID to database...
$sql = 'BEGIN LWWW.SetCurrentUser('.app()->user->id.'); END;';
app()->db->createCommand($sql)->execute();
}
}
}
catch(Exception $e)
{
//Here - my so called error handler...
//...some error text formating routines...
//...line directly responsible for displaying exception text...
$error_message.= '<div class="flash-error">'.$e->getMessage().'</div>';
//...some other errror text formating routines...
}
}
I priovided only the line that is printing out message being displayed once in Polish, once in English. All other lines hidden to short code.