Fatal error received attempting to edit banner in the admin. The error log is:
[13-Jun-2022 14:54:23 America/New_York] Request URI: /admin/index.php?cmd=banner_manager&page=1&bID=14&action=new, IP address: xx.xxx.xxx.xxx
--> PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /path to admin/includes/functions/general.php:2230
Stack trace:
#0 /path to admin/banner_manager.php(366): zen_set_field_length('banners', 'banners_sort_or...')
#1 /path to admin/index.php(11): require('partial path to store')
#2 {main}
thrown in /path to admin/includes/functions/general.php on line 2230.
The error occurs in function zen_set_field_length, code follows:
Code:
/**
* return the size and maxlength settings in the form size="blah" maxlength="blah" based on maximum size being 50
* uses $tbl = table name, $fld = field name
* example: zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')
* @param string $tbl
* @param string $fld
* @param int $max
* @param bool $override
* @return string
*/
function zen_set_field_length($tbl, $fld, $max = 50, $override = false)
{
$field_length = zen_field_length($tbl, $fld);
switch (true) {
case (($override == false and $field_length > $max)):
$length = 'size="' . ($max + 1) . '" maxlength="' . $field_length . '"';
break;
default:
$length = 'size="' . ($field_length + 1) . '" maxlength="' . $field_length . '"';
break;
}
return $length;
}
Line 2230 is the line in red. I have traced the problem to a call to the function with $tbl = TABLE_BANNERS, and $fld = 'banners_sort_order'. Function zen_field_length returns an empty variable for $field_length, I assume an empty string.
I suspect the issue may be due to the version of mysql. The error occurs on mysql 8.0.28 but not on mysql 5.7.34. mysql 8.0.28 has eliminated the length attribute for integers, which apparently was associated with the display length, not the size of the stored integer, but I'm not certain of the impact of the change when it comes to zen_field_length. I suspect the error may also occur for other admin functions but I don't have any hard data, just a nagging memory of other errors in admin.
Suggestions for a temporary or permanent fix would be appreciated.
zc157c, php8.0.2, mysql 8.0.28
Dave
Bookmarks