r40487 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40486‎ | r40487 | r40488 >
Date:13:51, 5 September 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
simplify recursion check (parent now stops all recursion aggressively anyway)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php
@@ -37,20 +37,13 @@
3838 }
3939
4040 protected function getResultText($res,$outputmode) {
41 - global $smwgEmbeddingList, $wgParser;
42 - if (!is_array($smwgEmbeddingList)) { // catch recursions (sometimes more restrictive than needed, but normal usage is not affected)
43 - $firstrun = true;
44 - $smwgEmbeddingList = array();
45 - // No page should embed itself:
46 - if ($wgParser->getTitle() instanceof Title) {
47 - $smwgEmbeddingList[] = $wgParser->getTitle()->getPrefixedText();
48 - } else {
49 - global $wgTitle;
50 - $smwgEmbeddingList[] = $wgTitle->getPrefixedText();
51 - }
52 - $oldEmbeddingList = false;
53 - } else {
54 - $oldEmbeddingList = array_values($smwgEmbeddingList);
 41+ global $wgParser;
 42+ // No page should embed itself, find out who we are:
 43+ if ($wgParser->getTitle() instanceof Title) {
 44+ $title = $wgParser->getTitle()->getPrefixedText();
 45+ } else { // this is likely to be in vain -- this case is typical if we run on special pages
 46+ global $wgTitle;
 47+ $title = $wgTitle->getPrefixedText();
5548 }
5649
5750 // print header
@@ -86,8 +79,7 @@
8780 if ($this->m_showhead) {
8881 $result .= $headstart . $text . $headend;
8982 }
90 - if (!in_array($object->getLongWikiText(), $smwgEmbeddingList)) { // prevent recursion!
91 - $smwgEmbeddingList[] = $object->getLongWikiText();
 83+ if ($object->getLongWikiText() != $title) {
9284 if ($object->getNamespace() == NS_MAIN) {
9385 $articlename = ':' . $object->getDBkey();
9486 } else {
@@ -121,11 +113,6 @@
122114 }
123115 $result .= $footer;
124116
125 - if (is_array($oldEmbeddingList)) {
126 - $smwgEmbeddingList = array_values($oldEmbeddingList);
127 - } else {
128 - $smwgEmbeddingList = false;
129 - }
130117 return $result;
131118 }
132119 }

Status & tagging log