* `wcf\system\event\listener\AbstractUserMergeListener` added.
* Notice texts support `{$username}` and `{$email}` placeholders.
* Notifications for comments in moderation.
-* Continuous numeration of edit history version in template.
+* Continuous numeration of edit history version in template.
+* `\wcf\data\user\UserProfile::getGuestUserProfile()` added.
#### New Traits
<?php
namespace wcf\data\comment;
use wcf\data\comment\response\StructuredCommentResponse;
-use wcf\data\user\User;
use wcf\data\user\UserProfile;
use wcf\data\DatabaseObjectDecorator;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
$this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, [
- 'username' => $this->username
- ]));
+ $this->userProfile = UserProfile::getGuestUserProfile($this->username);
}
}
<?php
namespace wcf\data\comment;
-use wcf\data\user\User;
use wcf\data\user\UserProfile;
use wcf\data\DatabaseObjectDecorator;
use wcf\data\TLegacyUserPropertyAccess;
$this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, [
- 'username' => $this->username
- ]));
+ $this->userProfile = UserProfile::getGuestUserProfile($this->username);
}
}
<?php
namespace wcf\data\comment\response;
-use wcf\data\user\User;
use wcf\data\user\UserProfile;
use wcf\data\DatabaseObjectDecorator;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
$this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, array(
- 'username' => $this->username
- )));
+ $this->userProfile = UserProfile::getGuestUserProfile($this->username);
}
}
<?php
namespace wcf\data\comment\response;
-use wcf\data\user\User;
use wcf\data\user\UserProfile;
use wcf\data\DatabaseObjectDecorator;
use wcf\data\TLegacyUserPropertyAccess;
$this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, [
- 'username' => $this->username
- ]));
+ $this->userProfile = UserProfile::getGuestUserProfile($this->username);
}
}
return '<a href="'.$link.'" class="userLink" data-user-id="'.$this->userID.'">'.StringUtil::encodeHtml($this->username).'</a>';
}
+
+ /**
+ * Returns an "empty" user profile object for a guest with the given username.
+ *
+ * Such objects can also be used in situations where the relevant user has been deleted
+ * but their original username is still known.
+ *
+ * @param string $username
+ * @return UserProfile
+ * @since 2.2
+ */
+ public static function getGuestUserProfile($username) {
+ return new UserProfile(new User(null, ['username' => $username]));
+ }
}
namespace wcf\system\user\notification\event;
use wcf\data\moderation\queue\ViewableModerationQueue;
use wcf\data\object\type\ObjectTypeCache;
-use wcf\data\user\User;
use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\CommentRuntimeCache;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
$commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new UserProfile(new User(null, [
- 'username' => $comment->username
- ]));
+ $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
}
return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.mail', [
$commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new UserProfile(new User(null, [
- 'username' => $comment->username
- ]));
+ $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
}
return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.message', [
$commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new UserProfile(new User(null, [
- 'username' => $comment->username
- ]));
+ $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
}
$authors = $this->getAuthors();