{"record":{"id":"2065f31dd8598e43","repo":"phacility/phabricator","slug":"email-is-already-primary","errorCode":null,"errorMessage":"Email is already primary!","messagePattern":"Email is already primary!","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/people/editor/PhabricatorUserEditor.php","lineNumber":291,"sourceCode":"    if (!$user->getID()) {\n      throw new Exception(pht('User has not been created yet!'));\n    }\n    if (!$email->getID()) {\n      throw new Exception(pht('Email has not been created yet!'));\n    }\n\n    $user->openTransaction();\n      $user->beginWriteLocking();\n\n        $user->reload();\n        $email->reload();\n\n        if ($email->getUserPHID() != $user->getPHID()) {\n          throw new Exception(pht('User does not own email!'));\n        }\n\n        if ($email->getIsPrimary()) {\n          throw new Exception(pht('Email is already primary!'));\n        }\n\n        if (!$email->getIsVerified()) {\n          throw new Exception(pht('Email is not verified!'));\n        }\n\n        $old_primary = $user->loadPrimaryEmail();\n        if ($old_primary) {\n          $old_primary->setIsPrimary(0);\n          $old_primary->save();\n        }\n\n        $email->setIsPrimary(1);\n        $email->save();\n\n        // If the user doesn't have the verified flag set on their account\n        // yet, set it. We've made sure the email is verified above. See\n        // T12635 for discussion.","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/editor/PhabricatorUserEditor.php#L273-L309","documentation":"Error \"Email is already primary!\" thrown in phacility/phabricator.","triggerScenarios":"Thrown at src/applications/people/editor/PhabricatorUserEditor.php:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}