Closed maxxer closed 8 years ago
Possible fix:
11:50 $ diff -Naur vendor/bupy7/yii2-activerecord-history/behaviors/History_orig.php vendor/bupy7/yii2-activerecord-history/behaviors/History.php --- vendor/bupy7/yii2-activerecord-history/behaviors/History_orig.php 2016-10-05 11:49:56.683069585 +0200
+++ vendor/bupy7/yii2-activerecord-history/behaviors/History.php 2016-10-05 11:04:15.699624100 +0200
@@ -100,6 +100,8 @@
*/
public function saveHistory(Event $event)
{
+ if(is_a(Yii::$app,'yii\console\Application'))
+ return;
$rowId = $this->getRowId();
$tableName = $this->getTableName();
$createdBy = $this->getCreatedBy();
@maxxer No. Need ID of an user. This is a mandatory requirement. You need authenticated an user in console or don't use history.
The same happens with Blameable Behavior they say, but they allow to set the value to be used, in case Yii::$app->user
is not available.
I should create a fake console user component implementing \yii\web\User that must return something to the ->id getter?
Make a service user and run below code before some action:
$identity = \app\models\User::findIdentity('<service_user_id>');
if ($identity === null) {
throw new ForbiddenHttpException;
}
\Yii::$app->user->setIdentity($identity);
Set custom user will be to future functional.
ok thanks...
When running AR creation from console commands the behavior returns error