Mitigated problem with page deletion (page link graph not updated correctly).

This commit is contained in:
Dario Solera 2011-06-24 09:05:42 +02:00
parent cec8bce4e7
commit 6733358ae9
5 changed files with 29 additions and 20 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.4.574")] [assembly: AssemblyVersion("3.0.4.575")]
[assembly: AssemblyFileVersion("3.0.4.574")] [assembly: AssemblyFileVersion("3.0.4.575")]

View file

@ -554,6 +554,11 @@ namespace ScrewTurn.Wiki {
// Remove outgoing links // Remove outgoing links
Settings.Provider.DeleteOutgoingLinks(page.FullName); Settings.Provider.DeleteOutgoingLinks(page.FullName);
RebuildPageLinks(Pages.GetPages(null));
foreach(NamespaceInfo nspace in GetNamespaces()) {
RebuildPageLinks(GetPages(nspace));
}
Log.LogEntry("Page " + page.FullName + " deleted", EntryType.General, Log.SystemUsername); Log.LogEntry("Page " + page.FullName + " deleted", EntryType.General, Log.SystemUsername);
RecentChanges.AddChange(page.FullName, title, null, DateTime.Now, SessionFacade.GetCurrentUsername(), Change.PageDeleted, ""); RecentChanges.AddChange(page.FullName, title, null, DateTime.Now, SessionFacade.GetCurrentUsername(), Change.PageDeleted, "");
Host.Instance.OnPageActivity(page, null, SessionFacade.GetCurrentUsername(), PageActivity.PageDeleted); Host.Instance.OnPageActivity(page, null, SessionFacade.GetCurrentUsername(), PageActivity.PageDeleted);
@ -1029,6 +1034,17 @@ namespace ScrewTurn.Wiki {
return ExtractNegativeKeys(result); return ExtractNegativeKeys(result);
} }
/// <summary>
/// Rebuilds the page links for the specified pages.
/// </summary>
/// <param name="pages">The pages.</param>
public static void RebuildPageLinks(IList<PageInfo> pages) {
foreach(PageInfo page in pages) {
PageContent content = Content.GetPageContent(page, false);
StorePageOutgoingLinks(page, content.Content);
}
}
/// <summary> /// <summary>
/// Gets the wanted/inexistent pages in all namespaces. /// Gets the wanted/inexistent pages in all namespaces.
/// </summary> /// </summary>

View file

@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using ScrewTurn.Wiki.PluginFramework; using ScrewTurn.Wiki.PluginFramework;
using ScrewTurn.Wiki.AclEngine; using ScrewTurn.Wiki.AclEngine;
@ -1150,13 +1151,11 @@ namespace ScrewTurn.Wiki {
IDictionary<string, string[]> links = GetAllOutgoingLinks(); IDictionary<string, string[]> links = GetAllOutgoingLinks();
// Step 1: rename source page, if any // Step 1: remove source page, if any
removedSomething = links.Remove(page); removedSomething = links.Remove(page);
// Step 2: rename all target pages, for all source pages // Step 2: remove all target pages, for all source pages
string[] keys = new string[links.Count]; foreach(string key in links.Keys.ToList()) {
links.Keys.CopyTo(keys, 0);
foreach(string key in keys) {
List<string> currentLinks = new List<string>(links[key]); List<string> currentLinks = new List<string>(links[key]);
removedSomething |= currentLinks.Remove(page); removedSomething |= currentLinks.Remove(page);
links[key] = currentLinks.ToArray(); links[key] = currentLinks.ToArray();

View file

@ -210,6 +210,11 @@ namespace ScrewTurn.Wiki {
} }
} }
} }
Pages.RebuildPageLinks(Pages.GetPages(null));
foreach(ScrewTurn.Wiki.PluginFramework.NamespaceInfo nspace in Pages.GetNamespaces()) {
Pages.RebuildPageLinks(Pages.GetPages(nspace));
}
} }
} }
}, WindowsIdentity.GetCurrent()); }, WindowsIdentity.GetCurrent());

View file

@ -113,25 +113,14 @@ namespace ScrewTurn.Wiki {
} }
protected void btnRebuildPageLinks_Click(object sender, EventArgs e) { protected void btnRebuildPageLinks_Click(object sender, EventArgs e) {
RebuildPageLinks(Pages.GetPages(null)); Pages.RebuildPageLinks(Pages.GetPages(null));
foreach(NamespaceInfo nspace in Pages.GetNamespaces()) { foreach(NamespaceInfo nspace in Pages.GetNamespaces()) {
RebuildPageLinks(Pages.GetPages(nspace)); Pages.RebuildPageLinks(Pages.GetPages(nspace));
} }
DisplayOrphansCount(); DisplayOrphansCount();
} }
/// <summary>
/// Rebuilds the page links for the specified pages.
/// </summary>
/// <param name="pages">The pages.</param>
private void RebuildPageLinks(IList<PageInfo> pages) {
foreach(PageInfo page in pages) {
PageContent content = Content.GetPageContent(page, false);
Pages.StorePageOutgoingLinks(page, content.Content);
}
}
protected void rptIndex_DataBinding(object sender, EventArgs e) { protected void rptIndex_DataBinding(object sender, EventArgs e) {
List<IndexRow> result = new List<IndexRow>(5); List<IndexRow> result = new List<IndexRow>(5);