Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php |
— | — | @@ -124,15 +124,6 @@ |
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | | - * Former hook used for storing data. Probably obsolete now (some testing required). |
129 | | - * TODO: delete this when the current architecture has been tested sucessfully |
130 | | - */ |
131 | | -function smwfSaveHook(&$article, &$user, &$text) { |
132 | | -// smwfSaveDataForTitle($article->getTitle()); // done by LinksUpdate now |
133 | | - return true; |
134 | | -} |
135 | | - |
136 | | -/** |
137 | 128 | * Used to updates data after changes of templates, but also at each saving of an article. |
138 | 129 | */ |
139 | 130 | function smwfLinkUpdateHook($links_update) { |
— | — | @@ -176,12 +167,13 @@ |
177 | 168 | * updated. To fix this, one would need to store errors as well. |
178 | 169 | */ |
179 | 170 | function smwfSaveDataForTitle($title) { |
| 171 | + global $smwgEnableUpdateJobs; |
180 | 172 | $namespace = $title->getNamespace(); |
181 | | - $updatejobflag = false; |
182 | 173 | |
183 | 174 | // Check if the semantic data has been changed. |
184 | 175 | // Sets the updateflag to true if so. |
185 | | - if ($namespace == SMW_NS_PROPERTY) { |
| 176 | + $updatejobflag = false; |
| 177 | + if ($smwgEnableUpdateJobs && ($namespace == SMW_NS_PROPERTY) ) { |
186 | 178 | // if it is a property, then we need to check if the type or |
187 | 179 | // the allowed values have been changed |
188 | 180 | $oldtype = smwfGetStore()->getSpecialValues($title, SMW_SP_HAS_TYPE); |
— | — | @@ -194,51 +186,42 @@ |
195 | 187 | $newvalues = SMWFactbox::$semdata->getPropertyValues(SMW_SP_POSSIBLE_VALUE); |
196 | 188 | $updatejobflag = smwfEqualDatavalues($oldvalues, $newvalues); |
197 | 189 | } |
198 | | - } |
199 | | - |
200 | | - if ($namespace == SMW_NS_TYPE) { |
| 190 | + } elseif ($smwgEnableUpdateJobs && ($namespace == SMW_NS_TYPE) ) { |
201 | 191 | // if it is a type we need to check if the conversion factors have been changed |
202 | 192 | $oldfactors = smwfGetStore()->getSpecialValues($title, SMW_SP_CONVERSION_FACTOR); |
203 | 193 | $newfactors = SMWFactbox::$semdata->getPropertyValues(SMW_SP_CONVERSION_FACTOR); |
204 | | - |
205 | 194 | $updatejobflag = smwfEqualDatavalues($oldfactors, $newfactors); |
206 | 195 | } |
207 | 196 | |
208 | | - // Save semantic data |
| 197 | + // Actually store semantic data |
209 | 198 | SMWFactbox::storeData(smwfIsSemanticsProcessed($title->getNamespace())); |
210 | 199 | |
211 | 200 | // Trigger relevant Updatejobs if necessary |
212 | 201 | if ($updatejobflag) { |
| 202 | + $jobs = array(); |
213 | 203 | $store = smwfGetStore(); |
214 | 204 | if ($namespace == SMW_NS_PROPERTY) { |
215 | 205 | $subjects = $store->getAllPropertySubjects($title); |
216 | 206 | foreach ($subjects as $subject) { |
217 | | - smwfGenerateSMWUpdateJobs($subject); |
| 207 | + $jobs[] = new SMWUpdateJob($subject); |
218 | 208 | } |
219 | 209 | } elseif ($namespace == SMW_NS_TYPE) { |
220 | 210 | $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_HAS_TYPE,$title->getDBkey()); |
221 | 211 | $subjects = $store->getSpecialSubjects(SMW_SP_HAS_TYPE, $dv); |
222 | 212 | foreach ($subjects as $titlesofpropertypagestoupdate) { |
223 | 213 | $subjectsPropertyPages = $store->getAllPropertySubjects($titlesofpropertypagestoupdate); |
224 | | - smwfGenerateSMWUpdateJobs($titlesofpropertypagestoupdate); |
| 214 | + $jobs[] = new SMWUpdateJob($titlesofpropertypagestoupdate); |
225 | 215 | foreach ($subjectsPropertyPages as $titleOfPageToUpdate) { |
226 | | - smwfGenerateSMWUpdateJobs($titleOfPageToUpdate); |
| 216 | + $jobs[] = new SMWUpdateJob($titleOfPageToUpdate); |
227 | 217 | } |
228 | 218 | } |
229 | 219 | } |
| 220 | + Job::batchInsert($jobs); ///NOTE: this only happens if $smwgEnableUpdateJobs was true above |
230 | 221 | } |
231 | 222 | return true; |
232 | 223 | } |
233 | 224 | |
234 | 225 | /** |
235 | | - * Generates a job, which update the semantic data of the responding page |
236 | | - */ |
237 | | -function smwfGenerateSMWUpdateJobs(& $title) { |
238 | | - $job = new SMWUpdateJob($title); |
239 | | - $job->insert(); |
240 | | -} |
241 | | - |
242 | | -/** |
243 | 226 | * Restore semantic data if articles are undeleted. |
244 | 227 | */ |
245 | 228 | function smwfUndeleteHook(&$title, $create) { |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -1614,7 +1614,7 @@ |
1615 | 1615 | * making changes, especially since errors may go unnoticed for some time. |
1616 | 1616 | */ |
1617 | 1617 | protected function updateRedirects($subject_t, $subject_ns, $curtarget_t='', $curtarget_ns=-1) { |
1618 | | - global $smwgQEqualitySupport; |
| 1618 | + global $smwgQEqualitySupport, $smwgEnableUpdateJobs; |
1619 | 1619 | $sid = $this->getSMWPageID($subject_t, $subject_ns, '', false); // find real id of subject, if any |
1620 | 1620 | /// NOTE: $sid can be 0 here; this is useful to know since it means that fewer table updates are needed |
1621 | 1621 | $db =& wfGetDB( DB_SLAVE ); |
— | — | @@ -1657,14 +1657,14 @@ |
1658 | 1658 | // -> ask SMW to update all affected pages as soon as possible (using jobs) |
1659 | 1659 | //first delete the existing redirect: |
1660 | 1660 | $db->delete('smw_redi2', array('s_title' => $subject_t,'s_namespace' => $subject_ns), 'SMW::updateRedirects'); |
1661 | | - if ($smwgQEqualitySupport != SMW_EQ_NONE) { // further updates if equality reasoning is enabled |
| 1661 | + if ( $smwgEnableUpdateJobs && ($smwgQEqualitySupport != SMW_EQ_NONE) ) { // further updates if equality reasoning is enabled |
| 1662 | + $jobs = array(); |
1662 | 1663 | $res = $db->select( array('smw_rels2','smw_ids'),'DISTINCT smw_title,smw_namespace', |
1663 | 1664 | 's_id=smw_id AND o_id=' . $db->addQuotes($old_tid), |
1664 | 1665 | 'SMW::updateRedirects'); |
1665 | 1666 | while ($row = $db->fetchObject($res)) { |
1666 | 1667 | $t = Title::makeTitle($row->smw_namespace,$row->smw_title); |
1667 | | - $job = new SMWUpdateJob($t); |
1668 | | - $job->insert(); |
| 1668 | + $jobs[] = new SMWUpdateJob($t); |
1669 | 1669 | } |
1670 | 1670 | $db->freeResult($res); |
1671 | 1671 | if ( $subject_ns == SMW_NS_PROPERTY ) { |
— | — | @@ -1676,8 +1676,7 @@ |
1677 | 1677 | 'SMW::updateRedirects'); |
1678 | 1678 | while ($row = $db->fetchObject($res)) { |
1679 | 1679 | $t = Title::makeTitle($row->smw_namespace,$row->smw_title); |
1680 | | - $job = new SMWUpdateJob($t); |
1681 | | - $job->insert(); |
| 1680 | + $jobs[] = new SMWUpdateJob($t); |
1682 | 1681 | } |
1683 | 1682 | } |
1684 | 1683 | $res = $db->select( array('smw_subs2','smw_ids'),'DISTINCT smw_title,smw_namespace', |
— | — | @@ -1685,8 +1684,7 @@ |
1686 | 1685 | 'SMW::updateRedirects'); |
1687 | 1686 | while ($row = $db->fetchObject($res)) { |
1688 | 1687 | $t = Title::makeTitle($row->smw_namespace,$row->smw_title); |
1689 | | - $job = new SMWUpdateJob($t); |
1690 | | - $job->insert(); |
| 1688 | + $jobs[] = new SMWUpdateJob($t); |
1691 | 1689 | } |
1692 | 1690 | } elseif ( $subject_ns == NS_CATEGORY ) { |
1693 | 1691 | foreach (array('smw_subs2','smw_inst2') as $table) { |
— | — | @@ -1695,11 +1693,11 @@ |
1696 | 1694 | 'SMW::updateRedirects'); |
1697 | 1695 | while ($row = $db->fetchObject($res)) { |
1698 | 1696 | $t = Title::makeTitle($row->smw_namespace,$row->smw_title); |
1699 | | - $job = new SMWUpdateJob($t); |
1700 | | - $job->insert(); |
| 1697 | + $jobs[] = new SMWUpdateJob($t); |
1701 | 1698 | } |
1702 | 1699 | } |
1703 | 1700 | } |
| 1701 | + Job::batchInsert($jobs); ///NOTE: this only happens if $smwgEnableUpdateJobs was true above |
1704 | 1702 | } |
1705 | 1703 | } |
1706 | 1704 | // finally, write the new redirect AND refresh your internal canonical id cache! |
Index: trunk/extensions/SemanticMediaWiki/includes/jobs/SMW_UpdateJob.php |
— | — | @@ -65,6 +65,8 @@ |
66 | 66 | /** |
67 | 67 | * This actually files the job. This is prevented if the configuration of SMW |
68 | 68 | * disables jobs. |
| 69 | + * NOTE: Any method that inserts jobs with Job::batchInsert or otherwise must |
| 70 | + * implement this check individually. The below is not called in these cases. |
69 | 71 | */ |
70 | 72 | function insert() { |
71 | 73 | global $smwgEnableUpdateJobs; |