r98050 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98049‎ | r98050 | r98051 >
Date:02:21, 25 September 2011
Author:samuellampa
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/RDFIO/classes/RDFStore.php (modified) (history)
  • /trunk/extensions/RDFIO/classes/SMWBatchWriter.php (modified) (history)
  • /trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RDFIO/specials/SpecialRDFImport_body.php
@@ -29,6 +29,7 @@
3030
3131 $this->setHeaders();
3232 $this->handleRequestData();
 33+ $showscreensonly = false;
3334
3435 if ( $this->m_action == 'Import' ) {
3536 if ( !$wgUser->matchEditToken( $this->m_edittoken ) ) {
Index: trunk/extensions/RDFIO/classes/PageHandler.php
@@ -46,9 +46,11 @@
4747 $properties = $this->m_properties;
4848 foreach ( $properties as $cur_prop ) {
4949 $propertystring = $cur_prop['p'];
50 - $property = SMWPropertyValue::makeUserProperty( $propertystring );
 50+ // TODO: Remove old code:
 51+ // $property = SMWPropertyValue::makeUserProperty( $propertystring );
 52+ $property_di = SMWDIProperty::newFromUserLabel($propertystring);
5153 $valuestring = RDFIOUtils::sanitizeSMWValue( $cur_prop['v'] );
52 - $value = SMWDataValueFactory::newPropertyObjectValue( $property, $valuestring );
 54+ $value = SMWDataValueFactory::newPropertyObjectValue( $property_di, $valuestring );
5355
5456 $propertyErrorText = $property->getErrorText();
5557 $propertyHasError = ( $propertyErrorText != '' );
@@ -161,16 +163,25 @@
162164 */
163165 private function initSMWWriter( $delete = false ) {
164166 // Create add and remove objects, to use in SMWWriter calls
165 - $page = SMWWikiPageValue::makePage( $this->m_wikititle, $this->m_ns );
 167+
 168+ // TODO: Should rather use (but not possible with current SMWWriter API?):
 169+ // $page_di = SMWDIWikiPage::newFromTitle( Title::makeTitle($this->m_ns, $this->m_wikititle) );
 170+ $page = SMWWikiPageValue::makePage( $this->m_wikititle, $this->m_ns );
 171+ $page_di = $page->getDataItem();
 172+ $page_data = new SMWSemanticData( $page_di );
 173+
 174+ $dummypage = SMWWikiPageValue::makePage( false, $this->m_ns );
 175+ $dummypage_di = $dummypage->getDataItem();
 176+ $dummypag_data = new SMWSemanticData( $dummypage_di );
 177+
 178+
166179 $this->m_smwwriter = new SMWWriter( $page->getTitle() );
167180 if ( $delete ) {
168 - // We are not adding anything, so create a "page" with "false" title
169 - $this->m_smwwriter_add = new SMWSemanticData( SMWWikiPageValue::makePage( false, $this->m_ns ) );
170 - $this->m_smwwriter_remove = new SMWSemanticData( $page );
 181+ $this->m_smwwriter_add = $page_data;
 182+ $this->m_smwwriter_remove = $dummypag_data;
171183 } else {
172 - $this->m_smwwriter_add = new SMWSemanticData( $page );
173 - // We are not removing anything, so create a "page" with "false" title
174 - $this->m_smwwriter_remove = new SMWSemanticData( SMWWikiPageValue::makePage( false, $this->m_ns ) );
 184+ $this->m_smwwriter_add = $dummypag_data;
 185+ $this->m_smwwriter_remove = $page_data;
175186 }
176187 }
177188
Index: trunk/extensions/RDFIO/classes/SMWBatchWriter.php
@@ -60,12 +60,12 @@
6161
6262 // Previously in Equiv URI Class
6363
64 - if ( $rdfiogUsePseudoNamespacesForProperties != '' ) { // TODO: Change to check options from import screen
 64+ if ( isset($rdfiogUsePseudoNamespacesForProperties) ) { // TODO: Change to check options from import screen
6565 // use parameter set in LocalSettings.php
6666 $this->m_usenspintitles_properties = $rdfiogUsePseudoNamespacesForProperties;
6767 }
6868
69 - if ( $rdfiogUsePseudoNamespacesForEntities != '' ) {
 69+ if ( isset($rdfiogUsePseudoNamespacesForEntities) ) {
7070 // use parameter set in LocalSettings.php
7171 $this->m_usenspintitles_entities = $rdfiogUsePseudoNamespacesForEntities;
7272 }
Index: trunk/extensions/RDFIO/classes/RDFStore.php
@@ -53,6 +53,10 @@
5454 $rs = $store->query( $q );
5555 if ( !$store->getErrors() ) {
5656 $rows = $rs['result']['rows'];
 57+ // @todo FIXME: Handle this case more nicely
 58+ if (count($rows) == 0) {
 59+ die( "No rows returned" );
 60+ }
5761 $row = $rows[0];
5862 $origuri = $row['origuri'];
5963 } else {

Status & tagging log