r90407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90406‎ | r90407 | r90408 >
Date:17:39, 19 June 2011
Author:yaron
Status:ok (Comments)
Tags:
Comment:
Follow-up to r90324 - in some cases (some MW versions?), Title::newFromText() returns null
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -239,7 +239,7 @@
240240 } else {
241241 // If target page doesn't exist, make it a red link
242242 $targetTitle = Title::newFromText( $inTargetName );
243 - if ( !$targetTitle->exists() ) {
 243+ if ( is_null( $targetTitle) || !$targetTitle->exists() ) {
244244 $classStr .= " new";
245245 }
246246 $str = "<a href=\"$link_url\" class=\"$classStr\">$inLinkStr</a>";

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90324Set #formlink to show a red link if target page doesn't exist; cleaned up cla...yaron23:19, 17 June 2011

Comments

#Comment by 😂 (talk | contribs)   17:41, 19 June 2011

Title::newFromText() will return null if you pass it something that can't be interpolated to a title. This sort of check is normal all over core.

$title = Title::newFromText( $something );
if( $title && $title->exists() ) {
	// do stuff
}

Status & tagging log