r52787 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52786‎ | r52787 | r52788 >
Date:08:14, 6 July 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Catch cases where MW title generation fails to avoid Bug 18323
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -136,6 +136,7 @@
137137
138138 public function getShortHTMLText($linker = NULL) {
139139 $this->unstub();
 140+ if ( ($linker !== NULL) && ($this->m_caption !== '') ) { $this->getTitle(); } // init the Title object, may reveal hitherto unnoticed errors
140141 if ( ($linker === NULL) || (!$this->isValid()) || ($this->m_caption === '') ) {
141142 return htmlspecialchars($this->getCaption());
142143 } else {
@@ -168,6 +169,7 @@
169170
170171 public function getLongHTMLText($linker = NULL) {
171172 $this->unstub();
 173+ if ($linker !== NULL) { $this->getTitle(); } // init the Title object, may reveal hitherto unnoticed errors
172174 if (!$this->isValid()) {
173175 return $this->getErrorText();
174176 }
@@ -245,10 +247,15 @@
246248
247249 /**
248250 * Return according Title object or NULL if no valid value was set.
 251+ * NULL can be returned even if this object returns TRUE for isValue(),
 252+ * since the latter function does not check whether MediaWiki can really
 253+ * make a Title out of the given data.
 254+ * However, isValid() will return FALSE *after* this function failed in
 255+ * trying to create a title.
249256 */
250257 public function getTitle() {
251258 $this->unstub();
252 - if ($this->m_title === NULL) {
 259+ if ( ($this->isValid()) && ($this->m_title === NULL) ) {
253260 if ($this->m_interwiki == '') {
254261 $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform);
255262 } else { // interwiki title objects must be built from full input texts

Status & tagging log