Developer forum

Forum » CMS - Standard features » Monitoring Health Wrong Item Ids bug

Monitoring Health Wrong Item Ids bug

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

I was chasing my tail for a while in Monitoring > Health > Content data > Wrong Item Ids. It seems to constantly hang and log an error in the event viewer.

 

After looking into this I notice it's because of the Item Type system names with dashes (i.e. "Swift_2Columns_9-3"). I tracked down the code to be in ContentDataHealthProvider.cs , method ExecuteCheck10_WrongItemIds. All that's needed is within the while, wrap the table name in square brackets (below in red).

 

Can this please be fixed?

 

        private static void ExecuteCheck10_WrongItemIds(Check check)
        {
            var commandBuilder = new CommandBuilder();
            commandBuilder.Add(@"SELECT [ItemType], [Current]
                FROM [ItemTypeId]
                WHERE EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = CONCAT('ItemType_', [ItemType]))");

            var isFirst = true;
            var itemCommandBuilder = new CommandBuilder();
            itemCommandBuilder.Add("SELECT TOP 100 * FROM (");

            var isTableExists = Database.ExecuteScalar(CommandBuilder.Create("SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ItemTypeId'"));
            if (Converter.ToInt32(isTableExists) == 1)
            {
                using (var reader = Database.CreateDataReader(commandBuilder))
                {
                    while (reader.Read())
                    {
                        if (!isFirst)
                        {
                            itemCommandBuilder.Add("UNION");
                        }
                        isFirst = false;
                        var itemType = reader.GetString(0);
                        var currentItemId = reader.GetInt32(1);
                        itemCommandBuilder.Add($"SELECT TOP 1 '{itemType}' ItemType FROM [ItemType_{itemType}]");
                        itemCommandBuilder.Add("WHERE CAST([Id] AS INT) > {0}", currentItemId);
                    }
                }
                itemCommandBuilder.Add(") t");
            }

            if (isFirst)
            {
                check.CheckWhatWasRun = commandBuilder.ToString();
                check.Count = 0;
                check.State = CheckState.Ok;
            }
            else
                RunDatabaseCheck(check, itemCommandBuilder, "ItemType", "", "", "ItemTypeId");
        }

 

Nuno Aguiar


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply
This post has been marked as an answer

Hi,

Bugged by task 8378, thanks for finding.

BR, Oleg QA

Votes for this answer: 1
 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Nuno

The bug #8378 has been fixed in Dynamicweb version 9.13.11
Get this release from the download section https://doc.dynamicweb.dk/downloads/dynamicweb-9

Sorry for any inconvenience this may have caused

Kind Regards
Dynamicweb Care Support
Kristian Kirkholt

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Thank you Kristian.

 

You must be logged in to post in the forum