Skip to content

Commit

Permalink
Merge pull request #313 from AcclaroInc/hotfix/uninstall-entries-delete
Browse files Browse the repository at this point in the history
fix: plugin uninstall deleting entries
  • Loading branch information
sidedwards authored Feb 27, 2022
2 parents 263cb72 + 97b27a8 commit 03a3453
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ function (PluginEvent $event) {
public function uninstall()
{
// Let's clean up the drafts table
$files = self::$plugin->fileRepository->getFiles();
$drafts = array_column($files, 'draftId');

$drafts = self::$plugin->fileRepository->getAllDraftIds();
if ($drafts) {
Craft::$app->queue->push(new DeleteDrafts([
'description' => Constants::JOB_DELETING_DRAFT,
Expand Down
19 changes: 19 additions & 0 deletions src/services/repository/FileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ public function getFiles($orderId = null, $elementId = null, $targetSite = null)
return $files ? $files : array();
}

/**
* @return array
*/
public function getAllDraftIds()
{

$records = FileRecord::find()->where(['IS NOT', 'draftId', NULL])->all();

$draftIds = [];

foreach ($records as $key => $record) {
if(!empty($record->draftId)){
$draftIds[] = $record->draftId;
}
}

return $draftIds;
}

/**
* @return \acclaro\translations\models\FileModel
*/
Expand Down

0 comments on commit 03a3453

Please sign in to comment.