Modify all Pages error

Hello xwiki Team,

I’m running xwiki 13.2.
I try to iterate over all the pages in my wiki to change the syntax.
My Idea was to iterate over all the Spaces of my Wiki and change the Syntax of every WebHome.
While iterating over all my documents, the xwiki was creating new Pages instead of modifying the correct page.
While I was trying to find my mistake, I was running the following example, which is also iterating over all the Pages

{{velocity}}
#foreach($space in $xwiki.spaces)
 * [[$space>>$services.model.createDocumentReference('', $space, '')]]
#end
{{/velocity}}

https://snippets.xwiki.org/xwiki/bin/view/Extension/List%20All%20Spaces
I got a list with Links to all my pages.
But when I was clicking on those links the wizard for creating a new page was opening up, instead of showing the correct page.
In the URL field of the browser it looks like that xwiki is using the Script Page as Parent for the Page I try to open.
Does anyone have an idea why it is not working?

The Script, that I was running:

{{velocity}}
#foreach($space in $xwiki.getSpaces())
#set($docRef  = $services.model.createDocumentReference('', $space, 'WebHome'))
#set($document = $xwiki.getDocument($docRef))
$document.convertSyntax("xwiki/2.1")
$document.save()
#end
{{/velocity}}

xwiki1

You should do a query instead, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module

Also you should change pages, not just space webhome.

Snippet example: Convert pages to another syntax (Extension.Convert pages to another syntax.WebHome) - XWiki

Actually I just checked and the snippet I pointed to is less good than calling $doc.convertSyntax()! :slight_smile: Reading the code, convertSyntax() also converts xobjects.

So all you need is to write a query to match the pages you need to convert.

Are you sure you wish to convert the syntax for default wiki pages coming from extensions? I don’t think you should… that’s seems risky.

May I ask from what syntax to which syntax you’re converting to?

I know, I’m not converting the Syntax of the default pages.
I was checking for a space name.
I just removed this check from the snippet to show just the necessary part.
But thanks for pointing this out. :slight_smile:

Ok, thanks for the quick answer. I’ll try to work with this snippet.