Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * The class in this file manages semantic data collected during parsing of an article. |
| 4 | + * The class in this file manages semantic data collected during parsing of an |
| 5 | + * article. |
5 | 6 | * |
6 | 7 | * @author Markus Krötzsch |
7 | 8 | * |
— | — | @@ -9,20 +10,16 @@ |
10 | 11 | */ |
11 | 12 | |
12 | 13 | /** |
13 | | - * Static class for managing semantic data collected during parsing, including some hooks |
14 | | - * that can be used for updating and storing the data for some article. All methods |
15 | | - * in this class are stateless: data is stored persistently only in a given parser |
16 | | - * output. There is one exception: to provide a minimal compatibility with MediaWiki |
17 | | - * up to version 1.13, the class keeps track of the latest ParserOutput that was |
18 | | - * accessed. In this way, the ParserOutput can be reproduced when storing, since it |
19 | | - * is not available as part of the storing LinkUpdate object in MediaWiki before 1.14. |
| 14 | + * Static class for managing semantic data collected during parsing, including |
| 15 | + * some hooks that can be used for updating and storing the data for some |
| 16 | + * article. All methods in this class are stateless: data is stored persistently |
| 17 | + * only in a given parser output. |
| 18 | + * |
20 | 19 | * @ingroup SMW |
| 20 | + * @author Markus Krötzsch |
21 | 21 | */ |
22 | 22 | class SMWParseData { |
23 | 23 | |
24 | | - /// ParserOutput last used. See documentation to SMWParseData. |
25 | | - static public $mPrevOutput = null; |
26 | | - |
27 | 24 | /** |
28 | 25 | * Remove relevant SMW magic words from the given text and return |
29 | 26 | * an array of the names of all discovered magic words. Moreover, |
— | — | @@ -43,7 +40,7 @@ |
44 | 41 | $words[] = 'SMW_SHOWFACTBOX'; |
45 | 42 | } |
46 | 43 | |
47 | | - $output = SMWParseData::getOutput( $parser ); |
| 44 | + $output = $parser->getOutput(); |
48 | 45 | $output->mSMWMagicWords = $words; |
49 | 46 | |
50 | 47 | return $words; |
— | — | @@ -56,7 +53,7 @@ |
57 | 54 | * @return SMWSemanticData |
58 | 55 | */ |
59 | 56 | static public function getSMWdata( $parser ) { |
60 | | - $output = self::getOutput( $parser ); |
| 57 | + $output = $parser->getOutput(); |
61 | 58 | $title = $parser->getTitle(); |
62 | 59 | |
63 | 60 | // No parsing, create error. |
— | — | @@ -78,7 +75,7 @@ |
79 | 76 | * @param Parser $parser |
80 | 77 | */ |
81 | 78 | static public function clearStorage( Parser $parser ) { |
82 | | - $output = self::getOutput( $parser ); |
| 79 | + $output = $parser->getOutput(); |
83 | 80 | $title = $parser->getTitle(); |
84 | 81 | |
85 | 82 | if ( !isset( $output ) || !isset( $title ) ) { |
— | — | @@ -306,22 +303,6 @@ |
307 | 304 | } |
308 | 305 | |
309 | 306 | /** |
310 | | - * Get the parser output from a parser object. The result is also stored |
311 | | - * in SMWParseData::$mPrevOutput for further reference. |
312 | | - * |
313 | | - * @param Parser $parser |
314 | | - */ |
315 | | - static protected function getOutput( Parser $parser ) { |
316 | | - if ( method_exists( $parser, 'getOutput' ) ) { |
317 | | - self::$mPrevOutput = $parser->getOutput(); |
318 | | - } else { |
319 | | - self::$mPrevOutput = $parser->mOutput; |
320 | | - } |
321 | | - |
322 | | - return self::$mPrevOutput; |
323 | | - } |
324 | | - |
325 | | - /** |
326 | 307 | * Hook function fetches category information and other final settings |
327 | 308 | * from parser output, so that they are also replicated in SMW for more |
328 | 309 | * efficient querying. |
— | — | @@ -401,26 +382,11 @@ |
402 | 383 | } |
403 | 384 | |
404 | 385 | /** |
405 | | - * Used to updates data after changes of templates, but also at each saving of an article. |
| 386 | + * Hook where the storage of data is triggered. This happens when |
| 387 | + * saving an article but possibly also when running update jobs. |
406 | 388 | */ |
407 | 389 | static public function onLinksUpdateConstructed( $links_update ) { |
408 | | - if ( isset( $links_update->mParserOutput ) ) { |
409 | | - $output = $links_update->mParserOutput; |
410 | | - } else { // MediaWiki <= 1.13 compatibility |
411 | | - $output = self::$mPrevOutput; |
412 | | - |
413 | | - if ( !isset( $output ) ) { |
414 | | - smwfGetStore()->clearData( new SMWDIWikiPage( |
415 | | - $links_update->mTitle->getDbKey(), |
416 | | - $links_update->mTitle->getNamespace(), |
417 | | - $links_update->mTitle->getInterwiki() |
418 | | - ) ); |
419 | | - return true; |
420 | | - } |
421 | | - } |
422 | | - |
423 | | - self::storeData( $output, $links_update->mTitle, true ); |
424 | | - |
| 390 | + self::storeData( $links_update->mParserOutput, $links_update->mTitle, true ); |
425 | 391 | return true; |
426 | 392 | } |
427 | 393 | |