SuiteCRM 7.14.6, PHP 8.2.9, DBManager.php error on quick repair

Im trying to perform quick repair and rebuild after upgrading from 7.12 but It is stuck on comapring vardefs and I receive error regarding DBManager in php log:

[14-Jan-2025 16:45:07 Asia/Kuwait] PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in C:\CRM\wwwroot\include\database\DBManager.php:1048
Stack trace:
#0 C:\CRM\wwwroot\include\database\DBManager.php(1048): array_map('strtolower', 'Array')
#1 C:\CRM\wwwroot\include\database\SqlsrvManager.php(326): DBManager->compareVarDefs(Array, Array)
#2 C:\CRM\wwwroot\include\database\DBManager.php(991): SqlsrvManager->compareVarDefs(Array, Array)
#3 C:\CRM\wwwroot\include\database\DBManager.php(765): DBManager->repairTableParams('acl_actions', Array, Array, false, NULL)
#4 C:\CRM\wwwroot\modules\Administration\repairDatabase.php(121): DBManager->repairTable(Object(ACLAction), false)
#5 C:\CRM\wwwroot\modules\Administration\QuickRepairAndRebuild.php(140): include_once('C:\\CRM\\wwwroot\\...')
#6 C:\CRM\wwwroot\modules\Administration\QuickRepairAndRebuild.php(122): RepairAndClear->repairDatabase()
#7 C:\CRM\wwwroot\modules\Administration\views\view.repair.php(56): RepairAndClear->repairAndClearAll(Array, Array, false, true)
#8 C:\CRM\wwwroot\include\MVC\View\SugarView.php(210): ViewRepair->display()
#9 C:\CRM\wwwroot\include\MVC\Controller\SugarController.php(432): SugarView->process()
#10 C:\CRM\wwwroot\include\MVC\Controller\SugarController.php(363): SugarController->processView()
#11 C:\CRM\wwwroot\include\MVC\SugarApplication.php(101): SugarController->execute()
#12 C:\CRM\wwwroot\index.php(52): SugarApplication->execute()
#13 {main}
  thrown in C:\CRM\wwwroot\include\database\DBManager.php on line 1048

I switched back to php 7.4 as I found this suggestion on forum here and the quick repair completes but it spits out complete nonsens on db repair script. For example:


/*INDEX MISMATCH WITH DATABASE - idx_del_user -  ROW <name> idx_del_user <type> index <fields>[0] => 'deleted'  [1] => 'assigned_user_id'  */
/* VARDEF - idx_del_user -  ROW<name> idx_del_user <type> index <fields>*/
DROP INDEX idx_del_user ON leads;;
CREATE INDEX idx_del_user ON leads (Array);;

CREATE INDEX idx_del_user ON leads (Array);; - instead of array there should be column list so I guess the DBManager.php script doesn’t work properly.
I looked through this forum and git issues but haven’t found anybody with the same problem.

Tested on PHP 8.1.9, same problem:

[14-Jan-2025 18:10:26 Asia/Kuwait] PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in C:\CRM\wwwroot\include\database\DBManager.php:1048
Stack trace:
#0 C:\CRM\wwwroot\include\database\DBManager.php(1048): array_map('strtolower', 'Array')
#1 C:\CRM\wwwroot\include\database\SqlsrvManager.php(326): DBManager->compareVarDefs(Array, Array)
#2 C:\CRM\wwwroot\include\database\DBManager.php(991): SqlsrvManager->compareVarDefs(Array, Array)
#3 C:\CRM\wwwroot\include\database\DBManager.php(765): DBManager->repairTableParams('acl_actions', Array, Array, false, NULL)
#4 C:\CRM\wwwroot\modules\Administration\repairDatabase.php(121): DBManager->repairTable(Object(ACLAction), false)
#5 C:\CRM\wwwroot\modules\Administration\QuickRepairAndRebuild.php(140): include_once('C:\\CRM\\wwwroot\\...')
#6 C:\CRM\wwwroot\modules\Administration\QuickRepairAndRebuild.php(122): RepairAndClear->repairDatabase()
#7 C:\CRM\wwwroot\modules\Administration\views\view.repair.php(56): RepairAndClear->repairAndClearAll(Array, Array, false, true)
#8 C:\CRM\wwwroot\include\MVC\View\SugarView.php(210): ViewRepair->display()
#9 C:\CRM\wwwroot\include\MVC\Controller\SugarController.php(432): SugarView->process()
#10 C:\CRM\wwwroot\include\MVC\Controller\SugarController.php(363): SugarController->processView()
#11 C:\CRM\wwwroot\include\MVC\SugarApplication.php(101): SugarController->execute()
#12 C:\CRM\wwwroot\index.php(52): SugarApplication->execute()
#13 {main}
  thrown in C:\CRM\wwwroot\include\database\DBManager.php on line 1048

Welcome to SuiteCRM community.

Check code from the GitHub.

Also, check your db charset/collation.

What do you mean by “Cross-check code form the github”? - by now I checked on DBManager.php in recent commit on main branch, also replaced it in my crm files to be sure.

What shuld I check about db charset?
Current settings:

'db_manager' => 'SqlsrvManager',
'collation' => 'polish_ci_as',
'charset' => 'utf8',

If you have mariadb, then I guess usually collation is:

$sugar_config[‘dbconfigoption’][‘collation’] = ‘utf8_general_ci’;

Forgot to mention but Im using MSSQL 2019 for database engine.
I still wonder why it pass ‘Array’ as a string to dbmanager function instead fo actual array.

Check compatibility matrix:

So? How this answer was relevant to my problem?
I meet criteria from compatibility matrix.

Can you try looking at the values in the variables in include/database/DBManager.php, in function compareVarDefs, around line 1034?

Maybe there’s a bug here but it would be nice to know which field is being examined at the time when it crashes, and what is it about the field_def that is causing trouble.

Hi, I added debug log for entry values in compareVarDefs and removeIndexLimit function.
Here is the log:

[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"id","type":"varchar","len":"36","required":"true"},"fielddef2":{"name":"id","vname":"LBL_ID","required":"true","type":"varchar","reportable":false,"comment":"Unique identifier","dbType":"id","len":"36","default":""},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"date_entered","type":"datetime"},"fielddef2":{"name":"date_entered","vname":"LBL_DATE_ENTERED","type":"datetime","required":false,"comment":"Date record created","dbType":"datetime","len":"","default":""},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"date_modified","type":"datetime"},"fielddef2":{"name":"date_modified","vname":"LBL_DATE_MODIFIED","type":"datetime","required":false,"comment":"Date record last modified","dbType":"datetime","len":"","default":""},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"modified_user_id","type":"varchar","len":"36"},"fielddef2":{"name":"modified_user_id","rname":"user_name","id_name":"modified_user_id","vname":"LBL_MODIFIED","type":"varchar","table":"modified_user_id_users","isnull":"false","dbType":"id","required":false,"len":36,"reportable":true,"comment":"User who last modified record"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"created_by","type":"varchar","len":"36"},"fielddef2":{"name":"created_by","rname":"user_name","id_name":"created_by","vname":"LBL_CREATED","type":"varchar","table":"created_by_users","isnull":"false","dbType":"id","len":36,"comment":"User ID who created record"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"name","type":"nvarchar","len":"150"},"fielddef2":{"name":"name","type":"nvarchar","vname":"LBL_NAME","len":150,"comment":"Name of the allowable action (view, list, delete, edit)","dbType":"varchar","required":false},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"category","type":"nvarchar","len":"100"},"fielddef2":{"name":"category","vname":"LBL_CATEGORY","type":"nvarchar","len":100,"reportable":true,"comment":"Category of the allowable action (usually the name of a module)","dbType":"varchar","required":false},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"acltype","type":"nvarchar","len":"100"},"fielddef2":{"name":"acltype","vname":"LBL_TYPE","type":"nvarchar","len":100,"reportable":true,"comment":"Specifier for Category, usually \"module\"","dbType":"varchar","required":false},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"aclaccess","type":"int","len":"4"},"fielddef2":{"name":"aclaccess","vname":"LBL_ACCESS","type":"int","len":"4","reportable":true,"comment":"Number specifying access priority; highest access \"wins\"","dbType":"int","required":false},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"deleted","type":"bit","len":"1"},"fielddef2":{"name":"deleted","vname":"LBL_DELETED","type":"bit","reportable":false,"comment":"Record deletion indicator","dbType":"bool","len":"1","default":"0"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] removeIndexLimit called with: {"fields":["id","deleted"]}
[17-Jan-2025 11:21:57 Asia/Kuwait] PHP Warning:  Array to string conversion in C:\CRM\wwwroot\include\database\MssqlManager.php on line 2146
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"aclactionid","type":"primary","fields":["id"]},"fielddef2":{"name":"idx_aclaction_id_del","type":"index","fields":"Array"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"idx_category_name","type":"index","fields":["category","name"]},"fielddef2":{"name":"idx_aclaction_id_del","type":"index","fields":"Array"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] removeIndexLimit called with: {"fields":"Array"}
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] removeIndexLimit called with: {"fields":["category","name"]}
[17-Jan-2025 11:21:57 Asia/Kuwait] PHP Warning:  Array to string conversion in C:\CRM\wwwroot\include\database\MssqlManager.php on line 2146
[17-Jan-2025 11:21:57 Asia/Kuwait] [DEBUG] compareVarDefs called with: {"fielddef1":{"name":"idx_category_name","type":"index","fields":["category","name"]},"fielddef2":{"name":"idx_category_name","type":"index","fields":"Array"},"ignoreName":false}
[17-Jan-2025 11:21:57 Asia/Kuwait] PHP Warning:  foreach() argument must be of type array|object, string given in C:\CRM\wwwroot\include\utils\array_utils.php on line 273
[17-Jan-2025 11:21:57 Asia/Kuwait] PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, string given in C:\CRM\wwwroot\include\database\DBManager.php:1054

This is helpful, thank you, but unfortunately I still can’t see the problem with this information. I believe it comes from further up, from the calling functions, or perhaps the way your vardefs are configured.

For some reason the name field is a string Array instead of an actual array-type variable, as you noted earlier.

Maybe try searching your files for idx_category_name, form the root of your SuiteCRM installation

grep -irn idx_category_name .

and then open each file and check the surroundings, see if anything catches your attention…