diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-10-23 13:47:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 13:47:42 +0200 |
commit | 8f59997689e933ed1b302c9a1a36e9cc9d56eefc (patch) | |
tree | 133ef466e46af386d7ad31d28d2b1425aa5d1d88 /lib | |
parent | 2055516cd8c1b9823ce9390f19a3dde178773dd9 (diff) | |
parent | 54c3aa3f997aa843be84880d518d1a36ba265926 (diff) | |
download | nextcloud-server-8f59997689e933ed1b302c9a1a36e9cc9d56eefc.tar.gz nextcloud-server-8f59997689e933ed1b302c9a1a36e9cc9d56eefc.zip |
Merge pull request #48837 from nextcloud/followup/47329/add-all-types-to-handling
fix(entity): Fix mapping of old/sub-types to actually supported datab…
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Db/Entity.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index cd15df134f1..d90d3ed4837 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -112,6 +112,15 @@ abstract class Entity { } switch ($type) { + case Types::BIGINT: + case Types::SMALLINT: + settype($args[0], Types::INTEGER); + break; + case Types::BINARY: + case Types::DECIMAL: + case Types::TEXT: + settype($args[0], Types::STRING); + break; case Types::TIME: case Types::DATE: case Types::DATETIME: @@ -260,9 +269,22 @@ abstract class Entity { * * @param string $fieldName the name of the attribute * @param \OCP\DB\Types::* $type the type which will be used to match a cast + * @since 31.0.0 Parameter $type is now restricted to {@see \OCP\DB\Types} constants. The formerly accidentally supported types 'int'|'bool'|'double' are mapped to Types::INTEGER|Types::BOOLEAN|Types::FLOAT accordingly. * @since 7.0.0 */ protected function addType(string $fieldName, string $type): void { + /** @psalm-suppress TypeDoesNotContainType */ + if (in_array($type, ['bool', 'double', 'int', 'array', 'object'], true)) { + // Mapping legacy strings to the actual types + $type = match ($type) { + 'int' => Types::INTEGER, + 'bool' => Types::BOOLEAN, + 'double' => Types::FLOAT, + 'array', + 'object' => Types::STRING, + }; + } + $this->_fieldTypes[$fieldName] = $type; } |