Skip to content

Fix HtmlModule 10 upgrade issues with localized sites #6560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

tvatavuk
Copy link
Contributor

@tvatavuk tvatavuk commented May 28, 2025

Fixes #6494

Summary

There is an upgrade issue affecting localized sites. After upgrading the HtmlModule to versions 10.00.00 or 10.00.01, exceptions may occur as explained in #6494.

The migration from the built-in HTML workflow is not correctly mapped to DNN content workflows when workflow names and states are localized. This depends on the admin-selected language at the time of site creation.

This fix addresses that issue.

This PR makes upgrading to DNN 10.00.02+ to resolve these errors. Alternatively, for sites already on 10.00.00 or 10.00.01, running the SQL script at
DesktopModules\HTML\Providers\DataProviders\SqlDataProvider\10.00.02.SqlDataProvider in the DNN SQL Console can also resolve the issues caused by content workflow localization.

TODO:

  • Halt upgrade if custom HTML workflows are detected
  • SQL script to fix localization issues after HTML upgrade
  • Improved SQL script to create missing content workflows and states
  • Migrate HTML workflow logic from SQL-only to C# for better flexibility during development
  • Enhance HtmlModule to be more robust in similar scenarios
  • Refine SQL scripts for best practices

@bdukes bdukes added this to the 10.0.2 milestone May 29, 2025
@valadas
Copy link
Contributor

valadas commented May 29, 2025

Awesome, thanks for taking care of this @tvatavuk

@tvatavuk tvatavuk marked this pull request as ready for review July 8, 2025 19:37
@Copilot Copilot AI review requested due to automatic review settings July 8, 2025 19:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses upgrade failures in the HTML module on localized sites by adding robust workflow migration both in SQL and C#, updating the module manifest, and adjusting HTML path handling logic.

  • Adds two new SQL scripts to ensure missing workflows/states are created (10.00.00.03) and to deduplicate localized workflows after migration (10.00.02).
  • Introduces LocalizationHelper and MigrateHelper in C# and updates HtmlTextController/EditHtml to run the migration and use the revised ManageRelativePaths overload.
  • Updates the module manifest (dnn_HTML.dnn), bumps the version to 10.00.02, and amends the project file to include new scripts and components.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Website/Providers/DataProviders/SqlDataProvider/10.00.00.03.SqlDataProvider New script to create missing content workflows and states
Tests/DotNetNuke.Tests.Modules/Html/HtmlTextControllerTests.cs Updated tests for the new two-parameter ManageRelativePaths
Modules/HTML/dnn_HTML.dnn Bumped module version, added 10.00.02 install script, updated upgrade list
Modules/HTML/Providers/DataProviders/SqlDataProvider/10.00.02.SqlDataProvider New script to deduplicate workflows and states after migration
Modules/HTML/Providers/DataProviders/SqlDataProvider/10.00.00.SqlDataProvider Refactored MigrateHtmlWorkflows SP to use localization lists
Modules/HTML/EditHtml.ascx.cs Adjusted calls to ManageRelativePaths to match the new overload
Modules/HTML/DotNetNuke.Modules.Html.csproj Added LocalizationHelper.cs, MigrateHelper.cs, included new SQL scripts
Modules/HTML/Components/MigrateHelper.cs New helper to invoke migration SP and clean up old schema
Modules/HTML/Components/LocalizationHelper.cs New helper to load state name localizations
Modules/HTML/Components/HtmlTextController.cs Removed obsolete usings, updated FormatHtmlText and UpgradeModule

Copy link
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing sticks out to me. @mitchelsellers @bdukes if you one of you want's to approv/merge, I think we would be ready to do a v10.0.2 that would not have a known issue in the release notes...

@valadas
Copy link
Contributor

valadas commented Jul 9, 2025

@tvatavuk this completes #6618 correct ?

@tvatavuk
Copy link
Contributor Author

tvatavuk commented Jul 9, 2025

