Skip to content
Permalink
Browse files

Fix: caching dependency

  • Loading branch information...
Thoulah committed Apr 13, 2019
1 parent 791cb4d commit 2c8b19f0b6fce09679f76d1ce647333c74dedb74
@@ -110,7 +110,7 @@ public function belongsToViewer(): bool {
}
public static function getLastModified(): int {
return $self::find()->max('updated');
return self::find()->max('updated');
}
public function getAuthor() {
@@ -95,6 +95,10 @@ public function sendCommentMail(Articles $model, self $comment): void {
endif;
}
public static function getLastModified(): int {
return self::find()->max('created');
}
public function getAuthor() {
return $this->hasOne(User::class, ['id' => 'user']);
}
@@ -8,7 +8,7 @@
$isHome = Yii::$app->controller->id === 'site' && Yii::$app->controller->action->id === 'index';
$dependency = [
'class' => ExpressionDependency::class,
'expression' => Articles::find()->max('updated'),
'expression' => implode('-', [Articles::getLastModified(), ArticlesComments::getLastModified()]),
'reusable' => true,
];
@@ -28,6 +28,7 @@
]);
echo Html::endTag('aside');
endif;
echo Html::beginTag('aside', ['class' => 'col-4 col-lg-3 d-none d-md-block']);
$form = ActiveForm::begin(['action' => ['articles/search'], 'method' => 'get', 'options' => ['role' => 'search']]);
echo $form->field(new Search(), 'keyword', [
@@ -11,13 +11,13 @@ public function run(): string {
$comments = ArticlesComments::find()
->orderBy(['created' => SORT_DESC])
->with('article')
->where(['active' => true])
->andWhere(['parent_comment' => null])
->where(['parent_comment' => null])
->limit($this->limit)
->all();
foreach ($comments as $comment) :
$link = Html::a($comment->title, ['articles/article', 'id' => $comment->article->id, 'title' => $comment->article->url, '#' => 'comments'], ['class' => 'card-link']);
$draft = ($comment->active === 1) ? '' : Html::tag('sup', Yii::t('mr42', 'Draft'), ['class' => 'badge badge-info ml-1']);
$link = Html::a($comment->title.$draft, ['articles/article', 'id' => $comment->article->id, 'title' => $comment->article->url, '#' => 'comments'], ['class' => 'card-link']);
$items[] = Html::tag('li', $link, ['class' => 'list-group-item text-truncate']);
endforeach;

0 comments on commit 2c8b19f

Please sign in to comment.
You can’t perform that action at this time.