Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php |
— | — | @@ -30,12 +30,12 @@ |
31 | 31 | const STRCOND_PRE = 0; |
32 | 32 | const STRCOND_POST = 1; |
33 | 33 | const STRCOND_MID = 2; |
34 | | - |
| 34 | + |
35 | 35 | /** |
36 | 36 | * String to match. |
37 | 37 | */ |
38 | 38 | public $string; |
39 | | - |
| 39 | + |
40 | 40 | /** |
41 | 41 | * Condition. One of STRCOND_PRE (string matches prefix), |
42 | 42 | * STRCOND_POST (string matches postfix), STRCOND_MID |
— | — | @@ -62,19 +62,19 @@ |
63 | 63 | * @author Markus Krötzsch |
64 | 64 | */ |
65 | 65 | class SMWRequestOptions { |
66 | | - |
| 66 | + |
67 | 67 | /** |
68 | 68 | * The maximum number of results that should be returned. |
69 | 69 | */ |
70 | 70 | public $limit = -1; |
71 | | - |
| 71 | + |
72 | 72 | /** |
73 | 73 | * A numerical offset. The first $offset results are skipped. |
74 | 74 | * Note that this does not imply a defined order of results |
75 | 75 | * (see SMWRequestOptions->$sort below). |
76 | 76 | */ |
77 | 77 | public $offset = 0; |
78 | | - |
| 78 | + |
79 | 79 | /** |
80 | 80 | * Should the result be ordered? The employed order is defined |
81 | 81 | * by the type of result that are requested: wiki pages and strings |
— | — | @@ -82,26 +82,26 @@ |
83 | 83 | * numerically. Usually, the order should be fairly "natural". |
84 | 84 | */ |
85 | 85 | public $sort = false; |
86 | | - |
| 86 | + |
87 | 87 | /** |
88 | 88 | * If SMWRequestOptions->$sort is true, this parameter defines whether |
89 | 89 | * the results are ordered in ascending or descending order. |
90 | 90 | */ |
91 | 91 | public $ascending = true; |
92 | | - |
| 92 | + |
93 | 93 | /** |
94 | 94 | * Specifies a lower or upper bound for the values returned by the query. |
95 | 95 | * Whether it is lower or upper is specified by the parameter "ascending" |
96 | 96 | * (true->lower, false->upper). |
97 | 97 | */ |
98 | 98 | public $boundary = null; |
99 | | - |
| 99 | + |
100 | 100 | /** |
101 | 101 | * Specifies whether or not the requested boundary should be returned |
102 | 102 | * as a result. |
103 | 103 | */ |
104 | 104 | public $include_boundary = true; |
105 | | - |
| 105 | + |
106 | 106 | /** |
107 | 107 | * An array of string conditions that are applied if the result has a |
108 | 108 | * string label that can be subject to those patterns. |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | public function getStringConditions() { |
126 | 126 | return $this->stringcond; |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | } |
130 | 130 | |
131 | 131 | |
— | — | @@ -253,8 +253,8 @@ |
254 | 254 | * includes relations, attributes, and special properties. This does |
255 | 255 | * not delete the respective text from the wiki, but only clears the |
256 | 256 | * stored data. |
257 | | - * |
258 | | - * @param Title $subject |
| 257 | + * |
| 258 | + * @param Title $subject |
259 | 259 | */ |
260 | 260 | public abstract function deleteSubject( Title $subject ); |
261 | 261 | |
— | — | @@ -262,8 +262,8 @@ |
263 | 263 | * Update the semantic data stored for some individual. The data is |
264 | 264 | * given as a SMWSemanticData object, which contains all semantic data |
265 | 265 | * for one particular subject. |
266 | | - * |
267 | | - * @param SMWSemanticData $data |
| 266 | + * |
| 267 | + * @param SMWSemanticData $data |
268 | 268 | */ |
269 | 269 | public abstract function doDataUpdate( SMWSemanticData $data ); |
270 | 270 | |
— | — | @@ -277,27 +277,46 @@ |
278 | 278 | public function updateData( SMWSemanticData $data ) { |
279 | 279 | wfRunHooks( 'SMWStore::updateDataBefore', array( $this, $data ) ); |
280 | 280 | |
281 | | - $this->doDataUpdate( $data ); |
| 281 | + global $smwgCheckChangesBeforeUpdate; |
| 282 | + if ( $smwgCheckChangesBeforeUpdate && $data->hasVisibleProperties() ) { |
| 283 | + $this->removeNotChangedProperties( $data ); |
| 284 | + } |
282 | 285 | |
283 | | - // Invalidate the page, so data stored on it gets displayed immediately in queries. |
284 | | - global $smwgAutoRefreshSubject; |
285 | | - if ( $smwgAutoRefreshSubject && !wfReadOnly() ) { |
286 | | - $title = Title::makeTitle( $data->getSubject()->getNamespace(), $data->getSubject()->getDBkey() ); |
287 | | - $dbw = wfGetDB( DB_MASTER ); |
| 286 | + if ( true /* TODO: something changed */ ) { |
| 287 | + // Invalidate the page, so data stored on it gets displayed immediately in queries. |
| 288 | + global $smwgAutoRefreshSubject; |
| 289 | + if ( $smwgAutoRefreshSubject && !wfReadOnly() ) { |
| 290 | + $title = Title::makeTitle( $data->getSubject()->getNamespace(), $data->getSubject()->getDBkey() ); |
| 291 | + $dbw = wfGetDB( DB_MASTER ); |
288 | 292 | |
289 | | - $dbw->update( |
290 | | - 'page', |
291 | | - array( 'page_touched' => $dbw->timestamp( time() + 9001 ) ), |
292 | | - $title->pageCond(), |
293 | | - __METHOD__ |
294 | | - ); |
| 293 | + $dbw->update( |
| 294 | + 'page', |
| 295 | + array( 'page_touched' => $dbw->timestamp( time() + 9001 ) ), |
| 296 | + $title->pageCond(), |
| 297 | + __METHOD__ |
| 298 | + ); |
295 | 299 | |
296 | | - HTMLFileCache::clearFileCache( $title ); |
297 | | - } |
| 300 | + HTMLFileCache::clearFileCache( $title ); |
| 301 | + } |
| 302 | + } |
298 | 303 | |
| 304 | + $this->doDataUpdate( $data ); |
| 305 | + |
299 | 306 | wfRunHooks( 'SMWStore::updateDataAfter', array( $this, $data ) ); |
300 | 307 | } |
301 | | - |
| 308 | + |
| 309 | + protected function removeNotChangedProperties( SMWSemanticData &$data ) { |
| 310 | + $storedValues = $this->getStoredValues( $data ); |
| 311 | + |
| 312 | + // TODO: remove data that has not changed |
| 313 | + |
| 314 | + if ( false /* TODO: something changed */ ) { |
| 315 | + wfRunHooks( 'SMWStore::dataChanged', array( $this, $data ) ); |
| 316 | + } |
| 317 | + } |
| 318 | + |
| 319 | + protected abstract function getStoredValues( SMWSemanticData $data ); |
| 320 | + |
302 | 321 | /** |
303 | 322 | * Clear all semantic data specified for some page. |
304 | 323 | * |
— | — | @@ -328,8 +347,8 @@ |
329 | 348 | * MODE_COUNT or MODE_DEBUG) a plain wiki and HTML-compatible string is |
330 | 349 | * returned. |
331 | 350 | * |
332 | | - * @param SMWQuery $query |
333 | | - * |
| 351 | + * @param SMWQuery $query |
| 352 | + * |
334 | 353 | * @return SMWQueryResult |
335 | 354 | */ |
336 | 355 | public abstract function getQueryResult( SMWQuery $query ); |