r98229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98228‎ | r98229 | r98230 >
Date:16:17, 27 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix whitespace

Add comments
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthHooks.php (modified) (history)
  • /trunk/extensions/Nuke/Nuke_body.php (modified) (history)
  • /trunk/extensions/SignupAPI/includes/ApiSignup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Nuke/Nuke_body.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class SpecialNuke extends SpecialPage {
5 -
 5+
66 public function __construct() {
77 parent::__construct( 'Nuke', 'nuke' );
88 }
@@ -16,10 +16,10 @@
1717
1818 $this->setHeaders();
1919 $this->outputHeader();
20 -
 20+
2121 if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
2222 $target = $wgRequest->getText( 'target', $par );
23 -
 23+
2424 // Normalise name
2525 if ( $target !== '' ) {
2626 $user = User::newFromName( $target );
@@ -33,19 +33,17 @@
3434 $target === '' ? wfMsg( 'nuke-multiplepeople' ) : $target
3535 )
3636 );
37 -
 37+
3838 if ( $wgRequest->getVal( 'action' ) == 'delete' ) {
3939 $pages = $wgRequest->getArray( 'pages' );
40 -
 40+
4141 if( $pages ) {
4242 return $this->doDelete( $pages, $reason );
4343 }
44 - }
45 - else {
 44+ } else {
4645 $this->listForm( $target, $reason, $wgRequest->getInt( 'limit' ) );
4746 }
48 - }
49 - else {
 47+ } else {
5048 $this->promptForm();
5149 }
5250 }
@@ -57,7 +55,7 @@
5856 global $wgOut, $wgUser;
5957
6058 $wgOut->addWikiMsg( 'nuke-tools' );
61 -
 59+
6260 $wgOut->addHTML(
6361 Xml::openElement(
6462 'form',
@@ -75,15 +73,15 @@
7674 . '</tr><tr>'
7775 . '<td></td>'
7876 . '<td>' . Xml::submitButton( wfMsg( 'nuke-submit-user' ) ) . '</td>'
79 - .'</tr></table>'
80 - . Html::hidden( 'wpEditToken', $wgUser->editToken() )
 77+ .'</tr></table>'
 78+ . Html::hidden( 'wpEditToken', $wgUser->editToken() )
8179 . Xml::closeElement( 'form' )
8280 );
8381 }
8482
8583 /**
8684 * Display list of pages to delete.
87 - *
 85+ *
8886 * @param string $username
8987 * @param string $reason
9088 * @param integer $limit
@@ -97,11 +95,10 @@
9896 $wgOut->addWikiMsg( 'nuke-nopages', $username );
9997 return $this->promptForm();
10098 }
101 -
 99+
102100 if ( $username == '' ) {
103101 $wgOut->addWikiMsg( 'nuke-list-multiple' );
104 - }
105 - else {
 102+ } else {
106103 $wgOut->addWikiMsg( 'nuke-list', $username );
107104 }
108105
@@ -138,9 +135,9 @@
139136
140137 // Select: All, None
141138 $links = array();
142 - $links[] = '<a href="#" onclick="selectPages( true ); return false;">' .
 139+ $links[] = '<a href="#" onclick="selectPages( true ); return false;">' .
143140 wfMsg( 'powersearch-toggleall' ) . '</a>';
144 - $links[] = '<a href="#" onclick="selectPages( false ); return false;">' .
 141+ $links[] = '<a href="#" onclick="selectPages( false ); return false;">' .
145142 wfMsg( 'powersearch-togglenone' ) . '</a>';
146143 $wgOut->addHTML(
147144 Xml::tags( 'p',
@@ -163,7 +160,7 @@
164161 $thumb = $image && $image->exists() ? $image->transform( array( 'width' => 120, 'height' => 120 ), 0 ) : false;
165162
166163 $changes = wfMsgExt( 'nchanges', 'parsemag', $wgLang->formatNum( $edits ) );
167 -
 164+
168165 $wgOut->addHTML( '<li>' .
169166 Xml::check( 'pages[]', true,
170167 array( 'value' => $title->getPrefixedDbKey() )
@@ -176,7 +173,7 @@
177174 $sk->makeKnownLinkObj( $title, $changes, 'action=history' ) .
178175 ")</li>\n" );
179176 }
180 -
 177+
181178 $wgOut->addHTML(
182179 "</ul>\n" .
183180 Xml::submitButton( wfMsg( 'nuke-submit-delete' ) ) .
@@ -186,31 +183,30 @@
187184
188185 /**
189186 * Gets a list of new pages by the specified user or everyone when none is specified.
190 - *
 187+ *
191188 * @param string $username
192189 * @param integer $limit
193 - *
 190+ *
194191 * @return array
195192 */
196193 protected function getNewPages( $username, $limit ) {
197194 $dbr = wfGetDB( DB_SLAVE );
198 -
 195+
199196 $what = array(
200197 'rc_namespace',
201198 'rc_title',
202199 'rc_timestamp',
203200 'COUNT(*) AS edits'
204 - );
205 -
 201+ );
 202+
