Merge branch 'master' into fix/602-catch-error-in-file-handlers

This commit is contained in:
Lucas Bartholemy 2025-04-10 13:39:31 +02:00 committed by GitHub
commit dc2e894892
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 80 additions and 13 deletions

View File

@ -1,6 +1,7 @@
name: PHP Codeception Tests
on:
workflow_dispatch:
push:
branches:
- master
@ -56,7 +57,7 @@ jobs:
steps:
- name: Start Selenium
run: |
docker run --detach --net=host --shm-size="2g" selenium/standalone-chrome
docker run --detach --net=host --shm-size="2g" selenium/standalone-chrome:108.0-20250123
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
@ -119,7 +120,7 @@ jobs:
run: php protected/humhub/tests/codeception/bin/yii installer/auto
- name: Rebuild search index
run: php protected/humhub/tests/codeception/bin/yii search/rebuild
run: php protected/humhub/tests/codeception/bin/yii content-search/rebuild
- name: Run test server
run: php --server 127.0.0.1:8080 index-test.php &>/tmp/phpserver.log &
@ -138,4 +139,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: codeception-output
path: protected/humhub/tests/codeception/_output/*
path: |
protected/humhub/tests/codeception/_output/*
protected/humhub/modules/*/tests/codeception/_output/*
protected/runtime/logs/*

View File

@ -5,6 +5,7 @@ HumHub Changelog
----------------------
- Fix #7484: Use password type on the installation DB config form
- Fix #7486: Catch errors in external file handlers
- Fix #7487: Fix comments list when comment is active from another parent comment
1.17.2 (April 7, 2025)
----------------------

View File

@ -65,9 +65,7 @@ class Comments extends Widget
{
$objectModel = PolymorphicRelation::getObjectModel($this->object);
$objectId = $this->object->getPrimaryKey();
$streamQuery = Yii::$app->request->getQueryParam('StreamQuery');
$currentCommentId = empty($streamQuery['commentId']) ? null : $streamQuery['commentId'];
$currentCommentId = $this->getCurrentCommentId();
// Count all Comments
$commentCount = CommentModel::GetCommentCount($objectModel, $objectId);
@ -101,4 +99,27 @@ class Comments extends Widget
{
return $this->isFullViewMode() ? $this->module->commentsBlockLoadSizeViewMode : $this->module->commentsBlockLoadSize;
}
protected function getCurrentCommentId(): ?int
{
$streamQuery = Yii::$app->request->getQueryParam('StreamQuery');
if (empty($streamQuery['commentId'])) {
return null;
}
$currentCommentId = (int) $streamQuery['commentId'];
$currentComment = Yii::$app->runtimeCache->getOrSet('getCurrentComment' . $currentCommentId, function () use ($currentCommentId) {
return CommentModel::findOne(['id' => $currentCommentId]);
});
if (!$currentComment ||
$currentComment->object_id !== $this->object?->id ||
$currentComment->object_model !== get_class($this->object)) {
// The current comment is from another parent object
return null;
}
return $currentCommentId;
}
}

View File

@ -212,7 +212,7 @@ class Content extends ActiveRecord implements Movable, ContentOwner, Archiveable
/**
* @since 1.3
*/
public function getModel(): ContentActiveRecord
public function getModel(): ?ContentActiveRecord
{
return $this->getPolymorphicRelation();
}

View File

@ -17,8 +17,8 @@ return array (
'Invalid Mime-Type' => 'Неправильный MIME-тип файла',
'Last update by:' => 'Последнее обновление:',
'Size:' => 'Размер:',
'Sorry, you can only upload up to {n,plural,=1{# file} other{# files}} at once.' => 'К сожалению, вы можете загрузить только до {n, plural, =1{# файла} many{# файлов}} одновременно.',
'Sorry, you can only upload up to {n,plural,=1{# file} other{# files}} at once.' => 'К сожалению, вы можете загрузить только до {n,plural,=1{# файла} other{# файлов}} одновременно.',
'The uploaded image is not a squared.' => 'Загруженное изображение не квадратное.',
'This upload field only allows a maximum of {n,plural,=1{# file} other{# files}}.' => 'Это поле загрузки допускает максимум {n,plural,=1{# файл} few{# файла} many{# файлов}}.',
'This upload field only allows a maximum of {n,plural,=1{# file} other{# files}}.' => 'Это поле загрузки допускает максимум {n,plural,=1{# файл} other{# файлов}}.',
'Upload files' => 'Загрузить файлы',
);

