You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Error 22018 wrong types received on SQL server database #5734
Several queries report error 22018 (expected integer, received string) while loading.
Description
Some navigation or automatic loads stop reporting 22018 on screen. The problem triggers randomly, while using SQLServer (strongly typed database).
The error is correct, as I altered the Database.php file to show in php_error log any receive variable and its type. Some $values in array come reported as "String", while the values is an "integer" (Ex: 5-"string") and are sent to queries that expect an "integer" (ex: select * from mytable where id=? -> 5)
Steps to Reproduce
Unfortunately, i cannot identify a method to reproduce the error. Just enabled a manual log, and used the application until it crashed. Sometimes it happens twice a day, sometimes once per hour. Its isolation was kinda nightmarish.
With normal use, it ends showing the problem in the log. I cannot either assure that this incorrect types come for a plugin or core function. But I suggest a Fix below for both cases.
Suggested watch code inside "execute" for Database.php function for debug purposes is:
error_log("New sql received: $sql")
foreach ($values as $p)
{
error_log("Variable is: ".$p."-".gettype($p));
}
Expected Behavior
Types should be received correctly, but as php is a soft typed language, perhaps is a good idea to "clean" them in the function. As far as I've seen, only happens with numeric values. So, the function "execute" in Database.php should ensure that the data sent is correct.
Sugested fix:
//cast hotfix for numeric values. EDIT: I found that floats are being cut, so probably I need more testing... I temporary put "float" instead of int
$valuesClean = array_map(function($v){
if (is_numeric($v)) return (float)$v;
return $v;
},$values);
then send $valuesClean to withPositionalParams instead of $values. This fixed the issue for me. Please note the log below, that contains current values "string" and fixed values.
Actual Behavior
Strings received.
Atm, it reports values like the log below. Log comes with the suggested hotfix check.
Please note that Microsoft SQL Server support in Kanboard is experimental and was implemented by a contributor. I don't use SQL Server myself, and I'm not familiar with Microsoft technologies.
That said, patches improving SQL Server compatibility are welcome, but they must not break or impact the officially supported databases. Otherwise, you'll need to maintain custom patches.
For production use, I recommend using one of the officially supported databases (SQLite, MySQL/MariaDB, PostgreSQL).
@targiledelin - what version of MSSQL are you using?
I am not seeing any such errors either running with 2016 or 2022.
What plugins are you using? Perhaps the problem is there...
Main issue is, as far as I understand, the eternal fight between soft and hard types. Both mysql and php use soft types, and they don't mind if you send them a string while an integer is required (If they can cast the value, everything is fine), but the stuff starts to be tricky in the moment they speak with a hard typed system (MSSQL, for example), on certain operations.
My suggestion is to integrate the hotfix code exposed above, on the suggested fix, and run it against a project stable database. If there are no problems after a while on a normal release, I bet the patch will be stable for everything, as you will be casting the numbers before sending them to mysql, postgres, or sqlite. As far as I can see, this hotfix works on my sqlserver smoothly, for the moment.
Why do I do this suggestion?
-Will fix any issue introduced (unconsciously) by any collaborator on any plugin, and in core application. When you develop in a soft typed environment, you tend to ignore te type unless it causes an issue. So, is simpler to autocast on the core library before sending the values to the hard typed environment (in this case, SQLServer)
-It will make kanboard core even more portable. If someone in the future wants to port the database schema to Oracle, or another hard-typed database, the problem will be solved before it starts (as the types will be sent correctly). Its a hard-type database long term hotfix.
@fguillot Yeah, I remember that. The problem is that using a different sql database is not even planned in my production environment. Sadly, is not my decision. I tried to convince them in any way, but its a corporate environment. I'm busted here =(
@jnahmias I will confirm the exact build as soon as I get back to work. Next week, probably, if I don't go to a formation course.
You are not probably seing the errors on the log output because I customized them (See, steps to reproduce). The errors trigger randomly, and I got a couple of them without any plugin Edit:(I think...). As I explained before, I think it is an structural point that should be explored IMHO. Real error is "22018", returned by database directly on screen.
Last to be said is that I have little to none experience on free software development, so if the hotfix requires I commit it, I will probably need to study a lot of documentation before touching anything. Can do, but may take a while. I don't want to break anyone else hard work.
Activity
fguillot commentedon Jan 8, 2026
Thanks for the report.
Please note that Microsoft SQL Server support in Kanboard is experimental and was implemented by a contributor. I don't use SQL Server myself, and I'm not familiar with Microsoft technologies.
That said, patches improving SQL Server compatibility are welcome, but they must not break or impact the officially supported databases. Otherwise, you'll need to maintain custom patches.
For production use, I recommend using one of the officially supported databases (SQLite, MySQL/MariaDB, PostgreSQL).
jnahmias commentedon Jan 9, 2026
@targiledelin - what version of MSSQL are you using?
I am not seeing any such errors either running with 2016 or 2022.
What plugins are you using? Perhaps the problem is there...
targiledelin commentedon Jan 9, 2026
Thanks you both for the answer.
Main issue is, as far as I understand, the eternal fight between soft and hard types. Both mysql and php use soft types, and they don't mind if you send them a string while an integer is required (If they can cast the value, everything is fine), but the stuff starts to be tricky in the moment they speak with a hard typed system (MSSQL, for example), on certain operations.
My suggestion is to integrate the hotfix code exposed above, on the suggested fix, and run it against a project stable database. If there are no problems after a while on a normal release, I bet the patch will be stable for everything, as you will be casting the numbers before sending them to mysql, postgres, or sqlite. As far as I can see, this hotfix works on my sqlserver smoothly, for the moment.
Why do I do this suggestion?
-Will fix any issue introduced (unconsciously) by any collaborator on any plugin, and in core application. When you develop in a soft typed environment, you tend to ignore te type unless it causes an issue. So, is simpler to autocast on the core library before sending the values to the hard typed environment (in this case, SQLServer)
-It will make kanboard core even more portable. If someone in the future wants to port the database schema to Oracle, or another hard-typed database, the problem will be solved before it starts (as the types will be sent correctly). Its a hard-type database long term hotfix.
@fguillot Yeah, I remember that. The problem is that using a different sql database is not even planned in my production environment. Sadly, is not my decision. I tried to convince them in any way, but its a corporate environment. I'm busted here =(
@jnahmias I will confirm the exact build as soon as I get back to work. Next week, probably, if I don't go to a formation course.
You are not probably seing the errors on the log output because I customized them (See, steps to reproduce). The errors trigger randomly, and I got a couple of them without any plugin Edit:(I think...). As I explained before, I think it is an structural point that should be explored IMHO. Real error is "22018", returned by database directly on screen.
Last to be said is that I have little to none experience on free software development, so if the hotfix requires I commit it, I will probably need to study a lot of documentation before touching anything. Can do, but may take a while. I don't want to break anyone else hard work.
Hope this helps =)