Not yet - I have separate code for #6618, which I'm planning to complete for a future DNN release after 10.00.02, assuming this PR becomes part of that release.
Additionally, I plan to introduce at least one more enhancement issue (with a corresponding PR) related to the migration of legacy html workflow settings at the site, tab, and module level.

@bdukes
Copy link
Contributor

bdukes commented Jul 10, 2025

In testing, there was an error during step 1 from 10.00.00.03.SqlDataProvider:

Violation of UNIQUE KEY constraint 'IX_ContentWorkflows'. Cannot insert duplicate key in object 'dbo.ContentWorkflows'. The duplicate key value is (17, Content Approval).

This site has ContentWorkflows rows with WorkflowKey set to an empty string. The MERGE statement is matching on WorkflowKey, but the index is for PortalID and WorkflowName.

@tvatavuk
Copy link
Contributor Author

Thanks a lot for testing and reporting this!

The issue occurs because the script attempts to insert a new content workflow when a workflow with the same WorkflowName and PortalID already exists - but with a different (or missing) WorkflowKey. Since the current logic relies on WorkflowKey to identify default workflows, this mismatch leads to a duplicate insert due to the IX_ContentWorkflows unique constraint on (PortalID, WorkflowName).

The complication arises because WorkflowName is sometimes localized based on the admin's UI culture at the time of portal creation, making WorkflowKey the more reliable identifier for defaults. However, as you noticed, sometimes WorkflowKey is empty or not set as expected.

Missing step was to normalize workflow keys, so I’ve added UPDATE statements to ensure that recognizable default workflow names are assigned their expected WorkflowKey values before the MERGE. This should prevent the reported error.

    /*------------------------------------------------------
        1.  Ensure known workflows has expected key
    ------------------------------------------------------*/

    -- ensure that each workflow with name 'Direct Publish' has workflow key 'DirectPublish'
    UPDATE {databaseOwner}{objectQualifier}ContentWorkflows
    SET WorkflowKey = 'DirectPublish'
    WHERE WorkflowName = N'Direct Publish' AND WorkflowKey <> 'DirectPublish';

    -- ensure that each workflow with name 'Save Draft' has workflow key 'SaveDraft'
    UPDATE {databaseOwner}{objectQualifier}ContentWorkflows
    SET WorkflowKey = 'SaveDraft'
    WHERE WorkflowName = N'Save Draft' AND WorkflowKey <> 'SaveDraft';
    -- ensure that each workflow with name 'Content Approval' has workflow key 'ContentApproval'
    UPDATE {databaseOwner}{objectQualifier}ContentWorkflows
    SET WorkflowKey = 'ContentApproval'
    WHERE WorkflowName = N'Content Approval' AND WorkflowKey <> 'ContentApproval';

I’ve tested against clean installs and dnn 9.13.9 upgrade scenario (with deleted WorkflowKey for ContentApproval) – all pass.

Thanks again for the quick report!

@bdukes
Copy link
Contributor

bdukes commented Jul 11, 2025

Thanks for the quick update @tvatavuk! Unfortunately, I now get a similar error from the ContentWorkflowStates step:

Violation of UNIQUE KEY constraint 'IX_ContentWorkflowStates'. Cannot insert duplicate key in object 'dbo.ContentWorkflowStates'. The duplicate key value is (292, Published).

I'm testing this with Site A from my previous testing. This includes "Save Draft" workflows where Draft has Order set to 1, but Published has Order set to 3 (there is no workflow state with Order set to 2 in this workflow). Similarly, there are "Content Approval" workflows with Draft 1, Ready For Review 3 and Published 5.

There are also workflows named "Folders: Content Approval" which don't get a workflow key, but I don't think those are causing any issue at this point.

I guess there will need to be an additional check that the given StateName does not exist for the workflow before trying to insert, rather than only checking Order, to avoid violations of the unique constraint.

Thanks again for the quick turnaround on these changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: HtmlModule 10 upgrade error
3 participants