On 30/07/11 01:10, Samuel Lampa wrote:
> Hi,
>
> 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 ...

You may want to take advantage of our extensive API documentation at

http://semantic-mediawiki.org/doc/classSMWDIWikiPage.html

The normal way to create DI objects is to use the constructor 
(__construct()). If your "title" is a DBKey (normalised) then this 
should work best for you. The method newFromSerialization() is only used 
to re-create DIs from the output of getSerialization(). Another way to 
get a data item is to call the method getDataItem() that any 
SMWDataValue object has (but making a DataValue in the first place is 
more work). The SMWDIWikiPage also has newFromTitle() that is based on a 
Title *object*, not a title string.

Some of your above code creates some very strange (to my eye) 
SMWWikiPageValue objects that might actually be invalid (check with 
isValid()). Namely, you try to use "false" as a title string, but a 
title string should be a valid MediaWiki page title.

Regards,

Markus


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


------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to