I have been given an application to keep running that is using Yii 1.1. For the time being I can not update it to Yii 2.0. The problem I'm having is that I'm trying to do some debugging with Yii::log() but it is only writing the first call of log() to the log file. I can't show the exact code but the idea is as follows.
public static function foo(){
Yii::log('Entered foo()', 'dev', 'My.Code.Example');
$thing = aDataBaseQuery();
if($thing !== null){
Yii::log('foo(): thing is not null', 'dev', 'My.Code.Example');
Example::bar($thing);
}
}
public static function bar($thing){
Yii::log('Entered bar()', 'dev', 'My.Code.Example');
if($thing !== null && $thing->column_name!='none'){
Yii::log('bar(): got past first if', 'dev', 'My.Code.Example');
$thing->setAttribute("column_name","some");
$thing->save();
}
}
The log file shows the 'Entered foo()' message, but none of the others. But I know it must be entering the if statment in bar() because the column_name of the expected database entry is updated to "some". So my question is, what could be causing the other 3 log lines to not write to the log?
EDIT: So after messing around with it for a while I'm more confused then when I started. I just added an else to the if statement in foo() so that it is:
public static function foo(){
Yii::log('Entered foo()', 'dev', 'My.Code.Example');
$criteria = new CDbCriteria();
$criteria->condition = "status='false'";
$thing = CActiveRecord::model()->find($criteria);
if($thing !== null){
Yii::log('foo(): thing is not null', 'dev', 'My.Code.Example');
Example::bar($thing);
} else {
Yii::log('foo(): thing is null', 'dev', 'My.Code.Example');
}
}
public static function bar($thing){
Yii::log('Entered bar()', 'dev', 'My.Code.Example');
if($thing !== null && $thing->column_name!='none'){
Yii::log('bar(): got past first if', 'dev', 'My.Code.Example');
$thing->setAttribute("column_name","some");
$thing->save();
}
}
The log reads
[dev] [My.Code.Example] Entered foo()
[dev] [My.Code.Example] foo(): thing is null
But when I query the database, the entry is updated so that column_name is some.