Skip to content

Commit

Permalink
fix: always regenerate availabe task types
Browse files Browse the repository at this point in the history
Signed-off-by: Jana Peper <[email protected]>
  • Loading branch information
janepie committed Dec 11, 2024
1 parent d879dde commit 899e97d
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,38 +733,36 @@ public function getPreferredProvider(string $taskTypeId) {
}

public function getAvailableTaskTypes(bool $showDisabled = false): array {

Check failure on line 735 in lib/private/TaskProcessing/Manager.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidNullableReturnType

lib/private/TaskProcessing/Manager.php:735:69: InvalidNullableReturnType: The declared return type 'array<string, array{description: string, inputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, inputShapeDefaults: array<array-key, numeric|string>, inputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, name: string, optionalInputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, optionalInputShapeDefaults: array<array-key, numeric|string>, optionalInputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, optionalOutputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, optionalOutputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, outputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, outputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>}>' for OC\TaskProcessing\Manager::getAvailableTaskTypes is not nullable, but 'array<array-key, array{description: string, inputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, inputShapeDefaults: array<array-key, numeric|string>, inputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, name: string, optionalInputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, optionalInputShapeDefaults: array<array-key, numeric|string>, optionalInputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, optionalOutputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, optionalOutputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>, outputShape: array<array-key, OCP\TaskProcessing\ShapeDescriptor>, outputShapeEnumValues: array<array-key, array<array-key, OCP\TaskProcessing\ShapeEnumValue>>}>|null' contains null (see https://psalm.dev/144)
if ($this->availableTaskTypes === null) {
$taskTypes = $this->_getTaskTypes();
$taskTypeSettings = $this->_getTaskTypeSettings();
$taskTypes = $this->_getTaskTypes();
$taskTypeSettings = $this->_getTaskTypeSettings();

$availableTaskTypes = [];
foreach ($taskTypes as $taskType) {
if ((!$showDisabled) && isset($taskTypeSettings[$taskType->getId()]) && !$taskTypeSettings[$taskType->getId()]) {
continue;
}
try {
$provider = $this->getPreferredProvider($taskType->getId());
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
continue;
}
try {
$availableTaskTypes[$provider->getTaskTypeId()] = [
'name' => $taskType->getName(),
'description' => $taskType->getDescription(),
'optionalInputShape' => $provider->getOptionalInputShape(),
'inputShapeEnumValues' => $provider->getInputShapeEnumValues(),
'inputShapeDefaults' => $provider->getInputShapeDefaults(),
'inputShape' => $taskType->getInputShape(),
'optionalInputShapeEnumValues' => $provider->getOptionalInputShapeEnumValues(),
'optionalInputShapeDefaults' => $provider->getOptionalInputShapeDefaults(),
'outputShape' => $taskType->getOutputShape(),
'outputShapeEnumValues' => $provider->getOutputShapeEnumValues(),
'optionalOutputShape' => $provider->getOptionalOutputShape(),
'optionalOutputShapeEnumValues' => $provider->getOptionalOutputShapeEnumValues(),
];
} catch (\Throwable $e) {
$this->logger->error('Failed to set up TaskProcessing provider ' . $provider::class, ['exception' => $e]);
}
$availableTaskTypes = [];
foreach ($taskTypes as $taskType) {
if ((!$showDisabled) && isset($taskTypeSettings[$taskType->getId()]) && !$taskTypeSettings[$taskType->getId()]) {
continue;
}
try {
$provider = $this->getPreferredProvider($taskType->getId());
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
continue;
}
try {
$availableTaskTypes[$provider->getTaskTypeId()] = [
'name' => $taskType->getName(),
'description' => $taskType->getDescription(),
'optionalInputShape' => $provider->getOptionalInputShape(),
'inputShapeEnumValues' => $provider->getInputShapeEnumValues(),
'inputShapeDefaults' => $provider->getInputShapeDefaults(),
'inputShape' => $taskType->getInputShape(),
'optionalInputShapeEnumValues' => $provider->getOptionalInputShapeEnumValues(),
'optionalInputShapeDefaults' => $provider->getOptionalInputShapeDefaults(),
'outputShape' => $taskType->getOutputShape(),
'outputShapeEnumValues' => $provider->getOutputShapeEnumValues(),
'optionalOutputShape' => $provider->getOptionalOutputShape(),
'optionalOutputShapeEnumValues' => $provider->getOptionalOutputShapeEnumValues(),
];
} catch (\Throwable $e) {
$this->logger->error('Failed to set up TaskProcessing provider ' . $provider::class, ['exception' => $e]);
}

$this->availableTaskTypes = $availableTaskTypes;
Expand Down

0 comments on commit 899e97d

Please sign in to comment.