Fix content search order after restoring from cache (#7017)

* Fix content search order after restoring from cache

* Update CHANGELOG-DEV.md
This commit is contained in:
Yuriy Bakhtin 2024-05-21 14:46:16 +02:00 committed by GitHub
parent 78a5c87da9
commit 5c0fea3089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -28,6 +28,7 @@ HumHub Changelog
- Fix #7011: Fixed performance issue in `Members::getPrivilegedUserIds`
- Enh #7010: Rich text tables: Vertical align top instead of middle
- Enh #5310: Mobile - Zooming into pictures
- Fix #7017: Fix content search order after restoring from cache
1.16.0-beta.2 (April 9, 2024)
-----------------------------

View File

@ -10,6 +10,7 @@ namespace humhub\modules\content\search;
use humhub\modules\content\models\Content;
use yii\data\Pagination;
use yii\db\Expression;
/**
* SearchResultSet
@ -41,6 +42,10 @@ class ResultSet
$this->pagination = $data['pagination'];
$this->results = empty($data['results'])
? []
: Content::find()->where(['IN', 'id', $data['results']])->all();
: Content::find()
->where(['IN', 'id', $data['results']])
// Restore an original order what was before serializing
->orderBy([new Expression('FIELD(id, ' . implode(',', $data['results']) . ')')])
->all();
}
}