Fix: Memory leak in activity mail summary processor cron

This commit is contained in:
Lucas Bartholemy 2018-05-02 17:47:19 +02:00
parent 6f3b2bc3c9
commit 0d61c0f7a5
3 changed files with 23 additions and 3 deletions

View File

@ -38,15 +38,16 @@ class Migration extends \yii\db\Migration
$this->updateSilent('file', ['object_model' => $newClass], ['object_model' => $oldClass]);
$this->updateSilent('like', ['object_model' => $newClass], ['object_model' => $oldClass]);
$this->updateSilent('notification', ['source_class' => $newClass], ['source_class' => $oldClass]);
$this->updateSilent('notification', ['class' => $newClass], ['class' => $oldClass]);
$this->updateSilent('user_mentioning', ['object_model' => $newClass], ['object_model' => $oldClass]);
$this->updateSilent('user_follow', ['object_model' => $newClass], ['object_model' => $oldClass]);
//$this->updateSilent('wall', ['object_model' => $newClass], ['object_model' => $oldClass]);
/**
* Looking up "NewLike" activities with this className
* Since 0.20 the className changed to Like (is not longer the target object e.g. post)
*
*
* Use raw query for better performace.
*/
$updateSql = "
@ -55,7 +56,7 @@ class Migration extends \yii\db\Migration
SET activity.object_model=:likeModelClass, activity.object_id=like.id
WHERE activity.class=:likedActivityClass AND like.id IS NOT NULL and activity.object_model != :likeModelClass
";
Yii::$app->db->createCommand($updateSql, [
':likeModelClass' => \humhub\modules\like\models\Like::className(),
':likedActivityClass' => \humhub\modules\like\activities\Liked::className()

View File

@ -47,6 +47,20 @@ class SettingsManager extends BaseSettingsManager
return $this->contentContainers[$container->contentcontainer_id];
}
/**
* Clears runtime cached content container settings
*
* @param ContentContainerActiveRecord|null $container if null all content containers will be flushed
*/
public function flushContentContainer(ContentContainerActiveRecord $container = null) {
if ($container === null) {
$this->contentContainers = [];
} else {
unset($this->contentContainers[$container->contentcontainer_id]);
}
}
/**
* Returns ContentContainerSettingsManager for the given $user or current logged in user
* @return ContentContainerSettingsManager

View File

@ -70,9 +70,14 @@ class MailSummaryProcessor
} catch (\Exception $ex) {
Yii::error('Could not send activity mail to: ' . $user->displayName . ' (' . $ex->getMessage() . ')', 'activity');
}
// Remove cached user settings
Yii::$app->getModule('activity')->settings->flushContentContainer($user);
if ($interactive) {
Console::updateProgress( ++$processed, $totalUsers);
}
}
if ($interactive) {