diff --git a/src/Translations.php b/src/Translations.php index 18522322..d9bb9b19 100644 --- a/src/Translations.php +++ b/src/Translations.php @@ -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, diff --git a/src/services/repository/FileRepository.php b/src/services/repository/FileRepository.php index eabf694b..fa61d3fd 100644 --- a/src/services/repository/FileRepository.php +++ b/src/services/repository/FileRepository.php @@ -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 */