diff --git a/appinfo/info.xml b/appinfo/info.xml index 281b868ad..a53b2b878 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -25,7 +25,7 @@ https://buymeacoffee.com/dartcafe - + OCA\Polls\Cron\NotificationCron diff --git a/lib/Db/V11/TableManager.php b/lib/Db/V11/TableManager.php index dd68a0272..b810e2bb2 100644 --- a/lib/Db/V11/TableManager.php +++ b/lib/Db/V11/TableManager.php @@ -156,14 +156,26 @@ public function createTable(string $tableName): array { $column = $table->getColumn($columnName); // Use $column->getType()->getName() instead of the static Type::lookupName(): // since Nextcloud 35, ISchemaWrapper no longer returns a raw - // Doctrine\DBAL\Types\Type but an OCP\DB\Schema wrapper - getName() works on both. + // Doctrine\DBAL\Types\Type but an OCP\DB\Schema\IColumn wrapper - getName() works on both. + // Psalm may complain, that TypeDoesNotContainType IColumn only exists since NC35, + // Suppress psalm messages for now. if ($column->getType()->getName() !== $columnDefinition['type']) { $messages[] = 'Migrated type of ' . $table->getName() . '[\'' . $columnName . '\'] from ' . $column->getType()->getName() . ' to ' . $columnDefinition['type']; - $column->setType(Type::getType($columnDefinition['type'])); + /** + * @psalm-suppress UndefinedClass + * @psalm-suppress TypeDoesNotContainType + */ + if ($column instanceof \OCP\DB\Schema\IColumn) { + // IColumn::setType() takes the type name as string|ColumnType, not a Doctrine Type instance + $column->setType($columnDefinition['type']); + } else { + $column->setType(Type::getType($columnDefinition['type'])); + } } - $column->setOptions($columnDefinition['options']); - // force change to current options definition + // Column::setOptions() is gone since Nextcloud 35 (public API only allows typed + // setters now). Table::modifyColumn() is unaffected and still takes an options + // array, so it alone is enough to force the column's options to match the schema. $table->modifyColumn($columnName, $columnDefinition['options']); } else { $table->addColumn($columnName, $columnDefinition['type'], $columnDefinition['options']);