diff --git a/src/applications/repository/xaction/PhabricatorRepositoryEncodingTransaction.php b/src/applications/repository/xaction/PhabricatorRepositoryEncodingTransaction.php index ef129da832..203b98abec 100644 --- a/src/applications/repository/xaction/PhabricatorRepositoryEncodingTransaction.php +++ b/src/applications/repository/xaction/PhabricatorRepositoryEncodingTransaction.php @@ -1,68 +1,68 @@ <?php final class PhabricatorRepositoryEncodingTransaction extends PhabricatorRepositoryTransactionType { const TRANSACTIONTYPE = 'repo:encoding'; public function generateOldValue($object) { return $object->getDetail('encoding'); } public function applyInternalEffects($object, $value) { $object->setDetail('encoding', $value); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); - if (strlen($old) && !strlen($new)) { + if ($old !== null && $new === null) { return pht( '%s removed the %s encoding configured for this repository.', $this->renderAuthor(), $this->renderOldValue()); - } else if (strlen($new) && !strlen($old)) { + } else if ($new !== null && $old === null) { return pht( '%s set the encoding for this repository to %s.', $this->renderAuthor(), $this->renderNewValue()); } else { return pht( '%s changed the repository encoding from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } } public function validateTransactions($object, array $xactions) { $errors = array(); foreach ($xactions as $xaction) { // Make sure the encoding is valid by converting to UTF-8. This tests // that the user has mbstring installed, and also that they didn't // type a garbage encoding name. Note that we're converting from // UTF-8 to the target encoding, because mbstring is fine with // converting from a nonsense encoding. $encoding = $xaction->getNewValue(); if (!strlen($encoding)) { continue; } try { phutil_utf8_convert('.', $encoding, 'UTF-8'); } catch (Exception $ex) { $errors[] = $this->newInvalidError( pht( 'Repository encoding "%s" is not valid: %s', $encoding, $ex->getMessage()), $xaction); } } return $errors; } }