View File

@ -315,7 +315,7 @@ class BaseType extends Model
$query = $db->getQueryBuilder()->dropColumn(Profile::tableName(), $this->profileField->internal_name);
$db->createCommand($query)->execute();
} else {
Yii::error('Could not delete profile column - not exists!');
Yii::error('Could not delete profile column "' . $columnName . '" - not exists!');
}
}

View File

@ -25,4 +25,5 @@ return [
['user_id' => 5, 'firstname' => 'Disabled', 'lastname' => 'User'],
['user_id' => 6, 'firstname' => 'UnApproved', 'lastname' => 'User'],
['user_id' => 7, 'firstname' => 'UnApprovedNoGroup', 'lastname' => 'User'],
['user_id' => 8, 'firstname' => 'AdminNotMember', 'lastname' => 'User'],
];

View File

@ -31,7 +31,7 @@ class PeopleFiltersTest extends HumHubDbTestCase
ProfileField::updateAll(['directory_filter' => 1], ['IN', 'internal_name', ['firstname', 'lastname']]);
$peopleFilters = new PeopleFilters();
$this->assertEquals(['Admin', 'Andreas', 'Peter', 'Sara'], $this->getFilterOptions('fields[firstname]', $peopleFilters));
$this->assertEquals(['Admin', 'AdminNotMember', 'Andreas', 'Peter', 'Sara'], $this->getFilterOptions('fields[firstname]', $peopleFilters));
}
public function testReducedFilters()
@ -52,8 +52,8 @@ class PeopleFiltersTest extends HumHubDbTestCase
// Filter by firstname
$peopleQuery = new PeopleQuery(['defaultFilters' => ['fields' => ['firstname' => 'Admin']]]);
$peopleFilters = new PeopleFilters(['query' => $peopleQuery]);
$this->assertEquals(['Admin'], $this->getFilterOptions('fields[firstname]', $peopleFilters));
$this->assertEquals(['AdminLastName'], $this->getFilterOptions('fields[lastname]', $peopleFilters));
$this->assertEquals(['Admin', 'AdminNotMember'], $this->getFilterOptions('fields[firstname]', $peopleFilters));
$this->assertEquals(['AdminLastName', 'User'], $this->getFilterOptions('fields[lastname]', $peopleFilters));
$this->assertEquals(['' => 'Any', 1 => 'Administrator'], $this->getFilterOptions('groupId', $peopleFilters));
// Filter by group

View File

@ -36,6 +36,14 @@ class Image extends BaseImage
public bool $showSelfOnlineStatus = false;
/**
* @inheritdoc
*/
public function beforeRun()
{
return parent::beforeRun() && $this->user instanceof User;
}
/**
* @inheritdoc
*/

View File

@ -3,6 +3,7 @@
namespace tests\codeception\_support;
use Codeception\Module;
use Codeception\TestInterface;
use Yii;
/**
@ -40,4 +41,35 @@ class WebHelper extends Module
Yii::$app->moduleManager->enableModules($cfg['humhub_modules']);
}
}
/**
* @inheritdoc
*/
public function _failed(TestInterface $test, $fail)
{
parent::_failed($test, $fail);
$filePath = codecept_output_dir() . str_replace(['\\', '/', ':', ' '], '.', $test->getSignature());
$logFilePath = Yii::getAlias('@runtime/logs') . DIRECTORY_SEPARATOR . 'app.log';
if (file_exists($logFilePath)) {
copy($logFilePath, $filePath . '.app.log');
}
if (!Yii::$app->db->isActive) {
return;
}
preg_match('/host=([^;]+)/', Yii::$app->db->dsn, $hostMatch);
preg_match('/dbname=([^;]+)/', Yii::$app->db->dsn, $dbMatch);
exec(sprintf(
'mysqldump --skip-column-statistics -u%s -p%s -h%s %s > %s',
escapeshellarg(Yii::$app->db->username ?? 'root'),
escapeshellarg(Yii::$app->db->password ?? 'root'),
escapeshellarg($hostMatch[1] ?? '127.0.0.1'),
escapeshellarg($dbMatch[1] ?? 'humhub_test'),
escapeshellarg($filePath . '.dump.sql'),
));
}
}