jenkins-bot has submitted this change and it was merged.
Change subject: Allow wikifarms to have global avatars
......................................................................
Allow wikifarms to have global avatars
The new $wgAvatarKey can now be used to set a static avatar
path between wikis, allowing global avatars
Bug: T85070
Change-Id: I232e54b389b9c44f208a779dd0c96e46859fedb2
---
M SocialProfile.php
M UserProfile/AvatarClass.php
M UserProfile/SpecialRemoveAvatar.php
M UserProfile/SpecialUploadAvatar.php
4 files changed, 45 insertions(+), 40 deletions(-)
Approvals:
Jack Phoenix: Looks good to me, approved
jenkins-bot: Verified
diff --git a/SocialProfile.php b/SocialProfile.php
index 2a29658..afec7d9 100644
--- a/SocialProfile.php
+++ b/SocialProfile.php
@@ -98,6 +98,11 @@
// Whether to enable friending or not -- this doesn't do very much actually,
so don't rely on it
$wgFriendingEnabled = true;
+// Prefix SocialProfile will use to store avatars
+// for global avatars on a wikifarm or groups of wikis,
+// set this to something static.
+$wgAvatarKey = $wgDBname;
+
// Extension credits that show up on Special:Version
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
diff --git a/UserProfile/AvatarClass.php b/UserProfile/AvatarClass.php
index 0e8b7ed..ac79e4d 100644
--- a/UserProfile/AvatarClass.php
+++ b/UserProfile/AvatarClass.php
@@ -34,7 +34,7 @@
* image size (s, m, ml or l)
*/
function getAvatarImage() {
- global $wgDBname, $wgUploadDirectory, $wgMemc;
+ global $wgAvatarKey, $wgUploadDirectory, $wgMemc;
$key = wfMemcKey( 'user', 'profile', 'avatar', $this->user_id,
$this->avatar_size );
$data = $wgMemc->get( $key );
@@ -43,7 +43,7 @@
if ( $data ) {
$avatar_filename = $data;
} else {
- $files = glob( $wgUploadDirectory . '/avatars/' .
$wgDBname . '_' . $this->user_id . '_' . $this->avatar_size . "*" );
+ $files = glob( $wgUploadDirectory . '/avatars/' .
$wgAvatarKey . '_' . $this->user_id . '_' . $this->avatar_size . "*" );
if ( !isset( $files[0] ) || !$files[0] ) {
$avatar_filename = 'default_' .
$this->avatar_size . '.gif';
} else {
diff --git a/UserProfile/SpecialRemoveAvatar.php
b/UserProfile/SpecialRemoveAvatar.php
index 4b02648..d7eac29 100644
--- a/UserProfile/SpecialRemoveAvatar.php
+++ b/UserProfile/SpecialRemoveAvatar.php
@@ -149,10 +149,10 @@
* Doesn't really matter since we're just going to
blast 'em all.
*/
private function deleteImage( $id, $size ) {
- global $wgUploadDirectory, $wgDBname, $wgMemc;
+ global $wgUploadDirectory, $wgAvatarKey, $wgMemc;
$avatar = new wAvatar( $id, $size );
- $files = glob( $wgUploadDirectory . '/avatars/' . $wgDBname .
'_' . $id . '_' . $size . "*" );
+ $files = glob( $wgUploadDirectory . '/avatars/' . $wgAvatarKey
. '_' . $id . '_' . $size . "*" );
wfSuppressWarnings();
$img = basename( $files[0] );
wfRestoreWarnings();
diff --git a/UserProfile/SpecialUploadAvatar.php
b/UserProfile/SpecialUploadAvatar.php
index c428f19..d2404ab 100644
--- a/UserProfile/SpecialUploadAvatar.php
+++ b/UserProfile/SpecialUploadAvatar.php
@@ -67,7 +67,7 @@
* @param $ext String: file extension (gif, jpg or png)
*/
private function showSuccess( $ext ) {
- global $wgDBname, $wgUploadPath, $wgUploadAvatarInRecentChanges;
+ global $wgAvatarKey, $wgUploadPath,
$wgUploadAvatarInRecentChanges;
$user = $this->getUser();
$log = new LogPage( 'avatar' );
@@ -95,7 +95,7 @@
$this->msg( 'user-profile-picture-large'
)->plain() .
'</td>
<td style="padding-bottom:20px;">
- <img src="' . $wgUploadPath . '/avatars/' .
$wgDBname . '_' . $uid . '_l.' . $ext . '?ts=' . rand() . '" alt="" border="0"
/>
+ <img src="' . $wgUploadPath . '/avatars/' .
$wgAvatarKey . '_' . $uid . '_l.' . $ext . '?ts=' . rand() . '" alt=""
border="0" />
</td>
</tr>';
$output .= '<tr>
@@ -103,7 +103,7 @@
$this->msg( 'user-profile-picture-medlarge'
)->plain() .
'</td>
<td style="padding-bottom:20px;">
- <img src="' . $wgUploadPath . '/avatars/' .
$wgDBname . '_' . $uid . '_ml.' . $ext . '?ts=' . rand() . '" alt="" border="0"
/>
+ <img src="' . $wgUploadPath . '/avatars/' .
$wgAvatarKey . '_' . $uid . '_ml.' . $ext . '?ts=' . rand() . '" alt=""
border="0" />
</td>
</tr>';
$output .= '<tr>
@@ -111,7 +111,7 @@
$this->msg( 'user-profile-picture-medium'
)->plain() .
'</td>
<td style="padding-bottom:20px;">
- <img src="' . $wgUploadPath . '/avatars/' .
$wgDBname . '_' . $uid . '_m.' . $ext . '?ts=' . rand() . '" alt="" border="0"
/>
+ <img src="' . $wgUploadPath . '/avatars/' .
$wgAvatarKey . '_' . $uid . '_m.' . $ext . '?ts=' . rand() . '" alt=""
border="0" />
</td>
</tr>';
$output .= '<tr>
@@ -119,7 +119,7 @@
$this->msg( 'user-profile-picture-small'
)->plain() .
'</td>
<td style="padding-bottom:20px;">
- <img src="' . $wgUploadPath . '/avatars/' .
$wgDBname . '_' . $uid . '_s.' . $ext . '?ts=' . rand() . '" alt="" border="0"
/>
+ <img src="' . $wgUploadPath . '/avatars/' .
$wgAvatarKey . '_' . $uid . '_s.' . $ext . '?ts=' . rand() . '" alt=""
border="0" />
</td>
</tr>';
$output .= '<tr>
@@ -229,9 +229,9 @@
* @return String: full img HTML tag
*/
function getAvatar( $size ) {
- global $wgDBname, $wgUploadDirectory, $wgUploadPath;
+ global $wgAvatarKey, $wgUploadDirectory, $wgUploadPath;
$files = glob(
- $wgUploadDirectory . '/avatars/' . $wgDBname . '_' .
+ $wgUploadDirectory . '/avatars/' . $wgAvatarKey . '_' .
$this->getUser()->getID() . '_' . $size . '*'
);
if ( isset( $files[0] ) && $files[0] ) {
@@ -346,7 +346,7 @@
* Create the thumbnails and delete old files
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
- global $wgUploadDirectory, $wgDBname, $wgMemc;
+ global $wgUploadDirectory, $wgAvatarKey, $wgMemc;
$this->avatarUploadDirectory = $wgUploadDirectory . '/avatars';
@@ -377,51 +377,51 @@
$stats->incStatField( 'user_image' );
}
- $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname
. '_' . $uid . '_l', 75 );
- $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname
. '_' . $uid . '_ml', 50 );
- $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname
. '_' . $uid . '_m', 30 );
- $this->createThumbnail( $this->mTempPath, $imageInfo, $wgDBname
. '_' . $uid . '_s', 16 );
+ $this->createThumbnail( $this->mTempPath, $imageInfo,
$wgAvatarKey . '_' . $uid . '_l', 75 );
+ $this->createThumbnail( $this->mTempPath, $imageInfo,
$wgAvatarKey . '_' . $uid . '_ml', 50 );
+ $this->createThumbnail( $this->mTempPath, $imageInfo,
$wgAvatarKey . '_' . $uid . '_m', 30 );
+ $this->createThumbnail( $this->mTempPath, $imageInfo,
$wgAvatarKey . '_' . $uid . '_s', 16 );
if ( $ext != 'jpg' ) {
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.jpg' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.jpg' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.jpg' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.jpg' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.jpg' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.jpg' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.jpg' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.jpg' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.jpg' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.jpg' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.jpg' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.jpg' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.jpg' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.jpg' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.jpg' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.jpg' );
}
}
if ( $ext != 'gif' ) {
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.gif' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.gif' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.gif' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.gif' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.gif' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.gif' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.gif' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.gif' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.gif' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.gif' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.gif' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.gif' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.gif' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.gif' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.gif' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.gif' );
}
}
if ( $ext != 'png' ) {
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.png' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_s.png' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.png' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_s.png' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.png' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_m.png' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.png' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_m.png' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.png' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_l.png' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.png' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_l.png' );
}
- if ( is_file( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.png' ) ) {
- unlink( $this->avatarUploadDirectory . '/' .
$wgDBname . '_' . $uid . '_ml.png' );
+ if ( is_file( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.png' ) ) {
+ unlink( $this->avatarUploadDirectory . '/' .
$wgAvatarKey . '_' . $uid . '_ml.png' );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/182357
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I232e54b389b9c44f208a779dd0c96e46859fedb2
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/SocialProfile
Gerrit-Branch: master
Gerrit-Owner: UltrasonicNXT <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Lewis Cawte <[email protected]>
Gerrit-Reviewer: UltrasonicNXT <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits