On my wiki we use attributes inside templates. This is working well for pages that are edited manually.

Now I need to import pages from text files into the wiki. All is working well, except for SMW attributes inside templates.

The code that creates the article is like this:

function editPage(&$title, $text, $comment)
    $article=new Article($title);
    $article->doEdit($text, $comment);
    return "OK";

If $text contains attributes, they are created and the inline query for this attribute will show the new page.

But if $text contains a template that defines attributes, the attributes are shown on the fact box on the page footer, but the page is not shown when I click on the query icon inside the fact box.

I was able to verify that some important hook functions are being called during $article->doEdit, specifically smwfParserHook and smwfSaveHook. I also searched the SMW documentation and mailing list but I couldn't find any new information on how to solve this problem.

I'd be very grateful if someone could help me. After all, importing pages is a common need that may happen to other users in the future.