r40316 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40315‎ | r40316 | r40317 >
Date:20:28, 1 September 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Use $wgTitle in emergency but default to $wgParser->getTitle() for most operations
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_RSSlink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_RSSlink.php
@@ -198,7 +198,7 @@
199199 * Creates the RSS output for the single item.
200200 */
201201 public function text() {
202 - global $wgTitle, $wgServer, $wgParser, $smwgStoreActive, $smwgRSSWithPages;
 202+ global $wgServer, $wgParser, $smwgStoreActive, $smwgRSSWithPages;
203203 static $parser = null;
204204 static $parser_options = null;
205205 $smwgStoreActive = false; // make sure no Factbox is shown (RSS lacks the required styles)
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php
@@ -38,12 +38,18 @@
3939
4040 protected function getResultText($res,$outputmode) {
4141 // handle factbox
42 - global $smwgStoreActive, $wgTitle, $smwgEmbeddingList, $wgParser;
 42+ global $smwgStoreActive, $smwgEmbeddingList, $wgParser;
4343 $old_smwgStoreActive = $smwgStoreActive;
 44+ $title = $wgParser->getTitle();
 45+ if ($title === NULL) { // try that in emergency, needed in 1.11 in Special:Ask
 46+ global $wgTitle;
 47+ $title = $wgTitle;
 48+ }
 49+
4450 $smwgStoreActive = false; // no annotations stored, no factbox printed
4551 if (!isset($smwgEmbeddingList)) { // used to catch recursions, sometimes more restrictive than needed, but no major use cases should be affected by that!
46 - $smwgEmbeddingList = array($wgTitle);
47 - $oldEmbeddingList = array($wgTitle);
 52+ $smwgEmbeddingList = array($title);
 53+ $oldEmbeddingList = array($title);
4854 } else {
4955 $oldEmbeddingList = array_values($smwgEmbeddingList);
5056 }
@@ -93,9 +99,9 @@
94100 }
95101 if ($outputmode == SMW_OUTPUT_WIKI) {
96102 // $result .= '{{' . $articlename . '}}'; // fails in MW1.12 and later
97 - $result .= '[[SMW::off]]' . $parser->preprocess('{{' . $articlename . '}}', $wgTitle, $parser_options) . '[[SMW::on]]';
 103+ $result .= '[[SMW::off]]' . $parser->preprocess('{{' . $articlename . '}}', $title, $parser_options) . '[[SMW::on]]';
98104 } else { // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
99 - $parserOutput = $parser->parse('[[SMW::off]]{{' . $articlename . '}}[[SMW::on]]', $wgTitle, $parser_options);
 105+ $parserOutput = $parser->parse('[[SMW::off]]{{' . $articlename . '}}[[SMW::on]]', $title, $parser_options);
100106 $result .= $parserOutput->getText();
101107 }
102108 } else {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -225,14 +225,19 @@
226226 * Process and answer a query as given by a string and an array of parameters
227227 * as is typically produced by the <ask> parser hook. The result is formatted
228228 * according to the specified $outputformat. The parameter $context defines in
229 - * what context the query is used, which affects ceretain general settings.
 229+ * what context the query is used, which affects certain general settings.
230230 */
231231 static public function getResultFromHookParams($querystring, $params, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY) {
232 - global $wgTitle;
 232+ global $wgParser;
 233+ $title = $wgParser->getTitle();
 234+ if ($title === NULL) { // try that in emergency, needed in 1.11 in Special:Ask
 235+ global $wgTitle;
 236+ $title = $wgTitle;
 237+ }
233238 // Take care at least of some templates -- for better template support use #ask
234239 $parser = new Parser();
235240 $parserOptions = new ParserOptions();
236 - $parser->startExternalParse( $wgTitle, $parserOptions, OT_HTML );
 241+ $parser->startExternalParse( $title, $parserOptions, OT_HTML );
237242 $querystring = $parser->transformMsg( $querystring, $parserOptions );
238243 return SMWQueryProcessor::getResultFromQueryString($querystring, $params, array(), $outputmode, $context);
239244 }

Status & tagging log