Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<screenshot>https://raw.githubusercontent.com/nextcloud/polls/main/screenshots/edit-poll.png</screenshot>
<donation>https://buymeacoffee.com/dartcafe</donation>
<dependencies>
<php min-version="8.1"/>
<nextcloud min-version="31" max-version="34"/>
<php min-version="8.2"/>
<nextcloud min-version="33" max-version="35"/>
</dependencies>
<background-jobs>
<job>OCA\Polls\Cron\NotificationCron</job>
Expand Down
19 changes: 15 additions & 4 deletions lib/Db/V11/TableManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,25 @@
$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
*/
if ($column instanceof \OCP\DB\Schema\IColumn) {

Check failure on line 167 in lib/Db/V11/TableManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

TypeDoesNotContainType

lib/Db/V11/TableManager.php:167:10: TypeDoesNotContainType: Cannot resolve types for $column - Doctrine\DBAL\Schema\Column does not contain OCP\DB\Schema\IColumn (see https://psalm.dev/056)

Check failure on line 167 in lib/Db/V11/TableManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

TypeDoesNotContainType

lib/Db/V11/TableManager.php:167:10: TypeDoesNotContainType: Cannot resolve types for $column - Doctrine\DBAL\Schema\Column does not contain OCP\DB\Schema\IColumn (see https://psalm.dev/056)
// IColumn::setType() takes the type name as string|ColumnType, not a Doctrine Type instance
$column->setType($columnDefinition['type']);

Check failure on line 169 in lib/Db/V11/TableManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable35

InvalidArgument

lib/Db/V11/TableManager.php:169:24: InvalidArgument: Argument 1 of Doctrine\DBAL\Schema\Column::setType expects Doctrine\DBAL\Types\Type, but 'bigint'|'string'|'text' provided (see https://psalm.dev/004)
} 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']);
Expand Down
Loading