r94470 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94469‎ | r94470 | r94471 >
Date:19:26, 14 August 2011
Author:reedy
Status:ok
Tags:
Comment:
Refactor out row duplicated code

htmlspecialchars around $_SERVER['HTTP_USER_AGENT']
Modified paths:
  • /trunk/extensions/UserDebugInfo/SpecialUserDebugInfo.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserDebugInfo/SpecialUserDebugInfo.php
@@ -27,43 +27,35 @@
2828
2929 $wgOut->addHTML( '<tbody>' );
3030
31 - $wgOut->addHTML( '<tr>' );
32 - $wgOut->addHTML( '<td>' );
33 - $wgOut->addWikiMsg( 'userdebuginfo-useragent' );
34 - $wgOut->addHTML( '</td>' );
 31+ $this->printRow( 'userdebuginfo-useragent', htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) );
3532
36 - $wgOut->addHTML( '<td>' );
37 - $wgOut->addHTML( $_SERVER['HTTP_USER_AGENT'] );
38 - $wgOut->addHTML( '</td>' );
39 -
40 - $wgOut->addHTML( '</tr>' );
41 -
4233 if ( isset( $_SERVER['REMOTE_HOST'] ) ) {
43 - $wgOut->addHTML( '<tr>' );
44 - $wgOut->addHTML( '<td>' );
45 - $wgOut->addWikiMsg( 'userdebuginfo-remotehost' );
46 - $wgOut->addHTML( '</td>' );
 34+ $this->printRow( 'userdebuginfo-remotehost', $_SERVER['REMOTE_HOST'] );
 35+ }
4736
48 - $wgOut->addHTML( '<td>' );
49 - $wgOut->addHTML( $_SERVER['REMOTE_HOST'] );
50 - $wgOut->addHTML( '</td>' );
 37+ $this->printRow( 'userdebuginfo-remoteaddr', $_SERVER['REMOTE_ADDR'] );
5138
52 - $wgOut->addHTML( '</tr>' );
53 - }
 39+ $wgOut->addHTML( '</tbody>' );
 40+ $wgOut->addHTML( '</table>' );
 41+ }
5442
 43+ /**
 44+ * @param $key
 45+ * @param $value
 46+ * @return void
 47+ */
 48+ private function printRow( $key, $value ) {
 49+ global $wgOut;
5550 $wgOut->addHTML( '<tr>' );
5651 $wgOut->addHTML( '<td>' );
57 - $wgOut->addWikiMsg( 'userdebuginfo-remoteaddr' );
 52+ $wgOut->addWikiMsg( $key );
5853 $wgOut->addHTML( '</td>' );
5954
6055 $wgOut->addHTML( '<td>' );
61 - $wgOut->addHTML( $_SERVER['REMOTE_ADDR'] );
 56+ $wgOut->addHTML( $value );
6257 $wgOut->addHTML( '</td>' );
6358
6459 $wgOut->addHTML( '</tr>' );
65 -
66 - $wgOut->addHTML( '</tbody>' );
67 - $wgOut->addHTML( '</table>' );
6860 }
6961 }
7062

Status & tagging log