206203 $where = array( "(rc_new = 1) OR (rc_log_type = 'upload' AND rc_log_action = 'upload')" );
207 -
 204+
208205 if ( $username == '' ) {
209206 $what[] = 'rc_user_text';
210 - }
211 - else {
 207+ } else {
212208 $where['rc_user_text'] = $username;
213209 }
214 -
 210+
215211 $result = $dbr->select( 'recentchanges',
216212 $what,
217213 $where,
@@ -221,9 +217,9 @@
222218 'LIMIT' => $limit
223219 )
224220 );
225 -
 221+
226222 $pages = array();
227 -
 223+
228224 foreach ( $result as $row ) {
229225 $pages[] = array(
230226 Title::makeTitle( $row->rc_namespace, $row->rc_title ),
@@ -231,15 +227,13 @@
232228 $username == '' ? $row->rc_user_text : false
233229 );
234230 }
235 -
236 - $dbr->freeResult( $result );
237 -
 231+
238232 return $pages;
239233 }
240234
241235 /**
242236 * Does the actual deletion of the pages.
243 - *
 237+ *
244238 * @param array $pages The pages to delete
245239 * @param string $reason
246240 */
@@ -263,6 +257,6 @@
264258 $res[] = wfMsgExt( 'nuke-not-deleted', array( 'parseinline' ), $title->getPrefixedText() );
265259 }
266260 }
267 - $wgOut->addHTML( "<ul>\n<li>" .implode( "</li>\n<li>", $res ) . "</li>\n</ul>\n" );
 261+ $wgOut->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $res ) . "</li>\n</ul>\n" );
268262 }
269263 }
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php
@@ -101,9 +101,9 @@
102102 /**
103103 * Show a nicer error when the user account does not exist on the local wiki, but
104104 * does exist globally
105 - * @param $users Array
106 - * @param $data Array
107 - * @param $abortError String
 105+ * @param $users Array
 106+ * @param $data Array
 107+ * @param $abortError String
108108 * @return bool
109109 */
110110 static function onSpecialPasswordResetOnSubmit( &$users, $data, &$abortError ) {
@@ -124,6 +124,11 @@
125125 return true;
126126 }
127127
 128+ /**
 129+ * @param $user User
 130+ * @param $inject_html string
 131+ * @return bool
 132+ */
128133 static function onUserLoginComplete( &$user, &$inject_html ) {
129134 global $wgCentralAuthCookies, $wgRequest;
130135 if ( !$wgCentralAuthCookies ) {
@@ -182,6 +187,11 @@
183188 return true;
184189 }
185190
 191+ /**
 192+ * @param $user User
 193+ * @param $result
 194+ * @return bool
 195+ */
186196 static function onUserLoadFromSession( $user, &$result ) {
187197 global $wgCentralAuthCookies, $wgCentralAuthCookiePrefix;
188198 if ( !$wgCentralAuthCookies ) {
@@ -267,6 +277,10 @@
268278 return true;
269279 }
270280
 281+ /**
 282+ * @param $user User
 283+ * @return bool
 284+ */
271285 static function onUserLogout( &$user ) {
272286 global $wgCentralAuthCookies;
273287 if ( !$wgCentralAuthCookies ) {
@@ -465,17 +479,17 @@
466480 return false;
467481 }
468482
469 - // Give other extensions a chance to stop auto creation, but they cannot
470 - // change $userName, because CentralAuth expects user names on all wikis
471 - // are the same.
 483+ // Give other extensions a chance to stop auto creation, but they cannot
 484+ // change $userName, because CentralAuth expects user names on all wikis
 485+ // are the same.
472486 //
473 - // * $user (and usually $wgUser) is the half-created User object and
474 - // should not be accessed in any way since calling any User methods
 487+ // * $user (and usually $wgUser) is the half-created User object and
 488+ // should not be accessed in any way since calling any User methods
475489 // in its half-initialised state will give incorrect results.
476490 //
477491 // * $userName is the new user name
478492 //
479 - // * $anon is an anonymous user object which can be safely used for
 493+ // * $anon is an anonymous user object which can be safely used for
480494 // permissions checks.
481495 if ( !wfRunHooks( 'CentralAuthAutoCreate', array( $user, $userName, $anon ) ) ) {
482496 wfDebug( __METHOD__ . ": denied by other extensions\n" );
Index: trunk/extensions/SignupAPI/includes/ApiSignup.php
@@ -197,8 +197,8 @@
198198 return array_merge( parent::getPossibleErrors(), array(
199199 array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ),
200200 array( 'code' => 'ReadOnlyPage', 'info' => 'Accounts cannot be created with read-only permissions' ),
201 - array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source.
202 - Ensure you have cookies enabled, reload this page and try again.' ),
 201+ array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source. ' .
 202+ 'Ensure you have cookies enabled, reload this page and try again.' ),
203203 array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ),
204204 array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ),
205205 array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ),

Status & tagging log