phacility/phabricator · error · Exception

Email is already primary!

Error message

Email is already primary!

What it means

Error "Email is already primary!" thrown in phacility/phabricator.

Source

Thrown at src/applications/people/editor/PhabricatorUserEditor.php:291

    if (!$user->getID()) {
      throw new Exception(pht('User has not been created yet!'));
    }
    if (!$email->getID()) {
      throw new Exception(pht('Email has not been created yet!'));
    }

    $user->openTransaction();
      $user->beginWriteLocking();

        $user->reload();
        $email->reload();

        if ($email->getUserPHID() != $user->getPHID()) {
          throw new Exception(pht('User does not own email!'));
        }

        if ($email->getIsPrimary()) {
          throw new Exception(pht('Email is already primary!'));
        }

        if (!$email->getIsVerified()) {
          throw new Exception(pht('Email is not verified!'));
        }

        $old_primary = $user->loadPrimaryEmail();
        if ($old_primary) {
          $old_primary->setIsPrimary(0);
          $old_primary->save();
        }

        $email->setIsPrimary(1);
        $email->save();

        // If the user doesn't have the verified flag set on their account
        // yet, set it. We've made sure the email is verified above. See
        // T12635 for discussion.

View on GitHub (pinned to 5720a38cfe)

When it happens

Trigger: Thrown at src/applications/people/editor/PhabricatorUserEditor.php:291 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/2065f31dd8598e43. Report an issue: GitHub.