Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Create a wiki page

I am getting security exceptions when trying to create a wiki page.  Once I added the "ignorepermissions=true" my code was no longer causing an exception, but other plugins that register for onbeforecommit can't read the page.

Is there an example of the "proper" way to create a wiki article?

My current code is:
CWikiPage newpage = api.WikiPage.NewWikiPage();
newpage.sHeadline = "US" + sValue.ToString();
newpage.sBody = "case " + sValue.ToString();
newpage.ixWiki = 45;
newpage.IgnorePermissions = true;
newpage.IgnorePermissions = false;
Rick Dales Send private email
Friday, September 18, 2009
Hi Rick,

Your code seems correct; when I try it it seems to work fine.

Writing a wiki page requires that the user have write permissions within the wiki.  So in your example, the user would need to have permission on ixWiki=45.

When is this code running?  Who is the user that is logged in?  The user when the code is first run should be the same as the user when BeforeCommit runs, so it sounds like that user doesn't have any permissions on ixWiki=45.

If this doesn't turn anything up, could you post the message of the exception you're seeing?
David Fullerton Send private email
Friday, September 18, 2009
The user is a site administator.  I am running this code in a PageDisplay() method in a page that I added.  The user gets to this page from a link that I display in BugDisplayViewLeft()

The same user (in the same session) can create wiki pages using the FogBugz UI in all wikis that exist.

The error is:
FogCreek.FogBugz.Exception.FogBugzSecurityException: The user does not have permission to read this object.Server stack trace:    at FogCreek.FogBugz.CProxyReadOnlyBase.AssertReadable()  at FogCreek.FogBugz.Plugins.Entity.CWikiPage.get_sBody()  at FogCreek.Plugins.Wiki.WikiBlockManager.WikiPageCommitBefore(CWikiPage oWikiPage)  at FogCreek.Plugins.Wiki.WikiBlockPlugin.WikiPageCommitBefore(CWikiPage oWikiPage)  at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)  at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)  at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)Exception rethrown at [0]:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)  at FogCreek.FogBugz.Plugins.Interfaces.IPluginWikiPageCommit.WikiPageCommitBefore(CWikiPage wikipage)  at FogCreek.FogBugz.CWikiPage.PluginBeforeCommit()
Rick Dales Send private email
Monday, September 21, 2009

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz