Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php |
— | — | @@ -244,14 +244,17 @@ |
245 | 245 | * so that they are also replicated in SMW for more efficient querying. |
246 | 246 | */ |
247 | 247 | static public function onParserAfterTidy(&$parser, &$text) { |
| 248 | + global $smwgUseCategoryHierarchy,$smwgCategoriesAsInstances; |
248 | 249 | if (SMWParseData::getSMWData($parser) === NULL) return true; |
249 | 250 | $categories = $parser->mOutput->getCategoryLinks(); |
250 | 251 | 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) ) { |
256 | 259 | $psubc = SMWPropertyValue::makeProperty('_SUBC'); |
257 | 260 | $dv = SMWDataValueFactory::newPropertyObjectValue($psubc); |
258 | 261 | $dv->setValues($name,NS_CATEGORY); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php |
— | — | @@ -298,12 +298,12 @@ |
299 | 299 | array_shift( $params ); // we already know the $parser ... |
300 | 300 | foreach ($params as $p) |
301 | 301 | if (trim($p) != "") { |
302 | | - $parts = explode("=", trim($p)); |
| 302 | + $parts = explode("=", trim($p), 2); |
303 | 303 | if (count($parts)==2) { |
304 | 304 | $property = $parts[0]; |
305 | 305 | $object = $parts[1]; |
306 | 306 | SMWParseData::addProperty( $property, $object, false, $parser, true ); |
307 | | - } |
| 307 | + } // else: no "=" given, ignore |
308 | 308 | } |
309 | 309 | SMWOutputs::commitToParser($parser); // not obviously required, but let us be sure |
310 | 310 | return ''; |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -144,7 +144,12 @@ |
145 | 145 | * The new SQL store's implementation of query answering. |
146 | 146 | */ |
147 | 147 | 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 |
149 | 154 | $result = new SMWQueryResult($query->getDescription()->getPrintrequests(), $query, array(), $this->m_store, true); |
150 | 155 | return $result; |
151 | 156 | } |
— | — | @@ -156,11 +161,6 @@ |
157 | 162 | $this->m_distance = $query->getDistance(); |
158 | 163 | SMWSQLStore2Query::$qnum = 0; |
159 | 164 | $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"; |
165 | 165 | // build query dependency tree: |
166 | 166 | wfProfileIn('SMWSQLStore2Queries::compileMainQuery (SMW)'); |
167 | 167 | $qid = $this->compileQueries($query->getDescription()); // compile query, build query "plan" |
— | — | @@ -174,9 +174,18 @@ |
175 | 175 | $this->m_queries[$qid] = $q; |
176 | 176 | } |
177 | 177 | // 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 | + } |
181 | 190 | |
182 | 191 | $this->applyOrderConditions($query,$rootid); // may extend query if needed for sorting |
183 | 192 | wfProfileIn('SMWSQLStore2Queries::executeMainQuery (SMW)'); |
— | — | @@ -426,7 +435,7 @@ |
427 | 436 | $isinverse = $property->isInverse(); |
428 | 437 | $pid = $this->m_store->getSMWPropertyID($property); |
429 | 438 | $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) |
431 | 440 | $pqid = SMWSQLStore2Query::$qnum; |
432 | 441 | $pquery = new SMWSQLStore2Query(); |
433 | 442 | $pquery->type = SMW_SQL2_PROP_HIERARCHY; |
— | — | @@ -438,17 +447,18 @@ |
439 | 448 | $pid = $property; |
440 | 449 | $sortkey = false; |
441 | 450 | $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) |
443 | 452 | $query->where = "$query->alias.p_id=" . $this->m_dbs->addQuotes($pid); |
444 | 453 | } |
445 | 454 | } |
446 | 455 | // $mode = SMWSQLStore2::getStorageMode($typeid); |
447 | 456 | $sortfield = ''; // used if we should sort by this property |
448 | 457 | 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) |
450 | 459 | if ($isinverse) { $s='o'; $o='s'; } else { $s='s'; $o='o'; } |
451 | 460 | $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' ); |
453 | 463 | $sub = $this->compileQueries($valuedesc); |
454 | 464 | if ($sub >= 0) { |
455 | 465 | $query->components[$sub] = "$query->alias.$o" . "_id"; |
— | — | @@ -712,9 +722,9 @@ |
713 | 723 | $values .= ($values?',':'') . '(' . $this->m_dbs->addQuotes($value) . ')'; |
714 | 724 | $valuecond .= ($valuecond?' OR ':'') . 'o_id=' . $this->m_dbs->addQuotes($value); |
715 | 725 | } |
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'); |
717 | 727 | // 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)); |
719 | 729 | if (!$this->m_dbs->fetchObject($res)) { // no subobjects, we are done! |
720 | 730 | $this->m_dbs->freeResult($res); |
721 | 731 | $query->type = SMW_SQL2_VALUE; |
— | — | @@ -752,7 +762,7 @@ |
753 | 763 | $this->m_dbs->query("INSERT " . (($wgDBtype=='postgres')?"":"IGNORE") . " INTO $tmpnew (id) VALUES $values", 'SMW::executeHierarchyQuery'); |
754 | 764 | |
755 | 765 | 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", |
757 | 767 | 'SMW::executeHierarchyQuery'); |
758 | 768 | if ($this->m_dbs->affectedRows() == 0) { // no change, exit loop |
759 | 769 | break; |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -22,9 +22,10 @@ |
23 | 23 | define('SMW_SQL2_SPEC2',8); |
24 | 24 | define('SMW_SQL2_REDI2',16); |
25 | 25 | 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) |
27 | 27 | define('SMW_SQL2_INST2',128); |
28 | 28 | define('SMW_SQL2_CONC2',256); |
| 29 | +define('SMW_SQL2_SUBP2',512); // subproperty table |
29 | 30 | |
30 | 31 | |
31 | 32 | /** |
— | — | @@ -74,7 +75,7 @@ |
75 | 76 | /// This array defines how various datatypes should be handled internally. This |
76 | 77 | /// list usually agrees with the datatype constants given in SMWDataValueFactory, |
77 | 78 | /// 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 |
79 | 80 | /// APIs, so arbitrary changes in this table may not work unless the according |
80 | 81 | /// datavalue class in SMWDataValueFactory supports those. |
81 | 82 | private static $storage_mode = array( |
— | — | @@ -98,16 +99,16 @@ |
99 | 100 | '__con' => SMW_SQL2_CONC2, // Special concept page type |
100 | 101 | '__sps' => SMW_SQL2_SPEC2, // Special string type |
101 | 102 | '__spu' => SMW_SQL2_SPEC2, // Special uri type |
102 | | - '__sup' => SMW_SQL2_SUBS2, // Special subproperty type |
| 103 | + '__sup' => SMW_SQL2_SUBP2, // Special subproperty type |
103 | 104 | '__suc' => SMW_SQL2_SUBS2, // Special subcategory type |
104 | 105 | '__spf' => SMW_SQL2_SPEC2, // Special form type (for Semantic Forms) |
105 | 106 | '__sin' => SMW_SQL2_INST2, // Special instance of type |
106 | 107 | '__red' => SMW_SQL2_REDI2, // Special redirect type |
107 | 108 | '__lin' => SMW_SQL2_SPEC2, // Special linear unit conversion type |
108 | 109 | '__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 |
110 | 111 | '__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) |
112 | 113 | ); |
113 | 114 | |
114 | 115 | ///// Reading methods ///// |
— | — | @@ -140,11 +141,14 @@ |
141 | 142 | $tasks = $tasks | SMWSQLStore2::getStorageMode($value); |
142 | 143 | } |
143 | 144 | } 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; |
145 | 146 | } |
146 | | - if ( ($subject->getNamespace() != SMW_NS_PROPERTY) && ($subject->getNamespace() != NS_CATEGORY) ) { |
| 147 | + if ($subject->getNamespace() != NS_CATEGORY) { |
147 | 148 | $tasks = $tasks & ~SMW_SQL2_SUBS2; |
148 | 149 | } |
| 150 | + if ($subject->getNamespace() != SMW_NS_PROPERTY) { |
| 151 | + $tasks = $tasks & ~SMW_SQL2_SUBP2; |
| 152 | + } |
149 | 153 | if ($subject->getNamespace() != SMW_NS_CONCEPT) { |
150 | 154 | $tasks = $tasks & ~SMW_SQL2_CONC2; |
151 | 155 | } |
— | — | @@ -170,7 +174,7 @@ |
171 | 175 | } |
172 | 176 | |
173 | 177 | // 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) { |
175 | 179 | if ( !($tasks & $task) ) continue; |
176 | 180 | wfProfileIn("SMWSQLStore2::getSemanticData-task$task (SMW)"); |
177 | 181 | $where = 'p_id=smw_id AND s_id=' . $db->addQuotes($sid); |
— | — | @@ -197,9 +201,16 @@ |
198 | 202 | $from = array('smw_subs2','smw_ids'); |
199 | 203 | $select = 'smw_title as value'; |
200 | 204 | $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'; |
203 | 207 | 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; |
204 | 215 | case SMW_SQL2_REDI2: |
205 | 216 | $from = array('smw_redi2','smw_ids'); |
206 | 217 | $select = 'smw_title as title, smw_namespace as namespace'; |
— | — | @@ -244,7 +255,7 @@ |
245 | 256 | $propertyname = $proprow->smw_title; |
246 | 257 | } |
247 | 258 | $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) ) { |
249 | 260 | $propertyname = $specprop; |
250 | 261 | $valuekeys = array($row->value,$namespace,'',''); |
251 | 262 | } elseif ($task == SMW_SQL2_REDI2) { |
— | — | @@ -512,11 +523,11 @@ |
513 | 524 | case SMW_SQL2_CONC2: |
514 | 525 | $table = 'smw_conc2'; // ignore value condition in this case |
515 | 526 | 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: |
517 | 528 | 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 | +// } |
521 | 532 | if ($value !== NULL) { |
522 | 533 | $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki()); |
523 | 534 | $sql .= ($sql?" AND ":'') . 'o_id=' . $db->addQuotes($oid); |
— | — | @@ -526,6 +537,7 @@ |
527 | 538 | case SMW_SQL2_RELS2: $table = 'smw_rels2'; break; |
528 | 539 | case SMW_SQL2_INST2: $table = 'smw_inst2'; break; |
529 | 540 | case SMW_SQL2_SUBS2: $table = 'smw_subs2'; break; |
| 541 | + case SMW_SQL2_SUBP2: $table = 'smw_subp2'; break; |
530 | 542 | } |
531 | 543 | } |
532 | 544 | break; |
— | — | @@ -714,6 +726,7 @@ |
715 | 727 | $up_rels2 = array(); $up_atts2 = array(); |
716 | 728 | $up_text2 = array(); $up_spec2 = array(); |
717 | 729 | $up_subs2 = array(); $up_inst2 = array(); |
| 730 | + $up_subp2 = array(); |
718 | 731 | $concept_desc = NULL; // this gets a special treatment |
719 | 732 | |
720 | 733 | foreach($data->getProperties() as $property) { |
— | — | @@ -733,6 +746,11 @@ |
734 | 747 | 's_id' => $sid, |
735 | 748 | 'o_id' => $this->makeSMWPageID($value->getDBkey(),$value->getNamespace(),'')); |
736 | 749 | 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; |
737 | 755 | case SMW_SQL2_CONC2: |
738 | 756 | $concept_desc = end($propertyValueArray); // only one value per page! |
739 | 757 | break; |
— | — | @@ -824,6 +842,9 @@ |
825 | 843 | if (count($up_subs2) > 0) { |
826 | 844 | $db->insert( 'smw_subs2', $up_subs2, 'SMW::updateSubs2Data'); |
827 | 845 | } |
| 846 | + if (count($up_subp2) > 0) { |
| 847 | + $db->insert( 'smw_subp2', $up_subp2, 'SMW::updateSubp2Data'); |
| 848 | + } |
828 | 849 | if (count($up_inst2) > 0) { |
829 | 850 | $db->insert( 'smw_inst2', $up_inst2, 'SMW::updateInst2Data'); |
830 | 851 | } |
— | — | @@ -914,9 +935,9 @@ |
915 | 936 | $db->update('smw_inst2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
916 | 937 | if ( ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) && |
917 | 938 | ( $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'); |
919 | 940 | } elseif ($oldtitle->getNamespace() == SMW_NS_PROPERTY) { |
920 | | - $db->delete('smw_subs2', $cond_array, 'SMWSQLStore2::changeTitle'); |
| 941 | + $db->delete('smw_subp2', $cond_array, 'SMWSQLStore2::changeTitle'); |
921 | 942 | } elseif ( ( $oldtitle->getNamespace() == NS_CATEGORY ) && |
922 | 943 | ( $newtitle->getNamespace() == NS_CATEGORY ) ) { |
923 | 944 | $db->update('smw_subs2', $val_array, $cond_array, 'SMWSQLStore2::changeTitle'); |
— | — | @@ -997,7 +1018,7 @@ |
998 | 1019 | if ($requestoptions->offset > 0) { |
999 | 1020 | $options .= ' OFFSET ' . $requestoptions->offset; |
1000 | 1021 | } |
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') ); |
1002 | 1023 | |
1003 | 1024 | if ($wgDBtype=='postgres') { // PostgresQL: no in-memory tables available |
1004 | 1025 | $sql = "CREATE OR REPLACE FUNCTION create_" . $smw_tmp_unusedprops . "() RETURNS void AS " |
— | — | @@ -1021,7 +1042,7 @@ |
1022 | 1043 | foreach (array($smw_rels2,$smw_atts2,$smw_text2) as $table) { |
1023 | 1044 | $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'); |
1024 | 1045 | } |
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'); |
1026 | 1047 | $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'); |
1027 | 1048 | // assume any property redirecting to some property to be used here: |
1028 | 1049 | // (a stricter and more costy approach would be to delete only redirects to active properties; |
— | — | @@ -1112,7 +1133,7 @@ |
1113 | 1134 | $db =& wfGetDB( DB_MASTER ); |
1114 | 1135 | extract( $db->tableNames('smw_ids','smw_rels2','smw_atts2','smw_text2', |
1115 | 1136 | 'smw_spec2','smw_subs2','smw_redi2','smw_inst2', |
1116 | | - 'smw_conc2','smw_conccache') ); |
| 1137 | + 'smw_subp2','smw_conc2','smw_conccache') ); |
1117 | 1138 | $reportTo = $verbose?$this:NULL; // use $this to report back from static SMWSQLHelpers |
1118 | 1139 | // repeatedly used DB field types defined here for convenience |
1119 | 1140 | $dbt_id = SMWSQLHelpers::getStandardDBType('id'); |
— | — | @@ -1185,11 +1206,16 @@ |
1186 | 1207 | 'value_string' => $dbt_title . ' NOT NULL'), $db, $reportTo); |
1187 | 1208 | SMWSQLHelpers::setupIndex($smw_spec2, array('s_id', 'p_id', 's_id,p_id'), $db); |
1188 | 1209 | |
1189 | | - SMWSQLHelpers::setupTable($smw_subs2, // subproperty/subclass relationships |
| 1210 | + SMWSQLHelpers::setupTable($smw_subs2, // subclass relationships |
1190 | 1211 | array('s_id' => $dbt_id . ' NOT NULL', |
1191 | 1212 | 'o_id' => $dbt_id . ' NOT NULL'), $db, $reportTo); |
1192 | 1213 | SMWSQLHelpers::setupIndex($smw_subs2, array('s_id', 'o_id'), $db); |
1193 | 1214 | |
| 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 | + |
1194 | 1220 | SMWSQLHelpers::setupTable($smw_inst2, // class instances (s_id the element, o_id the class) |
1195 | 1221 | array('s_id' => $dbt_id . ' NOT NULL', |
1196 | 1222 | 'o_id' => $dbt_id . ' NOT NULL',), $db, $reportTo); |
— | — | @@ -1271,7 +1297,7 @@ |
1272 | 1298 | $db =& wfGetDB( DB_MASTER ); |
1273 | 1299 | $tables = array('smw_rels2', 'smw_atts2', 'smw_text2', 'smw_spec2', |
1274 | 1300 | 'smw_subs2', 'smw_redi2', 'smw_ids', 'smw_inst2', |
1275 | | - 'smw_conc2', 'smw_conccache'); |
| 1301 | + 'smw_subp2', 'smw_conc2', 'smw_conccache'); |
1276 | 1302 | foreach ($tables as $table) { |
1277 | 1303 | $name = $db->tableName($table); |
1278 | 1304 | $db->query('DROP TABLE' . ($wgDBtype=='postgres'?'':' IF EXISTS'). $name, 'SMWSQLStore2::drop'); |
— | — | @@ -1877,6 +1903,7 @@ |
1878 | 1904 | $db->update('smw_text2', $val_array, $cond_array, 'SMW::moveID'); |
1879 | 1905 | $db->update('smw_spec2', $val_array, $cond_array, 'SMW::moveID'); |
1880 | 1906 | $db->update('smw_subs2', $val_array, $cond_array, 'SMW::moveID'); |
| 1907 | + $db->update('smw_subp2', $val_array, $cond_array, 'SMW::moveID'); |
1881 | 1908 | $db->update('smw_inst2', $val_array, $cond_array, 'SMW::moveID'); |
1882 | 1909 | if ($row->smw_namespace == SMW_NS_CONCEPT) { |
1883 | 1910 | $db->update('smw_conc2', $val_array, $cond_array, 'SMW::moveID'); |
— | — | @@ -1895,6 +1922,7 @@ |
1896 | 1923 | $db->update('smw_redi2', $val_array, $cond_array, 'SMW::moveID'); |
1897 | 1924 | $db->update('smw_rels2', $val_array, $cond_array, 'SMW::moveID'); |
1898 | 1925 | $db->update('smw_subs2', $val_array, $cond_array, 'SMW::moveID'); |
| 1926 | + $db->update('smw_subp2', $val_array, $cond_array, 'SMW::moveID'); |
1899 | 1927 | $db->update('smw_inst2', $val_array, $cond_array, 'SMW::moveID'); |
1900 | 1928 | $db->update('smw_conccache', $val_array, $cond_array, 'SMW::moveID'); |
1901 | 1929 | } |
— | — | @@ -1914,8 +1942,10 @@ |
1915 | 1943 | $db->delete('smw_text2', array('s_id' => $id), 'SMW::deleteSubject::Text2'); |
1916 | 1944 | $db->delete('smw_spec2', array('s_id' => $id), 'SMW::deleteSubject::Spec2'); |
1917 | 1945 | $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) { |
1919 | 1947 | $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'); |
1920 | 1950 | } |
1921 | 1951 | |
1922 | 1952 | // find bnodes used by this ID ... |
— | — | @@ -1977,12 +2007,12 @@ |
1978 | 2008 | $db->update('smw_rels2', $val_array, $cond_array, 'SMW::updateRedirects'); |
1979 | 2009 | $db->update('smw_atts2', $val_array, $cond_array, 'SMW::updateRedirects'); |
1980 | 2010 | $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'); |
1982 | 2012 | } elseif ($subject_ns == SMW_NS_PROPERTY) { // delete triples that are only allowed for properties |
1983 | 2013 | $db->delete('smw_rels2', array( 'p_id' => $sid ), 'SMW::updateRedirects'); |
1984 | 2014 | $db->delete('smw_atts2', array( 'p_id' => $sid ), 'SMW::updateRedirects'); |
1985 | 2015 | $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'); |
1987 | 2017 | } elseif ( ( $subject_ns == NS_CATEGORY ) && ( $curtarget_ns == NS_CATEGORY ) ) { |
1988 | 2018 | $db->update('smw_subs2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects'); |
1989 | 2019 | $db->update('smw_inst2', array( 'o_id' => $new_tid ), array( 'o_id' => $sid ), 'SMW::updateRedirects'); |
— | — | @@ -2017,7 +2047,7 @@ |
2018 | 2048 | $jobs[] = new SMWUpdateJob($t); |
2019 | 2049 | } |
2020 | 2050 | } |
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', |
2022 | 2052 | 's_id=smw_id AND o_id=' . $db->addQuotes($old_tid), |
2023 | 2053 | 'SMW::updateRedirects'); |
2024 | 2054 | while ($row = $db->fetchObject($res)) { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php |
— | — | @@ -103,6 +103,8 @@ |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * 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. |
107 | 109 | */ |
108 | 110 | public function hasVisibleProperties() { |
109 | 111 | $this->unstubProperties(); |
— | — | @@ -112,6 +114,8 @@ |
113 | 115 | /** |
114 | 116 | * Return true if there are any special properties that can |
115 | 117 | * be displayed. |
| 118 | + * @note While called "visible" this check actually refers to the function |
| 119 | + * SMWPropertyValue::isShown(). The name is kept for compatibility. |
116 | 120 | */ |
117 | 121 | public function hasVisibleSpecialProperties() { |
118 | 122 | $this->unstubProperties(); |
— | — | @@ -137,7 +141,7 @@ |
138 | 142 | $this->propvals[$property->getDBkey()][] = $value; |
139 | 143 | } |
140 | 144 | if (!$property->isUserDefined()) { |
141 | | - if ($property->isVisible()) { |
| 145 | + if ($property->isShown()) { |
142 | 146 | $this->hasvisiblespecs = true; |
143 | 147 | $this->hasvisibleprops = true; |
144 | 148 | } |
— | — | @@ -214,7 +218,7 @@ |
215 | 219 | } |
216 | 220 | $this->properties[$pname] = $propertyobj; |
217 | 221 | if (!$propertyobj->isUserDefined()) { |
218 | | - if ($propertyobj->isVisible()) { |
| 222 | + if ($propertyobj->isShown()) { |
219 | 223 | $this->hasvisiblespecs = true; |
220 | 224 | $this->hasvisibleprops = true; |
221 | 225 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Property.php |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | return; //init happened before |
373 | 373 | } |
374 | 374 | |
375 | | - global $smwgContLang; |
| 375 | + global $smwgContLang,$smwgUseCategoryHierarchy; |
376 | 376 | SMWPropertyValue::$m_propertylabels = $smwgContLang->getPropertyLabels(); |
377 | 377 | SMWPropertyValue::$m_propertyaliases = $smwgContLang->getPropertyAliases(); |
378 | 378 | // Setup built-in predefined properties. |
— | — | @@ -389,7 +389,7 @@ |
390 | 390 | '_PVAL' => array('__sps',true), |
391 | 391 | '_REDI' => array('__red',true), |
392 | 392 | '_SUBP' => array('__sup',true), |
393 | | - '_SUBC' => array('__suc',false), |
| 393 | + '_SUBC' => array('__suc',!$smwgUseCategoryHierarchy), |
394 | 394 | '_CONC' => array('__con',false), |
395 | 395 | '_MDAT' => array('_dat',false), |
396 | 396 | '_ERRP' => array('_wpp',false), |