r72167 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72166‎ | r72167 | r72168 >
Date:22:18, 1 September 2010
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
adding templateExists() function
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -818,4 +818,15 @@
819819 $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message );
820820 $this->centralNoticeError = true;
821821 }
 822+
 823+ public static function templateExists( $templateName ) {
 824+ $dbr = wfGetDB( DB_SLAVE );
 825+ $eTemplateName = htmlspecialchars( $templateName );
 826+ $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 'tmp_name' => $eTemplateName ) );
 827+ if ( $row ) {
 828+ return true;
 829+ } else {
 830+ return false;
 831+ }
 832+ }
822833 }

Comments

#Comment by Nikerabbit (talk | contribs)   06:45, 2 September 2010

return (bool) $row; ?

#Comment by Ryan Kaldari (WMF) (talk | contribs)   17:12, 2 September 2010

Hmm, tough choice. It's much more concise, but not as readable.

Status & tagging log