r70625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70624‎ | r70625 | r70626 >
Date:12:27, 7 August 2010
Author:ashley
Status:deferred
Tags:
Comment:
SocialProfile: fix PHP notice (Notice: Undefined offset: 0 in ..\extensions\SocialProfile\UserProfile\SpecialRemoveAvatar.php on line 126), expand docs and mark functions as private
Modified paths:
  • /trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
@@ -1,5 +1,10 @@
22 <?php
3 -
 3+/**
 4+ * A special page for privileged users to remove other users' avatars.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
49 class RemoveAvatar extends SpecialPage {
510
611 /**
@@ -19,25 +24,25 @@
2025
2126 $this->title = SpecialPage::getTitleFor( 'RemoveAvatar' );
2227
23 - # If the user isn't logged in, display an error
 28+ // If the user isn't logged in, display an error
2429 if ( !$wgUser->isLoggedIn() ) {
2530 $this->displayRestrictionError();
2631 return;
2732 }
2833
29 - # If the user doesn't have 'avatarremove' permission, display an error
 34+ // If the user doesn't have 'avatarremove' permission, display an error
3035 if ( !$wgUser->isAllowed( 'avatarremove' ) ) {
3136 $this->displayRestrictionError();
3237 return;
3338 }
3439
35 - # Show a message if the database is in read-only mode
 40+ // Show a message if the database is in read-only mode
3641 if ( wfReadOnly() ) {
3742 $wgOut->readOnlyPage();
3843 return;
3944 }
4045
41 - # If user is blocked, s/he doesn't need to access this page
 46+ // If user is blocked, s/he doesn't need to access this page
4247 if ( $wgUser->isBlocked() ) {
4348 $wgOut->blockedPage();
4449 return;
@@ -82,10 +87,11 @@
8388
8489 /**
8590 * Show the form for retrieving a user's current avatar
 91+ * @return HTML
8692 */
87 - function showUserForm() {
88 - $output = '<form method="get" name="avatar" action="">'
89 - . Xml::hidden( 'title', $this->getTitle() ) .
 93+ private function showUserForm() {
 94+ $output = '<form method="get" name="avatar" action="">' .
 95+ Xml::hidden( 'title', $this->getTitle() ) .
9096 '<b>' . wfMsg( 'username' ) . '</b>
9197 <input type="text" name="user" />
9298 <input type="submit" value="' . wfMsg( 'search' ) . '" />
@@ -95,8 +101,10 @@
96102
97103 /**
98104 * Shows the requested user's current avatar and the button for deleting it
 105+ *
 106+ * @param $user_name String: name of the user whose avatars we want to delete
99107 */
100 - function showUserAvatar( $user_name ) {
 108+ private function showUserAvatar( $user_name ) {
101109 $user_name = str_replace( '_', ' ', $user_name ); // replace underscores with spaces
102110 $user_id = User::idFromName( $user_name );
103111
@@ -115,15 +123,17 @@
116124 /**
117125 * Deletes all of the requested user's avatar images from the filesystem
118126 *
119 - * @param $id Int: user ID
120 - * @param $size Int: size of the avatar image to delete (small, medium or large).
 127+ * @param $id Integer: user ID
 128+ * @param $size String: size of the avatar image to delete (small, medium or large).
121129 * Doesn't really matter since we're just going to blast 'em all.
122130 */
123 - function deleteImage( $id, $size ) {
 131+ private function deleteImage( $id, $size ) {
124132 global $wgUploadDirectory, $wgDBname, $wgMemc;
125133 $avatar = new wAvatar( $id, $size );
126134 $files = glob( $wgUploadDirectory . '/avatars/' . $wgDBname . '_' . $id . '_' . $size . "*" );
 135+ wfSuppressWarnings();
127136 $img = basename( $files[0] );
 137+ wfRestoreWarnings();
128138 if ( $img && $img[0] ) {
129139 unlink( $wgUploadDirectory . '/avatars/' . $img );
130140 }

Status & tagging log