I think the solution is as simple as calling getDataItem on your SMWWikiPageValue before passing it along. I guess we might need to docs somewhere on the DV/DI changes in SMW 1.6, because right now Markus and I are probably the only people that have a good idea of what changed. TodoListSize++;


Jeroen De Dauw
Don't panic. Don't be evil.

On 30 July 2011 02:18, Samuel Lampa <samuel.lampa.l@rilnet.com> wrote:

I got a reported bug (per mail) with the initSMWWriter function in the PageHandler class in RDFIO [1] (For complete code, see: [2]), which seem to be due to some API changes in SMW, for which I'd need some guidance.

When trying to import the test data (from the "paste test data link") on the Special:RDFImport page, one gets:

Catchable fatal error: Argument 1 passed to SMWSemanticData::__construct() must be an instance of SMWDIWikiPage, instance of SMWWikiPageValue given, called in /home/samuel/www/smw-trunk/extensions/RDFIO/classes/PageHandler.php on line 171 and defined in /home/samuel/www/smw-trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php on line 103

Below is the relevant code from PageHandler.php. (line 171 highlighted):

$page = SMWWikiPageValue::makePage( $this->m_wikititle, $this->m_ns );

$this->m_smwwriter = new SMWWriter( $page->getTitle() );
if ( $delete ) {
 // We are not adding anything, so create a "page" with "false" title
 $this->m_smwwriter_add    = new SMWSemanticData(
                SMWWikiPageValue::makePage( false, $this->m_ns ) );
 $this->m_smwwriter_remove = new SMWSemanticData( $page );
} else {
 *$this->m_smwwriter_add    = new SMWSemanticData( $page );*
 // We are not removing anything, so create a "page" with "false" title
 $this->m_smwwriter_remove = new SMWSemanticData(
   SMWWikiPageValue::makePage( false, $this->m_ns ) );

The problem is obviously that SMWWikiPageValue::makePage( false, $this->m_ns ) returns an SMWWikiPageValue, while I need an SMWDIWikiPage for creating the new SMWSemanticData:s.

So, how can I go about creating new SMWDIWikiPage, when I have the title and the namespace (like I have in the code above)?

There is SMWDIWikiPage::newFromTitle($title), but that does not take the namespace (which I'll need to specify, not?), and there is SMWDIWikiPage::newFromSerialization($diType, $serialization) ... but unfortunately don't have a clue how to get the correct $diType and $serialization ...

// Samuel

[1] http://localhost/smw-dev/index.php/Extension:RDFIO
[2] http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/RDFIO/classes/PageHandler.php

Samuel Lampa
 Bioinformatician @ Uppsala University
  Blog: http://saml.rilspace.org