r88726 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88725‎ | r88726 | r88727 >
Date:17:02, 24 May 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Moved function show() to be a member of the class instead a global function, this was causing the following error when SpecialOpenIDDashboard::execute is called twice: PHP Fatal error: Cannot redeclare show() (previously declared in extensions/OpenID/SpecialOpenIDDashboard.body.php:42) in extensions/OpenID/SpecialOpenIDDashboard.body.php on line 42
* that function now displays true and null properly
* added alias for the special page to not throw notices
Modified paths:
  • /trunk/extensions/OpenID/OpenID.alias.php (modified) (history)
  • /trunk/extensions/OpenID/SpecialOpenIDDashboard.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.alias.php
@@ -14,6 +14,7 @@
1515 'OpenIDConvert' => array( 'OpenIDConvert' ),
1616 'OpenIDServer' => array( 'OpenIDServer' ),
1717 'OpenIDXRDS' => array( 'OpenIDXRDS' ),
 18+ 'OpenIDDashboard' => array( 'OpenIDDashboard' ),
1819 );
1920
2021 /** Arabic (العربية) */
@@ -170,4 +171,4 @@
171172 /**
172173 * For backwards compatibility with MediaWiki 1.15 and earlier.
173174 */
174 -$aliases =& $specialPageAliases;
\ No newline at end of file
 175+$aliases =& $specialPageAliases;
Index: trunk/extensions/OpenID/SpecialOpenIDDashboard.body.php
@@ -31,6 +31,16 @@
3232 'openid-dashboard-title-admin' : 'openid-dashboard-title' ) ;
3333 }
3434
 35+ function show( $string, $value ) {
 36+ if ( $value === null ) {
 37+ $value = 'null';
 38+ } elseif ( is_bool( $value ) ) {
 39+ $value = wfBoolToStr( $value );
 40+ } else {
 41+ $value = htmlspecialchars( $value );
 42+ }
 43+ return "<tr><td>$string</td><td>$value</td></tr>\n";
 44+ }
3545
3646 /**
3747 * Show the special page
@@ -38,16 +48,6 @@
3949 * @param $par Mixed: parameter passed to the page or null
4050 */
4151 function execute( $par ) {
42 -
43 - function show( $string, $value ) {
44 - if ( isset($value) ) {
45 - $value = ( $value===false ) ? 'false' : $value;
46 - } else {
47 - $value = 'undefined';
48 - }
49 - return "<tr><td>$string</td><td>$value</td></tr>";
50 - }
51 -
5252 global $wgOut, $wgUser;
5353 global $wgOpenIDShowUrlOnUserPage;
5454 global $wgOpenIDTrustEmailAddress;
@@ -62,32 +62,32 @@
6363 global $wgOpenIDShowProviderIcons;
6464
6565 if ( !$this->userCanExecute($wgUser) ) {
66 - $this->displayRestrictionError();
67 - return;
68 - }
 66+ $this->displayRestrictionError();
 67+ return;
 68+ }
6969
7070 $totalUsers = SiteStats::users();
7171 $OpenIDdistinctUsers = $this->getOpenIDUsers( 'distinctusers' );
7272 $OpenIDUsers = $this->getOpenIDUsers();
7373
7474 $out = "<table class='openiddashboard wikitable'><tr><th>Parameter</th><th>Value</th></tr>";
75 - $out .= show( 'MEDIAWIKI_OPENID_VERSION', MEDIAWIKI_OPENID_VERSION );
76 - $out .= show( '$wgOpenIDOnly', $wgOpenIDOnly );
77 - $out .= show( '$wgOpenIDClientOnly', $wgOpenIDClientOnly );
78 - $out .= show( '$wgOpenIDAllowServingOpenIDUserAccounts', $wgOpenIDAllowServingOpenIDUserAccounts );
79 - $out .= show( '$wgOpenIDTrustEmailAddress', $wgOpenIDTrustEmailAddress );
80 - $out .= show( '$wgOpenIDAllowExistingAccountSelection', $wgOpenIDAllowExistingAccountSelection );
81 - $out .= show( '$wgOpenIDAllowAutomaticUsername', $wgOpenIDAllowAutomaticUsername );
82 - $out .= show( '$wgOpenIDAllowNewAccountname', $wgOpenIDAllowNewAccountname );
83 - $out .= show( '$wgOpenIDUseEmailAsNickname', $wgOpenIDUseEmailAsNickname );
84 - $out .= show( '$wgOpenIDProposeUsernameFromSREG', $wgOpenIDProposeUsernameFromSREG );
85 - $out .= show( '$wgOpenIDShowUrlOnUserPage', $wgOpenIDShowUrlOnUserPage );
86 - $out .= show( '$wgOpenIDShowProviderIcons', $wgOpenIDShowProviderIcons );
 75+ $out .= $this->show( 'MEDIAWIKI_OPENID_VERSION', MEDIAWIKI_OPENID_VERSION );
 76+ $out .= $this->show( '$wgOpenIDOnly', $wgOpenIDOnly );
 77+ $out .= $this->show( '$wgOpenIDClientOnly', $wgOpenIDClientOnly );
 78+ $out .= $this->show( '$wgOpenIDAllowServingOpenIDUserAccounts', $wgOpenIDAllowServingOpenIDUserAccounts );
 79+ $out .= $this->show( '$wgOpenIDTrustEmailAddress', $wgOpenIDTrustEmailAddress );
 80+ $out .= $this->show( '$wgOpenIDAllowExistingAccountSelection', $wgOpenIDAllowExistingAccountSelection );
 81+ $out .= $this->show( '$wgOpenIDAllowAutomaticUsername', $wgOpenIDAllowAutomaticUsername );
 82+ $out .= $this->show( '$wgOpenIDAllowNewAccountname', $wgOpenIDAllowNewAccountname );
 83+ $out .= $this->show( '$wgOpenIDUseEmailAsNickname', $wgOpenIDUseEmailAsNickname );
 84+ $out .= $this->show( '$wgOpenIDProposeUsernameFromSREG', $wgOpenIDProposeUsernameFromSREG );
 85+ $out .= $this->show( '$wgOpenIDShowUrlOnUserPage', $wgOpenIDShowUrlOnUserPage );
 86+ $out .= $this->show( '$wgOpenIDShowProviderIcons', $wgOpenIDShowProviderIcons );
8787
88 - $out .= show( 'Number of users (total)', $totalUsers );
89 - $out .= show( 'Number of users with OpenID', $OpenIDdistinctUsers );
90 - $out .= show( 'Number of OpenIDs (total)', $OpenIDUsers );
91 - $out .= show( 'Number of users without OpenID', $totalUsers - $OpenIDdistinctUsers );
 88+ $out .= $this->show( 'Number of users (total)', $totalUsers );
 89+ $out .= $this->show( 'Number of users with OpenID', $OpenIDdistinctUsers );
 90+ $out .= $this->show( 'Number of OpenIDs (total)', $OpenIDUsers );
 91+ $out .= $this->show( 'Number of users without OpenID', $totalUsers - $OpenIDdistinctUsers );
9292 $out .= '</table>';
9393
9494 $this->setHeaders();

Sign-offs

UserFlagDate
Wikinauttested19:54, 24 May 2011

Comments

#Comment by Wikinaut (talk | contribs)   19:54, 24 May 2011

r88726 is tested

#Comment by Wikinaut (talk | contribs)   19:54, 24 May 2011

set "Tested". Let's see, what I does

Status & tagging log