r25830 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25829‎ | r25830 | r25831 >
Date:16:44, 13 September 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Bugfix: do not delete object references when updating semantic data for some page
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -504,40 +504,10 @@
505505
506506 function deleteSubject(Title $subject) {
507507 wfProfileIn("SMWSQLStore::deleteSubjects (SMW)");
 508+ $this->deleteSemanticData($subject);
508509 $db =& wfGetDB( DB_MASTER );
509 - $db->delete('smw_relations',
510 - array('subject_id' => $subject->getArticleID()),
511 - 'SMW::deleteSubject::Relations');
 510+ // also delete any occurence of subject in object positions:
512511 $db->update('smw_relations', array('object_id' => NULL), array('object_id' => $subject->getArticleID()), 'SMW::deleteSubject::RelationObj');
513 - $db->delete('smw_attributes',
514 - array('subject_id' => $subject->getArticleID()),
515 - 'SMW::deleteSubject::Attributes');
516 - $db->delete('smw_longstrings',
517 - array('subject_id' => $subject->getArticleID()),
518 - 'SMW::deleteSubject::Longstrings');
519 - $db->delete('smw_specialprops',
520 - array('subject_id' => $subject->getArticleID()),
521 - 'SMW::deleteSubject::Specialprops');
522 - $db->delete('smw_nary',
523 - array('subject_id' => $subject->getArticleID()),
524 - 'SMW::deleteSubject::NAry');
525 - if ($db->affectedRows() != 0) {
526 - $db->delete('smw_nary_relations',
527 - array('subject_id' => $subject->getArticleID()),
528 - 'SMW::deleteSubject::NAryRelations');
529 - $db->update('smw_nary_relations', array('object_id' => NULL), array('object_id' => $subject->getArticleID()), 'SMW::deleteSubject::NAryRelationsObj');
530 - $db->delete('smw_nary_attributes',
531 - array('subject_id' => $subject->getArticleID()),
532 - 'SMW::deleteSubject::NAryAttributes');
533 - $db->delete('smw_nary_longstrings',
534 - array('subject_id' => $subject->getArticleID()),
535 - 'SMW::deleteSubject::NaryLongstrings');
536 - }
537 - if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
538 - $db->delete('smw_subprops',
539 - array('subject_title' => $subject->getDBKey()),
540 - 'SMW::deleteSubject::Subprops');
541 - }
542512 wfProfileOut("SMWSQLStore::deleteSubjects (SMW)");
543513 }
544514
@@ -545,7 +515,7 @@
546516 wfProfileIn("SMWSQLStore::updateData (SMW)");
547517 $db =& wfGetDB( DB_MASTER );
548518 $subject = $data->getSubject();
549 - $this->deleteSubject($subject);
 519+ $this->deleteSemanticData($subject);
550520
551521 // do bulk updates:
552522 $up_relations = array();
@@ -1179,6 +1149,46 @@
11801150 }
11811151 return $sql_conds;
11821152 }
 1153+
 1154+ /**
 1155+ * Delete all semantic data stored for the given subject.
 1156+ * Used for update purposes.
 1157+ */
 1158+ protected function deleteSemanticData(Title $subject) {
 1159+ $db =& wfGetDB( DB_MASTER );
 1160+ $db->delete('smw_relations',
 1161+ array('subject_id' => $subject->getArticleID()),
 1162+ 'SMW::deleteSubject::Relations');
 1163+ $db->delete('smw_attributes',
 1164+ array('subject_id' => $subject->getArticleID()),
 1165+ 'SMW::deleteSubject::Attributes');
 1166+ $db->delete('smw_longstrings',
 1167+ array('subject_id' => $subject->getArticleID()),
 1168+ 'SMW::deleteSubject::Longstrings');
 1169+ $db->delete('smw_specialprops',
 1170+ array('subject_id' => $subject->getArticleID()),
 1171+ 'SMW::deleteSubject::Specialprops');
 1172+ $db->delete('smw_nary',
 1173+ array('subject_id' => $subject->getArticleID()),
 1174+ 'SMW::deleteSubject::NAry');
 1175+ if ($db->affectedRows() != 0) {
 1176+ $db->delete('smw_nary_relations',
 1177+ array('subject_id' => $subject->getArticleID()),
 1178+ 'SMW::deleteSubject::NAryRelations');
 1179+ $db->update('smw_nary_relations', array('object_id' => NULL), array('object_id' => $subject->getArticleID()), 'SMW::deleteSubject::NAryRelationsObj');
 1180+ $db->delete('smw_nary_attributes',
 1181+ array('subject_id' => $subject->getArticleID()),
 1182+ 'SMW::deleteSubject::NAryAttributes');
 1183+ $db->delete('smw_nary_longstrings',
 1184+ array('subject_id' => $subject->getArticleID()),
 1185+ 'SMW::deleteSubject::NaryLongstrings');
 1186+ }
 1187+ if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
 1188+ $db->delete('smw_subprops',
 1189+ array('subject_title' => $subject->getDBKey()),
 1190+ 'SMW::deleteSubject::Subprops');
 1191+ }
 1192+ }
11831193
11841194 /**
11851195 * Find out if the given page is a redirect and determine its target.

Status & tagging log