Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -870,8 +870,7 @@ |
871 | 871 | $tmpnew='smw_newcats'; |
872 | 872 | $tmpres='smw_rescats'; |
873 | 873 | |
874 | | - /// TODO: check for empty $tmpnew to abort early |
875 | | - /// TODO: avoid duplicate results |
| 874 | + /// TODO: avoid duplicate results? |
876 | 875 | for ($i=0; $i<$smwgIQSubcategoryInclusions; $i++) { |
877 | 876 | $db->insertSelect($tmpres, |
878 | 877 | array($cltable,$pagetable,$tmpnew), |
— | — | @@ -880,14 +879,12 @@ |
881 | 880 | "$cltable.cl_to=$tmpnew.cat_name AND |
882 | 881 | $pagetable.page_namespace=" . NS_CATEGORY . " AND |
883 | 882 | $pagetable.page_id=$cltable.cl_from"), 'SMW::getCategoryTable'); |
884 | | - $db->insertSelect($tablename, array($tmpnew), array('cat_name' => 'cat_name'), |
| 883 | + if ($db->affectedRows() == 0) { // no change, exit loop |
| 884 | + continue; |
| 885 | + } |
| 886 | + $db->insertSelect($tablename, array($tmpres), array('cat_name' => 'cat_name'), |
885 | 887 | '*', 'SMW::getCategoryTable'); |
886 | | - $db->insertSelect($tablename, array($tmpnew), array('cat_name' => 'cat_name'), |
887 | | - '*', 'SMW::getCategoryTable'); |
888 | | - $db->query('DROP TABLE ' . $tmpnew, 'SMW::getCategoryTable'); // empty "new" table |
889 | | - $db->query( 'CREATE TEMPORARY TABLE ' . $tmpnew . ' |
890 | | - ( cat_name VARCHAR(255) NOT NULL ) |
891 | | - TYPE=MEMORY', 'SMW::getCategoryTable' ); |
| 888 | + $db->query('TRUNCATE TABLE ' . $tmpnew, 'SMW::getCategoryTable'); // empty "new" table |
892 | 889 | $tmpname = $tmpnew; |
893 | 890 | $tmpnew = $tmpres; |
894 | 891 | $tmpres = $tmpname; |