The "afterSave" method is called for a very long time

I have such method in controller, that simple sets value of status field to 0 or 1.

public function actionNews_status($id,$status){

    $status = ($status==1)?1:0;

    $number = false;

    $news = News::findOne($id);


        $news->status = $status;

        $number = $news->save();

        Redis::rset($CACHE_mat, null);


    return json_encode(['status'=>$number]);


This method works for about 20 seconds.

I learned that the status field itself is updated immediately, since the query to the table instantly shows the changes. But the save method continues after that to work for a long time.

Then I found out the following… Slowly running the afterSave method call at the end of the updateInternal. But before the line with this call, the script is executed quickly.

Slowly works a call the afterSave by itself, not a code inside afterSave method and not code before afterSave calling.

Why this can happen?

Problem solved. Cause was found in overrided “afterSave” method in model class :)

To help others. What was wrong with the afterSave() override?

Simple some long operation(not relation with yii) before the call of parent::afterSave.

I forgot that the "afterSave" is overrided and could not understand why it is called for so long.