Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -151,7 +151,6 @@ |
152 | 152 | '__lin' => 'smw_spec2', // Special linear unit conversion type |
153 | 153 | '__imp' => 'smw_spec2', // Special import vocabulary type |
154 | 154 | '__err' => '', // Special error type, used to indicate that the table could not be determined (happens for type-polymorphic _1, _2, ...) |
155 | | - // '__pro' => SMW_SQL2_NONE, // Property page type; actually this should never be stored as a value (_wpp is used there) |
156 | 155 | ); |
157 | 156 | |
158 | 157 | /// Array to cache signatures of known built-in types. Having this data |
— | — | @@ -474,6 +473,7 @@ |
475 | 474 | } |
476 | 475 | |
477 | 476 | /** |
| 477 | + * returns an array of SMWWikiPageValue. |
478 | 478 | * |
479 | 479 | * @param SMWPropertyValue $property |
480 | 480 | * @param $value |
— | — | @@ -1223,9 +1223,12 @@ |
1224 | 1224 | public function setup( $verbose = true ) { |
1225 | 1225 | $this->reportProgress( "Setting up standard database configuration for SMW ...\n\n", $verbose ); |
1226 | 1226 | $this->reportProgress( "Selected storage engine is \"SMWSQLStore2\" (or an extension thereof)\n\n", $verbose ); |
| 1227 | + |
1227 | 1228 | $db = wfGetDB( DB_MASTER ); |
| 1229 | + |
1228 | 1230 | $this->setupTables( $verbose, $db ); |
1229 | 1231 | $this->setupPredefinedProperties( $verbose, $db ); |
| 1232 | + |
1230 | 1233 | return true; |
1231 | 1234 | } |
1232 | 1235 | |
— | — | @@ -1258,9 +1261,9 @@ |
1259 | 1262 | global $wgDBtype; |
1260 | 1263 | |
1261 | 1264 | extract( $db->tableNames( 'smw_ids', 'smw_spec2', 'smw_conccache', 'smw_conc2' ) ); |
1262 | | - $reportTo = $verbose ? $this:null; // use $this to report back from static SMWSQLHelpers |
| 1265 | + $reportTo = $verbose ? $this : null; // Use $this to report back from static SMWSQLHelpers. |
1263 | 1266 | |
1264 | | - // repeatedly used DB field types defined here for convenience |
| 1267 | + // Repeatedly used DB field types defined here for convenience. |
1265 | 1268 | $dbtypes = array( |
1266 | 1269 | 't' => SMWSQLHelpers::getStandardDBType( 'title' ), |
1267 | 1270 | 'u' => ( $wgDBtype == 'postgres' ? 'TEXT' : 'VARCHAR(63) binary' ), |
— | — | @@ -1273,7 +1276,7 @@ |
1274 | 1277 | 'w' => SMWSQLHelpers::getStandardDBType( 'iw' ) |
1275 | 1278 | ); |
1276 | 1279 | |
1277 | | - // DB update: field renaming between SMW 1.3 and SMW 1.4 |
| 1280 | + // DB update: field renaming between SMW 1.3 and SMW 1.4. |
1278 | 1281 | if ( ( $db->tableExists( $smw_spec2 ) ) && ( $db->fieldExists( $smw_spec2, 'sp_id', 'SMWSQLStore2::setup' ) ) ) { |
1279 | 1282 | if ( $wgDBtype == 'postgres' ) { |
1280 | 1283 | $db->query( "ALTER TABLE $smw_spec2 ALTER COLUMN sp_id RENAME TO p_id", 'SMWSQLStore2::setup' ); |
— | — | @@ -1288,9 +1291,9 @@ |
1289 | 1292 | array( |
1290 | 1293 | 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY AUTO_INCREMENT' ), |
1291 | 1294 | '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 | + 'smw_title' => $dbtypes['t'] . ' NOT NULL', |
| 1296 | + 'smw_iw' => $dbtypes['w'], |
| 1297 | + 'smw_sortkey' => $dbtypes['t'] . ' NOT NULL' |
1295 | 1298 | ), |
1296 | 1299 | $db, |
1297 | 1300 | $reportTo |
— | — | @@ -1311,20 +1314,41 @@ |
1312 | 1315 | |
1313 | 1316 | SMWSQLHelpers::setupIndex( $smw_conccache, array( 'o_id' ), $db ); |
1314 | 1317 | |
1315 | | - // set up concept descriptions |
1316 | | - SMWSQLHelpers::setupTable( $smw_conc2, |
1317 | | - array( 's_id' => $dbtypes['p'] . ' NOT NULL' . |
1318 | | - ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY' ), |
1319 | | - 'concept_txt' => $dbtypes['l'], |
1320 | | - 'concept_docu' => $dbtypes['l'], |
1321 | | - 'concept_features' => $dbtypes['i'], |
1322 | | - 'concept_size' => $dbtypes['i'], |
1323 | | - 'concept_depth' => $dbtypes['i'], |
1324 | | - 'cache_date' => $dbtypes['j'], |
1325 | | - 'cache_count' => $dbtypes['j'] ), $db, $reportTo ); |
| 1318 | + // Set up concept descriptions. |
| 1319 | + SMWSQLHelpers::setupTable( |
| 1320 | + $smw_conc2, |
| 1321 | + array( |
| 1322 | + 's_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY' ), |
| 1323 | + 'concept_txt' => $dbtypes['l'], |
| 1324 | + 'concept_docu' => $dbtypes['l'], |
| 1325 | + 'concept_features' => $dbtypes['i'], |
| 1326 | + 'concept_size' => $dbtypes['i'], |
| 1327 | + 'concept_depth' => $dbtypes['i'], |
| 1328 | + 'cache_date' => $dbtypes['j'], |
| 1329 | + 'cache_count' => $dbtypes['j'] |
| 1330 | + ), |
| 1331 | + $db, |
| 1332 | + $reportTo |
| 1333 | + ); |
| 1334 | + |
1326 | 1335 | SMWSQLHelpers::setupIndex( $smw_conc2, array( 's_id' ), $db ); |
1327 | 1336 | |
1328 | 1337 | // Set up all property tables as defined: |
| 1338 | + $this->setupPropertyTables( $dbtypes, $db, $reportTo ); |
| 1339 | + |
| 1340 | + $this->reportProgress( "Database initialised successfully.\n\n", $verbose ); |
| 1341 | + } |
| 1342 | + |
| 1343 | + /** |
| 1344 | + * Sets up the property tables. |
| 1345 | + * |
| 1346 | + * @param array $dbtypes |
| 1347 | + * @param $db |
| 1348 | + * @param $reportTo SMWSQLStore2 or null |
| 1349 | + */ |
| 1350 | + protected function setupPropertyTables( array $dbtypes, $db, $reportTo ) { |
| 1351 | + $addedCustomTypeSignatures = false; |
| 1352 | + |
1329 | 1353 | foreach ( self::getPropertyTables() as $proptable ) { |
1330 | 1354 | if ( $proptable->idsubject ) { |
1331 | 1355 | $fieldarray = array( 's_id' => $dbtypes['p'] . ' NOT NULL' ); |
— | — | @@ -1334,24 +1358,31 @@ |
1335 | 1359 | $indexes = array( 's_title,s_namespace' ); |
1336 | 1360 | } |
1337 | 1361 | |
1338 | | - if ( $proptable->fixedproperty == false ) { |
| 1362 | + if ( !$proptable->fixedproperty ) { |
1339 | 1363 | $fieldarray['p_id'] = $dbtypes['p'] . ' NOT NULL'; |
1340 | 1364 | $indexes[] = 'p_id'; |
1341 | 1365 | } |
1342 | 1366 | |
1343 | 1367 | foreach ( $proptable->objectfields as $fieldname => $typeid ) { |
1344 | | - $fieldarray[$fieldname] = $dbtypes[$typeid]; |
| 1368 | + // If the type signature is not recognized and the custom signatures have not been added, add them. |
| 1369 | + if ( !$addedCustomTypeSignatures && !array_key_exists( $typeid, $dbtypes ) ) { |
| 1370 | + wfRunHooks( 'SMWCustomSQLStoreFieldType', array( &$dbtypes ) ); |
| 1371 | + $addedCustomTypeSignatures = true; |
| 1372 | + } |
| 1373 | + |
| 1374 | + // Only add the type when the signature was recognized, otherwise ignore it silently. |
| 1375 | + if ( array_key_exists( $typeid, $dbtypes ) ) { |
| 1376 | + $fieldarray[$fieldname] = $dbtypes[$typeid]; |
| 1377 | + } |
1345 | 1378 | } |
1346 | 1379 | |
1347 | 1380 | $indexes = array_merge( $indexes, $proptable->indexes ); |
1348 | 1381 | |
1349 | 1382 | SMWSQLHelpers::setupTable( $db->tableName( $proptable->name ), $fieldarray, $db, $reportTo ); |
1350 | | - SMWSQLHelpers::setupIndex( $db->tableName( $proptable->name ), $indexes, $db ); |
1351 | | - } |
1352 | | - |
1353 | | - $this->reportProgress( "Database initialised successfully.\n\n", $verbose ); |
| 1383 | + SMWSQLHelpers::setupIndex( $db->tableName( $proptable->name ), $indexes, $db ); |
| 1384 | + } |
1354 | 1385 | } |
1355 | | - |
| 1386 | + |
1356 | 1387 | /** |
1357 | 1388 | * Create some initial DB entries for important built-in properties. Having the DB contents predefined |
1358 | 1389 | * allows us to safe DB calls when certain data is needed. At the same time, the entries in the DB |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -39,6 +39,8 @@ |
40 | 40 | * @note The resulting wikipage object might be invalid if |
41 | 41 | * the provided title is not allowed. An object is returned |
42 | 42 | * in any case. |
| 43 | + * |
| 44 | + * @return SMWWikiPageValue |
43 | 45 | */ |
44 | 46 | static public function makePage( $title, $namespace, $sortkey = '', $interwiki = '' ) { |
45 | 47 | $page = new SMWWikiPageValue( '_wpg' ); |