I discovered that when you move content to a different section the comment didnt follow. It turns out that the stored procedure Community_ContentPagesMoveContentPage has a slight flaw.
It sets the ContentPage_SectionID to the new section only for the parent page. This fix addresses this issue.
This simply alters the existing stored procedure.
-- Mike Munoz - 3/11/2005
-- This is a fix to address the issue of comments not moving
-- when you move contentpages to a new section
ALTER PROCEDURE Community_ContentPagesMoveContentPage
(
@communityID int,
@contentPageID int,
@moderationStatus int,
@sectionID int
)
AS
UPDATE Community_ContentPages SET
ContentPage_SectionID = @sectionID,
ContentPage_ModerationStatus = @moderationStatus
WHERE
ContentPage_CommunityID = @communityID
-- Mike Munoz 3/11/2005 Fixes Comments not showing up when moved to a new section
AND (ContentPage_ID = @contentPageID or contentPage_parentID = @contentPageID)
If you have used the move function previously then you have disassociated contentpages for the comments.The following is a simple script that updates the content pages to address that issue as well.
This script uses a temp table to hold the values that we need to update from and a transaction to make sure that all steps are successful before we make the changes final.
DECLARE @Succeed int
set xact_abort on
SET NOCOUNT ON
set @Succeed = 1
BEGIN TRANSACTION contentpagefix
SAVE TRAN contentpagefix
-- Create Temp table to hold the values we need to update the section ID's
CREATE TABLE [#ContentPageTemp] (
[contentPage_id] [int] NOT NULL ,
[contentPage_sectionID] [int] NULL
) ON [PRIMARY]
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
--Populate the Temp table with the Community_ContentPages Table contents
INSERT INTO #ContentPageTemp
SELECT
contentPage_id,
contentPage_sectionID
FROM Community_ContentPages
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
-- Update the Section ID of all rows that have ParentID's.
-- This basically synchronizes all contentpages to have the same sectionID as their Parent page
update Community_ContentPages
set Community_ContentPages.contentPage_sectionID = a.contentPage_sectionID
from #ContentPageTemp a, Community_ContentPages b
where
b.contentPage_parentID =a.contentPage_id
-- Check to see if any Errors were returned
IF @@error<>0 SELECT @Succeed=0
-- Check to to see if any errors occured
IF @Succeed=0
ROLLBACK TRANSACTION contentpagefix --Undo all changes if there were any errors
ELSE
COMMIT TRANSACTION -- No errors than we makes the changes final
AS ALWAYS BACKUP YOUR DATABASE BEFORE MAKING ANY CHANGES LIKE THIS!!!!