r101255 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101254‎ | r101255 | r101256 >
Date:11:49, 29 October 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
removed obsolete backward compat code
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php
@@ -1,6 +1,7 @@
22 <?php
33 /**
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.
56 *
67 * @author Markus Krötzsch
78 *
@@ -9,20 +10,16 @@
1011 */
1112
1213 /**
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+ *
2019 * @ingroup SMW
 20+ * @author Markus Krötzsch
2121 */
2222 class SMWParseData {
2323
24 - /// ParserOutput last used. See documentation to SMWParseData.
25 - static public $mPrevOutput = null;
26 -
2724 /**
2825 * Remove relevant SMW magic words from the given text and return
2926 * an array of the names of all discovered magic words. Moreover,
@@ -43,7 +40,7 @@
4441 $words[] = 'SMW_SHOWFACTBOX';
4542 }
4643
47 - $output = SMWParseData::getOutput( $parser );
 44+ $output = $parser->getOutput();
4845 $output->mSMWMagicWords = $words;
4946
5047 return $words;
@@ -56,7 +53,7 @@
5754 * @return SMWSemanticData
5855 */
5956 static public function getSMWdata( $parser ) {
60 - $output = self::getOutput( $parser );
 57+ $output = $parser->getOutput();
6158 $title = $parser->getTitle();
6259
6360 // No parsing, create error.
@@ -78,7 +75,7 @@
7976 * @param Parser $parser
8077 */
8178 static public function clearStorage( Parser $parser ) {
82 - $output = self::getOutput( $parser );
 79+ $output = $parser->getOutput();
8380 $title = $parser->getTitle();
8481
8582 if ( !isset( $output ) || !isset( $title ) ) {
@@ -306,22 +303,6 @@
307304 }
308305
309306 /**
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 - /**
326307 * Hook function fetches category information and other final settings
327308 * from parser output, so that they are also replicated in SMW for more
328309 * efficient querying.
@@ -401,26 +382,11 @@
402383 }
403384
404385 /**
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.
406388 */
407389 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 );
425391 return true;
426392 }
427393