Hard delete content records on integrity check (#6282)

This commit is contained in:
Yuriy Bakhtin 2023-05-02 12:20:54 +04:00 committed by GitHub
parent 7dd5c4ec89
commit 7e391224f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View File

@ -10,6 +10,7 @@ HumHub Changelog
- Fix #6264: Fix date format for columns `created_at` and `updated_at`
- Fix #6265: Broken HMTL in Visibility and Hidden Checkbox
- Enh #6242: Submit button hidden when editing a comment having a long "code" line
- Fix #6282: Hard delete content records on integrity check
1.14.0 (April 20, 2023)
-----------------------

View File

@ -130,19 +130,19 @@ class Events extends BaseObject
$source = $a->getSource();
} catch (IntegrityException $ex) {
if ($integrityController->showFix('Deleting activity id ' . $a->id . ' without existing target! (' . $a->object_model . ')')) {
$a->delete();
$a->hardDelete();
}
}
}
// Check for moduleId is set
if (empty($a->module) && $integrityController->showFix('Deleting activity id ' . $a->id . ' without module_id!')) {
$a->delete();
$a->hardDelete();
}
// Check Activity class exists
if (!class_exists($a->class) && $integrityController->showFix('Deleting activity id ' . $a->id . ' class not exists! (' . $a->class . ')')) {
$a->delete();
$a->hardDelete();
}
}
}

View File

@ -79,14 +79,15 @@ class Events extends BaseObject
$integrityController->showTestHeadline('Content Objects (' . Content::find()->count() . ' entries)');
foreach (Content::find()->each() as $content) {
/* @var Content $content */
if ($content->createdBy == null) {
if ($integrityController->showFix('Deleting content id ' . $content->id . ' of type ' . $content->object_model . ' without valid user!')) {
$content->delete();
$content->hardDelete();
}
}
if ($content->getPolymorphicRelation() === null) {
if ($integrityController->showFix('Deleting content id ' . $content->id . ' of type ' . $content->object_model . ' without valid content object!')) {
$content->delete();
$content->hardDelete();
}
}
}

View File

@ -27,9 +27,10 @@ class Events extends \yii\base\BaseObject
$integrityController->showTestHeadline("Post Module - Posts (" . Post::find()->count() . " entries)");
foreach (Post::find()->all() as $post) {
/* @var Post $post */
if (empty($post->content->id)) {
if ($integrityController->showFix("Deleting post " . $post->id . " without existing content record!")) {
$post->delete();
$post->hardDelete();
}
}
}