/**
  * change user's email and send reconfirmation email
  * @requestParam string username
  * @requestParam string email
  * @responseParam string result [ok/error/invalidsession/confirmed]
  * @responseParam string msg - result messages
  * @responseParam string errParam - error param
  */
 public function changeUnconfirmedUserEmail()
 {
     // get new email from request
     $email = $this->request->getVal('email', '');
     $username = $this->request->getVal('username');
     if (!($this->isValidEmailFieldValue($email) && $this->isValidUsernameField($username))) {
         return;
     }
     $user = User::newFromName($username);
     if (!($this->isValidUser($user) && $this->isValidSession($user))) {
         return;
     }
     // check email changes limit
     $memKey = wfSharedMemcKey('wikialogin', 'email_changes', $user->getId());
     // CONN-471: Respect the registration per email limit
     if (!($this->isWithinEmailChangesLimit($memKey) && $this->isWithinRegistrationPerEmailLimit($email))) {
         return;
     }
     // increase counter for email changes
     $this->userLoginHelper->incrMemc($memKey);
     $this->setResponseFields('ok', wfMessage('usersignup-reconfirmation-email-sent', $email)->escaped());
     if ($email != $user->getEmail()) {
         $user->setEmail($email);
         // CONN-471: Call AbortNewAccount to validate username/password with Phalanx
         if ($this->isBlockedByPhalanx($user)) {
             return;
         }
         // send reconfirmation email
         $result = $user->sendReConfirmationMail();
         $user->saveSettings();
         // set counter to 1 for confirmation emails sent
         $memKey = $this->userLoginHelper->getMemKeyConfirmationEmailsSent($user->getId());
         $this->wg->Memc->set($memKey, 1, 24 * 60 * 60);
         if (!$result->isGood()) {
             $this->setResponseFields('error', wfMessage('userlogin-error-mail-error', $result->getMessage())->parse());
         }
     }
 }