Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-6902

When creating a new wiki, use the XWikiDocument class to save the wiki descriptor and not the api.Document class

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2 M2
    • Fix Version/s: 3.2 M3
    • Component/s: {Unused} Wiki Manager
    • Labels:
      None
    • keywords:
      wiki manager core api create wiki limitation patch
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      The wiki manager plugin works with web api classes such as Document and that is good for when it is called from velocity or from its plugin API, but the problem is that internally, it also uses web api classes instead of using core classes like XWikiDocument:

      wikiSuperDocToSave.save(comment);
      

      One problem that this behaviour is causing is that the plugin api makes user rights check and document PR check on wiki creation, but the, it checks a second time, internally, when saving the wiki descriptor by using Document.save(). This is messing things up for code that wants to allow regular users to create wikis (like the workspaces feature) because the "convention" of "platform code uses core model directly without extra checks; web code uses web api and does all the checking" is not enforced.

      The solution (here) is simple:

      XWikiDocument wikiSuperXDocToSave = wikiSuperDocToSave.getDocument();
      context.getWiki().saveDocument(wikiSuperXDocToSave, comment, context);
      

        Attachments

          Activity

            People

            • Assignee:
              tmortagne Thomas Mortagne
              Reporter:
              enygma Eduard Moraru
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Date of First Response: