r60330 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60329‎ | r60330 | r60331 >
Date:17:29, 23 December 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
aggregated fixes for Bugs 21887, 21891, 21868, 20039, 21108 (based on offline work ... git would be nice sometimes ;-)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php
@@ -244,14 +244,17 @@
245245 * so that they are also replicated in SMW for more efficient querying.
246246 */
247247 static public function onParserAfterTidy(&$parser, &$text) {
 248+ global $smwgUseCategoryHierarchy,$smwgCategoriesAsInstances;
248249 if (SMWParseData::getSMWData($parser) === NULL) return true;
249250 $categories = $parser->mOutput->getCategoryLinks();
250251 foreach ($categories as $name) {
251 - $pinst = SMWPropertyValue::makeProperty('_INST');
252 - $dv = SMWDataValueFactory::newPropertyObjectValue($pinst);
253 - $dv->setValues($name,NS_CATEGORY);
254 - SMWParseData::getSMWData($parser)->addPropertyObjectValue($pinst,$dv);
255 - if (SMWParseData::getSMWData($parser)->getSubject()->getNamespace() == NS_CATEGORY) {
 252+ if ($smwgCategoriesAsInstances && (SMWParseData::getSMWData($parser)->getSubject()->getNamespace() != NS_CATEGORY) ) {
 253+ $pinst = SMWPropertyValue::makeProperty('_INST');
 254+ $dv = SMWDataValueFactory::newPropertyObjectValue($pinst);
 255+ $dv->setValues($name,NS_CATEGORY);
 256+ SMWParseData::getSMWData($parser)->addPropertyObjectValue($pinst,$dv);
 257+ }
 258+ if ($smwgUseCategoryHierarchy && (SMWParseData::getSMWData($parser)->getSubject()->getNamespace() == NS_CATEGORY) ) {
256259 $psubc = SMWPropertyValue::makeProperty('_SUBC');
257260 $dv = SMWDataValueFactory::newPropertyObjectValue($psubc);
258261 $dv->setValues($name,NS_CATEGORY);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php
@@ -298,12 +298,12 @@
299299 array_shift( $params ); // we already know the $parser ...
300300 foreach ($params as $p)
301301 if (trim($p) != "") {
302 - $parts = explode("=", trim($p));
 302+ $parts = explode("=", trim($p), 2);
303303 if (count($parts)==2) {
304304 $property = $parts[0];
305305 $object = $parts[1];
306306 SMWParseData::addProperty( $property, $object, false, $parser, true );
307 - }
 307+ } // else: no "=" given, ignore
308308 }
309309 SMWOutputs::commitToParser($parser); // not obviously required, but let us be sure
310310 return '';
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -144,7 +144,12 @@
145145 * The new SQL store's implementation of query answering.
146146 */
147147 public function getQueryResult(SMWQuery $query) {
148 - if ($query->querymode == SMWQuery::MODE_NONE) { // don't query, but return something to printer
 148+ global $smwgIgnoreQueryErrors;
 149+ if (!$smwgIgnoreQueryErrors && ($query->querymode != SMWQuery::MODE_DEBUG) && (count($query->getErrors()) > 0)) {
 150+ $result = new SMWQueryResult($query->getDescription()->getPrintrequests(), $query, array(), $this->m_store, false);
 151+ return $result;
 152+ /// NOTE: We currently check this only once since the below steps do not create further errors
 153+ } elseif ($query->querymode == SMWQuery::MODE_NONE) { // don't query, but return something to printer
149154 $result = new SMWQueryResult($query->getDescription()->getPrintrequests(), $query, array(), $this->m_store, true);
150155 return $result;
151156 }
@@ -156,11 +161,6 @@
157162 $this->m_distance = $query->getDistance();
158163 SMWSQLStore2Query::$qnum = 0;
159164 $this->m_sortkeys = $query->sortkeys;
160 - // manually make final root query (to retrieve namespace,title):
161 - $rootid = SMWSQLStore2Query::$qnum;
162 - $qobj = new SMWSQLStore2Query();
163 - $qobj->jointable = 'smw_ids';
164 - $qobj->joinfield = "$qobj->alias.smw_id";
165165 // build query dependency tree:
166166 wfProfileIn('SMWSQLStore2Queries::compileMainQuery (SMW)');
167167 $qid = $this->compileQueries($query->getDescription()); // compile query, build query "plan"
@@ -174,9 +174,18 @@
175175 $this->m_queries[$qid] = $q;
176176 }
177177 // append query to root:
178 - $qobj->components = array($qid => "$qobj->alias.smw_id");
179 - $qobj->sortfields = $this->m_queries[$qid]->sortfields;
180 - $this->m_queries[$rootid] = $qobj;
 178+ if ($this->m_queries[$qid]->jointable != 'smw_ids') {
 179+ // manually make final root query (to retrieve namespace,title):
 180+ $rootid = SMWSQLStore2Query::$qnum;
 181+ $qobj = new SMWSQLStore2Query();
 182+ $qobj->jointable = 'smw_ids';
 183+ $qobj->joinfield = "$qobj->alias.smw_id";
 184+ $qobj->components = array($qid => "$qobj->alias.smw_id");
 185+ $qobj->sortfields = $this->m_queries[$qid]->sortfields;
 186+ $this->m_queries[$rootid] = $qobj;
 187+ } else { // not such a common case, but it is worth avoiding the additional inner join here
 188+ $rootid = $qid;
 189+ }
181190
182191 $this->applyOrderConditions($query,$rootid); // may extend query if needed for sorting
183192 wfProfileIn('SMWSQLStore2Queries::executeMainQuery (SMW)');
@@ -426,7 +435,7 @@
427436 $isinverse = $property->isInverse();
428437 $pid = $this->m_store->getSMWPropertyID($property);
429438 $sortkey = $property->getDBkey(); /// TODO: strictly speaking, the DB key is not what we want here, since sortkey is based on a "wiki value"
430 - if ($mode != SMW_SQL2_SUBS2) { // also make property hierarchy (though not for all properties)
 439+ if ( ($mode != SMW_SQL2_SUBS2) && ($mode != SMW_SQL2_SUBP2) ) { // also make property hierarchy (though not for all properties)
431440 $pqid = SMWSQLStore2Query::$qnum;
432441 $pquery = new SMWSQLStore2Query();
433442 $pquery->type = SMW_SQL2_PROP_HIERARCHY;
@@ -438,17 +447,18 @@
439448 $pid = $property;
440449 $sortkey = false;
441450 $mode = SMWSQLStore2::getStorageMode($typeid);
442 - if ($mode != SMW_SQL2_SUBS2) { // no property hierarchy, but normal query (not for all properties)
 451+ if ( ($mode != SMW_SQL2_SUBS2) && ($mode != SMW_SQL2_SUBP2) ) { // no property hierarchy, but normal query (not for all properties)
443452 $query->where = "$query->alias.p_id=" . $this->m_dbs->addQuotes($pid);
444453 }
445454 }
446455 // $mode = SMWSQLStore2::getStorageMode($typeid);
447456 $sortfield = ''; // used if we should sort by this property
448457 switch ($mode) {
449 - case SMW_SQL2_RELS2: case SMW_SQL2_SUBS2: // subconditions as subqueries (compiled)
 458+ case SMW_SQL2_RELS2: case SMW_SQL2_SUBS2: case SMW_SQL2_SUBP2: // subconditions as subqueries (compiled)
450459 if ($isinverse) { $s='o'; $o='s'; } else { $s='s'; $o='o'; }
451460 $query->joinfield = "$query->alias.$s" . "_id";
452 - $query->jointable = ($mode==SMW_SQL2_RELS2)?'smw_rels2':'smw_subs2';
 461+ $query->jointable = ($mode==SMW_SQL2_RELS2)?'smw_rels2':
 462+ ( ($mode==SMW_SQL2_SUBS2)?'smw_subs2':'smw_subp2' );
453463 $sub = $this->compileQueries($valuedesc);
454464 if ($sub >= 0) {
455465 $query->components[$sub] = "$query->alias.$o" . "_id";
@@ -712,9 +722,9 @@
713723 $values .= ($values?',':'') . '(' . $this->m_dbs->addQuotes($value) . ')';
714724 $valuecond .= ($valuecond?' OR ':'') . 'o_id=' . $this->m_dbs->addQuotes($value);
715725 }
716 - $smw_subs2 = $this->m_dbs->tableName('smw_subs2');
 726+ $smwtable = $this->m_dbs->tableName(($query->type == SMW_SQL2_PROP_HIERARCHY)?'smw_subp2':'smw_subs2');
717727 // try to safe time (SELECT is cheaper than creating/dropping 3 temp tables):
718 - $res = $this->m_dbs->select($smw_subs2,'s_id',$valuecond, array('LIMIT'=>1));
 728+ $res = $this->m_dbs->select($smwtable,'s_id',$valuecond, array('LIMIT'=>1));
719729 if (!$this->m_dbs->fetchObject($res)) { // no subobjects, we are done!
720730 $this->m_dbs->freeResult($res);
721731 $query->type = SMW_SQL2_VALUE;
@@ -752,7 +762,7 @@
753763 $this->m_dbs->query("INSERT " . (($wgDBtype=='postgres')?"":"IGNORE") . " INTO $tmpnew (id) VALUES $values", 'SMW::executeHierarchyQuery');
754764
755765 for ($i=0; $i<$depth; $i++) {
756 - $this->m_dbs->query("INSERT " . (($wgDBtype=='postgres')?'':'IGNORE ') . "INTO $tmpres (id) SELECT s_id" . ($wgDBtype=='postgres'?'::integer':'') . " FROM $smw_subs2, $tmpnew WHERE o_id=id",
 766+ $this->m_dbs->query("INSERT " . (($wgDBtype=='postgres')?'':'IGNORE ') . "INTO $tmpres (id) SELECT s_id" . ($wgDBtype=='postgres'?'::integer':'') . " FROM $smwtable, $tmpnew WHERE o_id=id",
757767 'SMW::executeHierarchyQuery');
758768 if ($this->m_dbs->affectedRows() == 0) { // no change, exit loop
759769 break;
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -22,9 +22,10 @@
2323 define('SMW_SQL2_SPEC2',8);
2424 define('SMW_SQL2_REDI2',16);
2525 define('SMW_SQL2_NARY2',32); // not really a table, but a retrieval type
26 -define('SMW_SQL2_SUBS2',64);
 26+define('SMW_SQL2_SUBS2',64); // subcategory table (formerly subcategories+subproperties)
2727 define('SMW_SQL2_INST2',128);
2828 define('SMW_SQL2_CONC2',256);
 29+define('SMW_SQL2_SUBP2',512); // subproperty table
2930
3031
3132 /**
@@ -74,7 +75,7 @@
7576 /// This array defines how various datatypes should be handled internally. This
7677 /// list usually agrees with the datatype constants given in SMWDataValueFactory,
7778 /// but need not be complete: the default storage method is SMW_SQL2_ATTS2.
78 - /// Note that some storage methods require datavalue objects ot support specific
 79+ /// Note that some storage methods require datavalue objects to support specific
7980 /// APIs, so arbitrary changes in this table may not work unless the according
8081 /// datavalue class in SMWDataValueFactory supports those.
8182 private static $storage_mode = array(
@@ -98,16 +99,16 @@
99100 '__con' => SMW_SQL2_CONC2, // Special concept page type
100101 '__sps' => SMW_SQL2_SPEC2, // Special string type
101102 '__spu' => SMW_SQL2_SPEC2, // Special uri type
102 - '__sup' => SMW_SQL2_SUBS2, // Special subproperty type
 103+ '__sup' => SMW_SQL2_SUBP2, // Special subproperty type
103104 '__suc' => SMW_SQL2_SUBS2, // Special subcategory type
104105 '__spf' => SMW_SQL2_SPEC2, // Special form type (for Semantic Forms)
105106 '__sin' => SMW_SQL2_INST2, // Special instance of type
106107 '__red' => SMW_SQL2_REDI2, // Special redirect type
107108 '__lin' => SMW_SQL2_SPEC2, // Special linear unit conversion type
108109 '__nry' => SMW_SQL2_NARY2, // Special multi-valued type
109 - '__err' => SMW_SQL2_NONE, // Special error type, actually this is not stored right now
 110+ '__err' => SMW_SQL2_NONE, // Special error type, actually this is not stored right now
110111 '__imp' => SMW_SQL2_SPEC2, // Special import vocabulary type
111 - '__pro' => SMW_SQL2_NONE, // Property page type; actually this should never be stored as a value (_wpp is used there)
 112+ '__pro' => SMW_SQL2_NONE, // Property page type; actually this should never be stored as a value (_wpp is used there)
112113 );
113114
114115 ///// Reading methods /////
@@ -140,11 +141,14 @@
141142 $tasks = $tasks | SMWSQLStore2::getStorageMode($value);
142143 }
143144 } else {
144 - $tasks = SMW_SQL2_RELS2 | SMW_SQL2_ATTS2 | SMW_SQL2_TEXT2| SMW_SQL2_SPEC2 | SMW_SQL2_NARY2 | SMW_SQL2_SUBS2 | SMW_SQL2_INST2 | SMW_SQL2_REDI2 | SMW_SQL2_CONC2;
 145+ $tasks = SMW_SQL2_RELS2 | SMW_SQL2_ATTS2 | SMW_SQL2_TEXT2| SMW_SQL2_SPEC2 | SMW_SQL2_NARY2 | SMW_SQL2_SUBS2 | SMW_SQL2_SUBP2 | SMW_SQL2_INST2 | SMW_SQL2_REDI2 | SMW_SQL2_CONC2;
145146 }
146 - if ( ($subject->getNamespace() != SMW_NS_PROPERTY) && ($subject->getNamespace() != NS_CATEGORY) ) {
 147+ if ($subject->getNamespace() != NS_CATEGORY) {
147148 $tasks = $tasks & ~SMW_SQL2_SUBS2;
148149 }
 150+ if ($subject->getNamespace() != SMW_NS_PROPERTY) {
 151+ $tasks = $tasks & ~SMW_SQL2_SUBP2;
 152+ }
149153 if ($subject->getNamespace() != SMW_NS_CONCEPT) {
150154 $tasks = $tasks & ~SMW_SQL2_CONC2;
151155 }
@@ -170,7 +174,7 @@
171175 }
172176
173177 // most types of data suggest rather similar code
174 - foreach (array(SMW_SQL2_RELS2, SMW_SQL2_ATTS2, SMW_SQL2_TEXT2, SMW_SQL2_INST2, SMW_SQL2_SUBS2, SMW_SQL2_SPEC2, SMW_SQL2_REDI2, SMW_SQL2_CONC2) as $task) {
 178+ foreach (array(SMW_SQL2_RELS2, SMW_SQL2_ATTS2, SMW_SQL2_TEXT2, SMW_SQL2_INST2, SMW_SQL2_SUBS2, SMW_SQL2_SUBP2, SMW_SQL2_SPEC2, SMW_SQL2_REDI2, SMW_SQL2_CONC2) as $task) {
175179 if ( !($tasks & $task) ) continue;
176180 wfProfileIn("SMWSQLStore2::getSemanticData-task$task (SMW)");
177181 $where = 'p_id=smw_id AND s_id=' . $db->addQuotes($sid);
@@ -197,9 +201,16 @@
198202 $from = array('smw_subs2','smw_ids');
199203 $select = 'smw_title as value';
200204 $where = 'o_id=smw_id AND s_id=' . $db->addQuotes($sid);
201 - $namespace = $subject->getNamespace();
202 - $specprop = ($namespace==NS_CATEGORY)?'_SUBC':'_SUBP';
 205+ $namespace = NS_CATEGORY;
 206+ $specprop = '_SUBC';
203207 break;
 208+ case SMW_SQL2_SUBP2:
 209+ $from = array('smw_subp2','smw_ids');
 210+ $select = 'smw_title as value';
 211+ $where = 'o_id=smw_id AND s_id=' . $db->addQuotes($sid);
 212+ $namespace = SMW_NS_PROPERTY;
 213+ $specprop = '_SUBP';
 214+ break;
204215 case SMW_SQL2_REDI2:
205216 $from = array('smw_redi2','smw_ids');
206217 $select = 'smw_title as title, smw_namespace as namespace';
@@ -244,7 +255,7 @@
245256 $propertyname = $proprow->smw_title;
246257 }
247258 $valuekeys = array($row->value);
248 - } elseif ( ($task == SMW_SQL2_SUBS2) || ($task == SMW_SQL2_INST2) ) {
 259+ } elseif ( ($task == SMW_SQL2_SUBS2) || ($task == SMW_SQL2_SUBP2) || ($task == SMW_SQL2_INST2) ) {
249260 $propertyname = $specprop;
250261 $valuekeys = array($row->value,$namespace,'','');
251262 } elseif ($task == SMW_SQL2_REDI2) {
@@ -512,11 +523,11 @@
513524 case SMW_SQL2_CONC2:
514525 $table = 'smw_conc2'; // ignore value condition in this case
515526 break;
516 - case SMW_SQL2_RELS2: case SMW_SQL2_INST2: case SMW_SQL2_SUBS2:
 527+ case SMW_SQL2_RELS2: case SMW_SQL2_INST2: case SMW_SQL2_SUBS2: case SMW_SQL2_SUBP2:
517528 if ($mode!=SMW_SQL2_RELS2) $sql = ''; // no property column here
518 - if ($mode==SMW_SQL2_SUBS2) { // this table is shared, filter the relevant case
519 - $sql = 'smw_namespace=' . (($typeid == '__sup')?$db->addQuotes(SMW_NS_PROPERTY):$db->addQuotes(NS_CATEGORY));
520 - }
 529+// if ($mode==SMW_SQL2_SUBS2) { // this table is shared, filter the relevant case
 530+// $sql = 'smw_namespace=' . (($typeid == '__sup')?$db->addQuotes(SMW_NS_PROPERTY):$db->addQuotes(NS_CATEGORY));
 531+// }
521532 if ($value !== NULL) {
522533 $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki());
523534 $sql .= ($sql?" AND ":'') . 'o_id=' . $db->addQuotes($oid);
@@ -526,6 +537,7 @@
527538 case SMW_SQL2_RELS2: $table = 'smw_rels2'; break;
528539 case SMW_SQL2_INST2: $table = 'smw_inst2'; break;
529540 case SMW_SQL2_SUBS2: $table = 'smw_subs2'; break;
 541+ case SMW_SQL2_SUBP2: $table = 'smw_subp2'; break;
530542 }
531543 }
532544 break;
@@ -714,6 +726,7 @@
715727 $up_rels2 = array(); $up_atts2 = array();
716728 $up_text2 = array(); $up_spec2 = array();
717729 $up_subs2 = array(); $up_inst2 = array();
 730+ $up_subp2 = array();
718731 $concept_desc = NULL; // this gets a special treatment
719732
720733 foreach($data->getProperties() as $property) {
@@ -733,6 +746,11 @@
734747 's_id' => $sid,
735748 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),''));
736749 break;
 750+ case SMW_SQL2_SUBP2:
 751+ $up_subp2[] = array(
 752+ 's_id' => $sid,
 753+ 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),''));
 754+ break;
737755 case SMW_SQL2_CONC2:
738756 $concept_desc = end($propertyValueArray); // only one value per page!
739757 break;
@@ -824,6 +842,9 @@
825843 if (count($up_subs2) > 0) {
826844 $db->insert( 'smw_subs2', $up_subs2, 'SMW::updateSubs2Data');
827845 }
 846+ if (count($up_subp2) > 0) {
 847+ $db->insert( 'smw_subp2', $up_subp2, 'SMW::updateSubp2Data');
 848+ }
828849 if (count($up_inst2) > 0) {
829850 $db->insert( 'smw_inst2', $up_inst2, 'SMW::updateInst2Data');
830851 }
@@ -914,9 +935,9 @@
915936 $db->update('smw_inst2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
916937 if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) &&
917938 ( $newtitle->getNamespace() == SMW_NS_PROPERTY ) ) {
918 - $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
 939+ $db->update('smw_subp2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
919940 } elseif ($oldtitle->getNamespace() == SMW_NS_PROPERTY) {
920 - $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle');
 941+ $db->delete('smw_subp2', $cond_array, 'SMWSQLStore2::changeTitle');
921942 } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) &&
922943 ( $newtitle->getNamespace() == NS_CATEGORY ) ) {
923944 $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle');
@@ -997,7 +1018,7 @@
9981019 if ($requestoptions->offset > 0) {
9991020 $options .= ' OFFSET ' . $requestoptions->offset;
10001021 }
1001 - extract( $db->tableNames('page', 'smw_rels2', 'smw_atts2', 'smw_text2', 'smw_subs2', 'smw_ids', 'smw_tmp_unusedprops', 'smw_redi2') );
 1022+ extract( $db->tableNames('page', 'smw_rels2', 'smw_atts2', 'smw_text2', 'smw_subp2', 'smw_ids', 'smw_tmp_unusedprops', 'smw_redi2') );
10021023
10031024 if ($wgDBtype=='postgres') { // PostgresQL: no in-memory tables available
10041025 $sql = "CREATE OR REPLACE FUNCTION create_" . $smw_tmp_unusedprops . "() RETURNS void AS "
@@ -1021,7 +1042,7 @@
10221043 foreach (array($smw_rels2,$smw_atts2,$smw_text2) as $table) {
10231044 $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops, $table INNER JOIN $smw_ids ON p_id=smw_id WHERE title=smw_title AND smw_iw=" . $db->addQuotes(''), 'SMW::getUnusedPropertySubjects');
10241045 }
1025 - $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops, $smw_subs2 INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title", 'SMW::getUnusedPropertySubjects');
 1046+ $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops, $smw_subp2 INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title", 'SMW::getUnusedPropertySubjects');
10261047 $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops, $smw_ids WHERE title=smw_title AND smw_namespace=" . $db->addQuotes(SMW_NS_PROPERTY) . ' AND smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW), 'SMW::getUnusedPropertySubjects');
10271048 // assume any property redirecting to some property to be used here:
10281049 // (a stricter and more costy approach would be to delete only redirects to active properties;
@@ -1112,7 +1133,7 @@
11131134 $db =& wfGetDB( DB_MASTER );
11141135 extract( $db->tableNames('smw_ids','smw_rels2','smw_atts2','smw_text2',
11151136 'smw_spec2','smw_subs2','smw_redi2','smw_inst2',
1116 - 'smw_conc2','smw_conccache') );
 1137+ 'smw_subp2','smw_conc2','smw_conccache') );
11171138 $reportTo = $verbose?$this:NULL; // use $this to report back from static SMWSQLHelpers
11181139 // repeatedly used DB field types defined here for convenience
11191140 $dbt_id = SMWSQLHelpers::getStandardDBType('id');
@@ -1185,11 +1206,16 @@
11861207 'value_string' => $dbt_title . ' NOT NULL'), $db, $reportTo);
11871208 SMWSQLHelpers::setupIndex($smw_spec2, array('s_id', 'p_id', 's_id,p_id'), $db);
11881209
1189 - SMWSQLHelpers::setupTable($smw_subs2, // subproperty/subclass relationships
 1210+ SMWSQLHelpers::setupTable($smw_subs2, // subclass relationships
11901211 array('s_id' => $dbt_id . ' NOT NULL',
11911212 'o_id' => $dbt_id . ' NOT NULL'), $db, $reportTo);
11921213 SMWSQLHelpers::setupIndex($smw_subs2, array('s_id', 'o_id'), $db);
11931214
 1215+ SMWSQLHelpers::setupTable($smw_subp2, // subproperty relationships
 1216+ array('s_id' => $dbt_id . ' NOT NULL',
 1217+ 'o_id' => $dbt_id . ' NOT NULL'), $db, $reportTo);
 1218+ SMWSQLHelpers::setupIndex($smw_subp2, array('s_id', 'o_id'), $db);
 1219+
11941220 SMWSQLHelpers::setupTable($smw_inst2, // class instances (s_id the element, o_id the class)
11951221 array('s_id' => $dbt_id . ' NOT NULL',
11961222 'o_id' => $dbt_id . ' NOT NULL',), $db, $reportTo);
@@ -1271,7 +1297,7 @@
12721298 $db =& wfGetDB( DB_MASTER );
12731299 $tables = array('smw_rels2', 'smw_atts2', 'smw_text2', 'smw_spec2',
12741300 'smw_subs2', 'smw_redi2', 'smw_ids', 'smw_inst2',
1275 - 'smw_conc2', 'smw_conccache');
 1301+ 'smw_subp2', 'smw_conc2', 'smw_conccache');
12761302 foreach ($tables as $table) {
12771303 $name = $db->tableName($table);
12781304 $db->query('DROP TABLE' . ($wgDBtype=='postgres'?'':' IF EXISTS'). $name, 'SMWSQLStore2::drop');
@@ -1877,6 +1903,7 @@
18781904 $db->update('smw_text2', $val_array, $cond_array, 'SMW::moveID');
18791905 $db->update('smw_spec2', $val_array, $cond_array, 'SMW::moveID');
18801906 $db->update('smw_subs2', $val_array, $cond_array, 'SMW::moveID');
 1907+ $db->update('smw_subp2', $val_array, $cond_array, 'SMW::moveID');
18811908 $db->update('smw_inst2', $val_array, $cond_array, 'SMW::moveID');
18821909 if ($row->smw_namespace == SMW_NS_CONCEPT) {
18831910 $db->update('smw_conc2', $val_array, $cond_array, 'SMW::moveID');
@@ -1895,6 +1922,7 @@
18961923 $db->update('smw_redi2', $val_array, $cond_array, 'SMW::moveID');
18971924 $db->update('smw_rels2', $val_array, $cond_array, 'SMW::moveID');
18981925 $db->update('smw_subs2', $val_array, $cond_array, 'SMW::moveID');
 1926+ $db->update('smw_subp2', $val_array, $cond_array, 'SMW::moveID');
18991927 $db->update('smw_inst2', $val_array, $cond_array, 'SMW::moveID');
19001928 $db->update('smw_conccache', $val_array, $cond_array, 'SMW::moveID');
19011929 }
@@ -1914,8 +1942,10 @@
19151943 $db->delete('smw_text2', array('s_id' => $id), 'SMW::deleteSubject::Text2');
19161944 $db->delete('smw_spec2', array('s_id' => $id), 'SMW::deleteSubject::Spec2');
19171945 $db->delete('smw_inst2', array('s_id' => $id), 'SMW::deleteSubject::Inst2');
1918 - if ( ($subject->getNamespace() == SMW_NS_PROPERTY) || ($subject->getNamespace() == NS_CATEGORY) ) {
 1946+ if ($subject->getNamespace() == NS_CATEGORY) {
19191947 $db->delete('smw_subs2', array('s_id' => $id), 'SMW::deleteSubject::Subs2');
 1948+ } elseif ($subject->getNamespace() == SMW_NS_PROPERTY) {
 1949+ $db->delete('smw_subp2', array('s_id' => $id), 'SMW::deleteSubject::Subp2');
19201950 }
19211951
19221952 // find bnodes used by this ID ...
@@ -1977,12 +2007,12 @@
19782008 $db->update('smw_rels2', $val_array, $cond_array, 'SMW::updateRedirects');
19792009 $db->update('smw_atts2', $val_array, $cond_array, 'SMW::updateRedirects');
19802010 $db->update('smw_text2', $val_array, $cond_array, 'SMW::updateRedirects');
1981 - $db->update('smw_subs2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects');
 2011+ $db->update('smw_subp2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects');
19822012 } elseif ($subject_ns == SMW_NS_PROPERTY) { // delete triples that are only allowed for properties
19832013 $db->delete('smw_rels2', array( 'p_id' => $sid ), 'SMW::updateRedirects');
19842014 $db->delete('smw_atts2', array( 'p_id' => $sid ), 'SMW::updateRedirects');
19852015 $db->delete('smw_text2', array( 'p_id' => $sid ), 'SMW::updateRedirects');
1986 - $db->delete('smw_subs2', array( 'o_id' => $sid ), 'SMW::updateRedirects');
 2016+ $db->delete('smw_subp2', array( 'o_id' => $sid ), 'SMW::updateRedirects');
19872017 } elseif ( ( $subject_ns == NS_CATEGORY ) && ( $curtarget_ns == NS_CATEGORY ) ) {
19882018 $db->update('smw_subs2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects');
19892019 $db->update('smw_inst2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects');
@@ -2017,7 +2047,7 @@
20182048 $jobs[] = new SMWUpdateJob($t);
20192049 }
20202050 }
2021 - $res = $db->select( array('smw_subs2','smw_ids'),'DISTINCT smw_title,smw_namespace',
 2051+ $res = $db->select( array('smw_subp2','smw_ids'),'DISTINCT smw_title,smw_namespace',
20222052 's_id=smw_id AND o_id=' . $db->addQuotes($old_tid),
20232053 'SMW::updateRedirects');
20242054 while ($row = $db->fetchObject($res)) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -103,6 +103,8 @@
104104
105105 /**
106106 * Return true if there are any visible properties.
 107+ * @note While called "visible" this check actually refers to the function
 108+ * SMWPropertyValue::isShown(). The name is kept for compatibility.
107109 */
108110 public function hasVisibleProperties() {
109111 $this->unstubProperties();
@@ -112,6 +114,8 @@
113115 /**
114116 * Return true if there are any special properties that can
115117 * be displayed.
 118+ * @note While called "visible" this check actually refers to the function
 119+ * SMWPropertyValue::isShown(). The name is kept for compatibility.
116120 */
117121 public function hasVisibleSpecialProperties() {
118122 $this->unstubProperties();
@@ -137,7 +141,7 @@
138142 $this->propvals[$property->getDBkey()][] = $value;
139143 }
140144 if (!$property->isUserDefined()) {
141 - if ($property->isVisible()) {
 145+ if ($property->isShown()) {
142146 $this->hasvisiblespecs = true;
143147 $this->hasvisibleprops = true;
144148 }
@@ -214,7 +218,7 @@
215219 }
216220 $this->properties[$pname] = $propertyobj;
217221 if (!$propertyobj->isUserDefined()) {
218 - if ($propertyobj->isVisible()) {
 222+ if ($propertyobj->isShown()) {
219223 $this->hasvisiblespecs = true;
220224 $this->hasvisibleprops = true;
221225 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php
@@ -371,7 +371,7 @@
372372 return; //init happened before
373373 }
374374
375 - global $smwgContLang;
 375+ global $smwgContLang,$smwgUseCategoryHierarchy;
376376 SMWPropertyValue::$m_propertylabels = $smwgContLang->getPropertyLabels();
377377 SMWPropertyValue::$m_propertyaliases = $smwgContLang->getPropertyAliases();
378378 // Setup built-in predefined properties.
@@ -389,7 +389,7 @@
390390 '_PVAL' => array('__sps',true),
391391 '_REDI' => array('__red',true),
392392 '_SUBP' => array('__sup',true),
393 - '_SUBC' => array('__suc',false),
 393+ '_SUBC' => array('__suc',!$smwgUseCategoryHierarchy),
394394 '_CONC' => array('__con',false),
395395 '_MDAT' => array('_dat',false),
396396 '_ERRP' => array('_wpp',false),

Status & tagging log