http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98050

Revision: 98050
Author:   samuellampa
Date:     2011-09-25 02:21:37 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
Bugfix: 1. Check that variables are set also, not only non-empty. 2. Don't 
check empty variable.

Modified Paths:
--------------
    trunk/extensions/RDFIO/classes/PageHandler.php
    trunk/extensions/RDFIO/classes/RDFStore.php
    trunk/extensions/RDFIO/classes/SMWBatchWriter.php
    trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php

Modified: trunk/extensions/RDFIO/classes/PageHandler.php
===================================================================
--- trunk/extensions/RDFIO/classes/PageHandler.php      2011-09-25 02:09:42 UTC 
(rev 98049)
+++ trunk/extensions/RDFIO/classes/PageHandler.php      2011-09-25 02:21:37 UTC 
(rev 98050)
@@ -46,9 +46,11 @@
         $properties = $this->m_properties;
         foreach ( $properties as $cur_prop ) {
             $propertystring = $cur_prop['p'];
-            $property = SMWPropertyValue::makeUserProperty( $propertystring );
+            // TODO: Remove old code:
+            // $property = SMWPropertyValue::makeUserProperty( $propertystring 
);
+            $property_di = SMWDIProperty::newFromUserLabel($propertystring);
             $valuestring = RDFIOUtils::sanitizeSMWValue( $cur_prop['v'] );
-            $value    = SMWDataValueFactory::newPropertyObjectValue( 
$property, $valuestring );
+            $value    = SMWDataValueFactory::newPropertyObjectValue( 
$property_di, $valuestring );
 
             $propertyErrorText = $property->getErrorText();
             $propertyHasError = ( $propertyErrorText != '' );
@@ -161,16 +163,25 @@
      */
     private function initSMWWriter( $delete = false ) {
         // Create add and remove objects, to use in SMWWriter calls
-        $page = SMWWikiPageValue::makePage( $this->m_wikititle, $this->m_ns );
+               
+        // TODO: Should rather use (but not possible with current SMWWriter 
API?):
+       // $page_di = SMWDIWikiPage::newFromTitle( 
Title::makeTitle($this->m_ns, $this->m_wikititle) );
+       $page = SMWWikiPageValue::makePage( $this->m_wikititle, $this->m_ns );
+       $page_di = $page->getDataItem(); 
+       $page_data = new SMWSemanticData( $page_di ); 
+       
+       $dummypage = SMWWikiPageValue::makePage( false, $this->m_ns );
+       $dummypage_di = $dummypage->getDataItem();
+        $dummypag_data = new SMWSemanticData( $dummypage_di ); 
+       
+        
         $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 );
+            $this->m_smwwriter_add    = $page_data;
+            $this->m_smwwriter_remove = $dummypag_data;
         } 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 ) );
+            $this->m_smwwriter_add    = $dummypag_data;
+            $this->m_smwwriter_remove = $page_data;
         }
     }
 

Modified: trunk/extensions/RDFIO/classes/RDFStore.php
===================================================================
--- trunk/extensions/RDFIO/classes/RDFStore.php 2011-09-25 02:09:42 UTC (rev 
98049)
+++ trunk/extensions/RDFIO/classes/RDFStore.php 2011-09-25 02:21:37 UTC (rev 
98050)
@@ -53,6 +53,10 @@
         $rs = $store->query( $q );
         if ( !$store->getErrors() ) {
             $rows = $rs['result']['rows'];
+            // @todo FIXME: Handle this case more nicely
+            if (count($rows) == 0) {
+                   die( "No rows returned" );
+            }
             $row = $rows[0];
             $origuri = $row['origuri'];
         } else {

Modified: trunk/extensions/RDFIO/classes/SMWBatchWriter.php
===================================================================
--- trunk/extensions/RDFIO/classes/SMWBatchWriter.php   2011-09-25 02:09:42 UTC 
(rev 98049)
+++ trunk/extensions/RDFIO/classes/SMWBatchWriter.php   2011-09-25 02:21:37 UTC 
(rev 98050)
@@ -60,12 +60,12 @@
 
         // Previously in Equiv URI Class
 
-        if ( $rdfiogUsePseudoNamespacesForProperties != '' ) { // TODO: Change 
to check options from import screen
+        if ( isset($rdfiogUsePseudoNamespacesForProperties) ) { // TODO: 
Change to check options from import screen
             // use parameter set in LocalSettings.php
             $this->m_usenspintitles_properties = 
$rdfiogUsePseudoNamespacesForProperties;
         }
 
-        if ( $rdfiogUsePseudoNamespacesForEntities != '' ) {
+        if ( isset($rdfiogUsePseudoNamespacesForEntities) ) {
             // use parameter set in LocalSettings.php
             $this->m_usenspintitles_entities = 
$rdfiogUsePseudoNamespacesForEntities;
         }

Modified: trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php
===================================================================
--- trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php   2011-09-25 
02:09:42 UTC (rev 98049)
+++ trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php   2011-09-25 
02:21:37 UTC (rev 98050)
@@ -29,6 +29,7 @@
 
                $this->setHeaders();
                $this->handleRequestData();
+               $showscreensonly = false;
 
                if ( $this->m_action == 'Import' ) {
                        if ( !$wgUser->matchEditToken( $this->m_edittoken ) ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to