From 33ec3f05a75eb59396d17c05b6a908cf48aa3e69 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 29 Nov 2021 16:45:48 +0200 Subject: [PATCH] fix Undefined array key warning --- api/src/Db.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/Db.php b/api/src/Db.php index 4963bd6075..33f2d02ffd 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -1630,9 +1630,10 @@ class Db $not_null = is_array($column_definitions) && isset($column_definitions[$col]['nullable']) ? !$column_definitions[$col]['nullable'] : false; $maxlength = null; - if ($truncate_varchar) + if ($truncate_varchar && !is_int($col) && isset($column_definitions[$col]) && + in_array($column_definitions[$col]['type'], ['varchar','ascii'])) { - $maxlength = in_array($column_definitions[$col]['type'], array('varchar','ascii')) ? $column_definitions[$col]['precision'] : null; + $maxlength = $column_definitions[$col]['precision']; } // dont use IN ( ), if there's only one value, it's slower for MySQL if (is_array($data) && count($data) <= 1)