r23960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23959‎ | r23960 | r23961 >
Date:14:42, 10 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Fixed bug occurring with installations using table prefixes.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -872,7 +872,7 @@
873873 global $wgDBname, $smwgIQSubcategoryInclusions;
874874
875875 $tablename = 'cats' . SMWSQLStore::$m_tablenum++;
876 - $db->query( 'CREATE TEMPORARY TABLE ' . $wgDBname . '.' . $tablename .
 876+ $db->query( 'CREATE TEMPORARY TABLE ' . $tablename .
877877 '( cat_name VARCHAR(255) NOT NULL )
878878 TYPE=MEMORY', 'SMW::getCategoryTable' );
879879 if (array_key_exists($catname, SMWSQLStore::$m_categorytables)) { // just copy known result
@@ -888,28 +888,26 @@
889889 $db->query( 'CREATE TEMPORARY TABLE smw_rescats
890890 ( cat_name VARCHAR(255) NOT NULL )
891891 TYPE=MEMORY', 'SMW::getCategoryTable' );
 892+ $tmpnew = 'smw_newcats';
 893+ $tmpres = 'smw_rescats';
892894
893895 $pagetable = $db->tableName('page');
894896 $cltable = $db->tableName('categorylinks');
895 - $db->insert($tablename, array('cat_name' => $catname), 'SMW::getCategoryTable');
896 - $db->insert('smw_newcats', array('cat_name' => $catname), 'SMW::getCategoryTable');
897 - $tmpnew='smw_newcats';
898 - $tmpres='smw_rescats';
 897+ $db->query("INSERT INTO $tablename (cat_name) VALUES ('$catname')", 'SMW::getCategoryTable');
 898+ $db->query("INSERT INTO smw_newcats (cat_name) VALUES ('$catname')", 'SMW::getCategoryTable');
899899
900900 /// TODO: avoid duplicate results?
901901 for ($i=0; $i<$smwgIQSubcategoryInclusions; $i++) {
902 - $db->insertSelect($tmpres,
903 - array($cltable,$pagetable,$tmpnew),
904 - array('cat_name' => 'page_title'),
905 - array(
906 - "$cltable.cl_to=$tmpnew.cat_name AND
907 - $pagetable.page_namespace=" . NS_CATEGORY . " AND
908 - $pagetable.page_id=$cltable.cl_from"), 'SMW::getCategoryTable');
 902+ $db->query("INSERT INTO $tmpres (cat_name) SELECT $pagetable.page_title
 903+ FROM $cltable,$pagetable,$tmpnew WHERE
 904+ $cltable.cl_to=$tmpnew.cat_name AND
 905+ $pagetable.page_namespace=" . NS_CATEGORY . " AND
 906+ $pagetable.page_id=$cltable.cl_from", 'SMW::getCategoryTable');
909907 if ($db->affectedRows() == 0) { // no change, exit loop
910908 continue;
911909 }
912 - $db->insertSelect($tablename, array($tmpres), array('cat_name' => 'cat_name'),
913 - '*', 'SMW::getCategoryTable');
 910+ $db->query("INSERT INTO $tablename (cat_name) SELECT $tmpres.cat_name
 911+ FROM $tmpres", 'SMW::getCategoryTable');
914912 $db->query('TRUNCATE TABLE ' . $tmpnew, 'SMW::getCategoryTable'); // empty "new" table
915913 $tmpname = $tmpnew;
916914 $tmpnew = $tmpres;

Status & tagging log