r66674 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66673‎ | r66674 | r66675 >
Date:01:16, 20 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r66673
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -387,7 +387,7 @@
388388 foreach ( $proptable->objectfields as $fieldname => $typeid ) { // now add select entries for object column(s)
389389 if ( $typeid == 'p' ) { // Special case: page id, use smw_id table to insert 4 page-specific values instead of internal id
390390 $from .= ' INNER JOIN ' . $db->tableName( 'smw_ids' ) . " AS o$valuecount ON $fieldname=o$valuecount.smw_id";
391 - $select .= ( ( $select != '' ) ? ',':'' ) . "$fieldname AS id$valuecount";
 391+ $select .= ( ( $select != '' ) ? ',' : '' ) . "$fieldname AS id$valuecount";
392392 $selectvalues[$valuecount] = "o$valuecount.smw_title";
393393 $selectvalues[$valuecount + 1] = "o$valuecount.smw_namespace";
394394 $selectvalues[$valuecount + 2] = "o$valuecount.smw_iw";
@@ -457,7 +457,7 @@
458458 foreach ( self::getPropertyTables() as $tid => $pt ) { // just read all
459459 $newvalue = array_merge( $newvalue, $this->fetchSemanticData( $row->$oidfield, null, $pt ) );
460460 }
461 - } elseif ( ( $iw != '' ) && ( $iw { 0 } == ':' ) ) { // other internal object, maybe a DB inconsistency; ignore row
 461+ } elseif ( ( $iw != '' ) && ( $iw { 0 } == ' : ' ) ) { // other internal object, maybe a DB inconsistency; ignore row
462462 $propertyname = '';
463463 }
464464 next( $pagevalues );
@@ -520,7 +520,7 @@
521521 }
522522
523523 if ( $proptable->fixedproperty == false ) {
524 - $where .= ( $where ? ' AND ':'' ) . "t1.p_id=" . $db->addQuotes( $pid );
 524+ $where .= ( $where ? ' AND ' : '' ) . "t1.p_id=" . $db->addQuotes( $pid );
525525 }
526526
527527 $this->prepareValueQuery( $from, $where, $proptable, $value, 1 );
@@ -587,7 +587,7 @@
588588 }
589589
590590 if ( $subproptable->fixedproperty == false ) { // the ID we get should be !=0, so no point in filtering the converse
591 - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.p_id=" . $db->addQuotes( $this->getSMWPropertyID( $subproperty ) );
 591+ $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.p_id=" . $db->addQuotes( $this->getSMWPropertyID( $subproperty ) );
592592 }
593593
594594 $this->prepareValueQuery( $from, $where, $subproptable, $subvalue, $tableindex );
@@ -603,9 +603,9 @@
604604 if ( $typeid == 'p' ) { // Special case: page id, resolve this in advance
605605 $oid = $this->getSMWPageID( $dbkeys[$i], $dbkeys[$i + 1], $dbkeys[$i + 2] );
606606 $i += 3; // skip these additional values (sortkey not needed here)
607 - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $oid );
 607+ $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $oid );
608608 } elseif ( $typeid != 'l' ) { // plain value, but not a text blob
609 - $where .= ( $where ? ' AND ':'' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $dbkeys[$i] );
 609+ $where .= ( $where ? ' AND ' : '' ) . "t$tableindex.$fieldname=" . $db->addQuotes( $dbkeys[$i] );
610610 }
611611
612612 $i++;
@@ -1261,16 +1261,18 @@
12621262 $reportTo = $verbose ? $this:null; // use $this to report back from static SMWSQLHelpers
12631263
12641264 // repeatedly used DB field types defined here for convenience
1265 - $dbtypes = array( 't' => SMWSQLHelpers::getStandardDBType( 'title' ),
1266 - 'u' => ( $wgDBtype == 'postgres' ? 'TEXT' : 'VARCHAR(63) binary' ),
1267 - 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ),
1268 - 'f' => ( $wgDBtype == 'postgres' ? 'DOUBLE PRECISION' : 'DOUBLE' ),
1269 - 'i' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8)' ),
1270 - 'j' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8) UNSIGNED' ),
1271 - 'p' => SMWSQLHelpers::getStandardDBType( 'id' ),
1272 - 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ),
1273 - 'w' => SMWSQLHelpers::getStandardDBType( 'iw' ) );
1274 -//.//
 1265+ $dbtypes = array(
 1266+ 't' => SMWSQLHelpers::getStandardDBType( 'title' ),
 1267+ 'u' => ( $wgDBtype == 'postgres' ? 'TEXT' : 'VARCHAR(63) binary' ),
 1268+ 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ),
 1269+ 'f' => ( $wgDBtype == 'postgres' ? 'DOUBLE PRECISION' : 'DOUBLE' ),
 1270+ 'i' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8)' ),
 1271+ 'j' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8) UNSIGNED' ),
 1272+ 'p' => SMWSQLHelpers::getStandardDBType( 'id' ),
 1273+ 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ),
 1274+ 'w' => SMWSQLHelpers::getStandardDBType( 'iw' )
 1275+ );
 1276+
12751277 // DB update: field renaming between SMW 1.3 and SMW 1.4
12761278 if ( ( $db->tableExists( $smw_spec2 ) ) && ( $db->fieldExists( $smw_spec2, 'sp_id', 'SMWSQLStore2::setup' ) ) ) {
12771279 if ( $wgDBtype == 'postgres' ) {
@@ -1280,26 +1282,39 @@
12811283 }
12821284 }
12831285
1284 - // set up table for internal IDs used in this store:
1285 - SMWSQLHelpers::setupTable( $smw_ids,
1286 - array( 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY':' KEY AUTO_INCREMENT' ),
1287 - 'smw_namespace' => $dbtypes['n'] . ' NOT NULL',
1288 - 'smw_title' => $dbtypes['t'] . ' NOT NULL',
1289 - 'smw_iw' => $dbtypes['w'],
1290 - 'smw_sortkey' => $dbtypes['t'] . ' NOT NULL' ), $db, $reportTo );
 1286+ // Set up table for internal IDs used in this store:
 1287+ SMWSQLHelpers::setupTable(
 1288+ $smw_ids,
 1289+ array(
 1290+ 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY AUTO_INCREMENT' ),
 1291+ 'smw_namespace' => $dbtypes['n'] . ' NOT NULL',
 1292+ 'smw_title' => $dbtypes['t'] . ' NOT NULL',
 1293+ 'smw_iw' => $dbtypes['w'],
 1294+ 'smw_sortkey' => $dbtypes['t'] . ' NOT NULL'
 1295+ ),
 1296+ $db,
 1297+ $reportTo
 1298+ );
 1299+
12911300 SMWSQLHelpers::setupIndex( $smw_ids, array( 'smw_id', 'smw_title,smw_namespace,smw_iw', 'smw_sortkey' ), $db );
12921301
1293 - // set up concept cache: member elements (s)->concepts (o)
1294 - SMWSQLHelpers::setupTable( $smw_conccache,
1295 - array( 's_id' => $dbtypes['p'] . ' NOT NULL',
1296 - 'o_id' => $dbtypes['p'] . ' NOT NULL' ), $db, $reportTo );
 1302+ // Set up concept cache: member elements (s)->concepts (o)
 1303+ SMWSQLHelpers::setupTable(
 1304+ $smw_conccache,
 1305+ array(
 1306+ 's_id' => $dbtypes['p'] . ' NOT NULL',
 1307+ 'o_id' => $dbtypes['p'] . ' NOT NULL'
 1308+ ),
 1309+ $db,
 1310+ $reportTo
 1311+ );
12971312
12981313 SMWSQLHelpers::setupIndex( $smw_conccache, array( 'o_id' ), $db );
12991314
13001315 // set up concept descriptions
13011316 SMWSQLHelpers::setupTable( $smw_conc2,
13021317 array( 's_id' => $dbtypes['p'] . ' NOT NULL' .
1303 - ( $wgDBtype == 'postgres' ? ' PRIMARY KEY':' KEY' ),
 1318+ ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY' ),
13041319 'concept_txt' => $dbtypes['l'],
13051320 'concept_docu' => $dbtypes['l'],
13061321 'concept_features' => $dbtypes['i'],
@@ -1413,7 +1428,7 @@
14141429
14151430 foreach ( $tables as $table ) {
14161431 $name = $db->tableName( $table );
1417 - $db->query( 'DROP TABLE' . ( $wgDBtype == 'postgres' ? '':' IF EXISTS' ) . $name, 'SMWSQLStore2::drop' );
 1432+ $db->query( 'DROP TABLE' . ( $wgDBtype == 'postgres' ? '' : ' IF EXISTS' ) . $name, 'SMWSQLStore2::drop' );
14181433 $this->reportProgress( " ... dropped table $name.\n", $verbose );
14191434 }
14201435
@@ -1634,13 +1649,14 @@
16351650 if ( $labelcol != '' ) { // Apply string conditions.
16361651 foreach ( $requestoptions->getStringConditions() as $strcond ) {
16371652 $string = str_replace( '_', '\_', $strcond->string );
 1653+
16381654 switch ( $strcond->condition ) {
16391655 case SMWStringCondition::STRCOND_PRE: $string .= '%'; break;
16401656 case SMWStringCondition::STRCOND_POST: $string = '%' . $string; break;
16411657 case SMWStringCondition::STRCOND_MID: $string = '%' . $string . '%'; break;
16421658 }
16431659
1644 - $sql_conds .= ( ( $addand || ( $sql_conds != '' ) ) ? ' AND ':'' ) . $labelcol . ' LIKE ' . $db->addQuotes( $string );
 1660+ $sql_conds .= ( ( $addand || ( $sql_conds != '' ) ) ? ' AND ' : '' ) . $labelcol . ' LIKE ' . $db->addQuotes( $string );
16451661 }
16461662 }
16471663 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66673Style improvementsjeroendedauw01:08, 20 May 2010

Status & tagging log