- $nickname = $this->trimmed('nickname');
- try {
- $nickname = Nickname::normalize($nickname, true);
- } catch (NicknameTakenException $e) {
- // Abort only if the nickname is occupied by another local profile
- if ($e->profile->id != $this->scoped->id) {
- $this->showForm($e->getMessage());
- return;
+ // $nickname will only be set if this changenick value is true.
+ if (common_config('profile', 'changenick') == true) {
+ try {
+ $nickname = Nickname::normalize($this->trimmed('nickname'), true);
+ } catch (NicknameTakenException $e) {
+ // Abort only if the nickname is occupied by _another_ local user profile
+ if (!$this->scoped->sameAs($e->profile)) {
+ throw $e;
+ }
+ // Since the variable wasn't set before the exception was thrown, let's run
+ // the normalize sequence again, but without in-use check this time.
+ $nickname = Nickname::normalize($this->trimmed('nickname'));