From 017f1360597deabd989b60727c514fb8880e3e24 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 9 Nov 2023 15:38:59 +0100 Subject: fix: Don't try to access undefined array key Signed-off-by: Marcel Klehr --- lib/private/TextProcessing/Manager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/private/TextProcessing') diff --git a/lib/private/TextProcessing/Manager.php b/lib/private/TextProcessing/Manager.php index c165f229919..41a4a5dedad 100644 --- a/lib/private/TextProcessing/Manager.php +++ b/lib/private/TextProcessing/Manager.php @@ -158,7 +158,11 @@ class Manager implements IManager { throw new PreConditionNotMetException('No LanguageModel provider is installed that can handle this task'); } $task->setStatus(OCPTask::STATUS_SCHEDULED); - [$provider,] = $this->getPreferredProviders($task); + $providers = $this->getPreferredProviders($task); + if (count($providers) === 0) { + throw new PreConditionNotMetException('No LanguageModel provider is installed that can handle this task'); + } + [$provider,] = $providers; if ($provider instanceof IProviderWithExpectedRuntime) { $completionExpectedAt = new \DateTime('now'); $completionExpectedAt->add(new \DateInterval('PT'.$provider->getExpectedRuntime().'S')); -- cgit v1.2.3