Right now you can't create two blogs without a domain name, since it has a unique key on the column. Removing the key.
Details
Details
- Reviewers
epriestley - Maniphest Tasks
- T9360: Unbeta Phame
- Commits
- Restricted Diffusion Commit
rP4acb7f63e85c: Drop domain key on PhameBlog
Create two blogs with no domain name, works as expected. Create two blogs with cat.dog as domain name, get duplicate domain error.
Diff Detail
Diff Detail
- Repository
- rP Phabricator
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
Does this fix it instead?
diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php index 3698293..c73c2be 100644 --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -47,9 +47,14 @@ final class PhameBlogEditor switch ($xaction->getTransactionType()) { case PhameBlogTransaction::TYPE_NAME: case PhameBlogTransaction::TYPE_DESCRIPTION: - case PhameBlogTransaction::TYPE_DOMAIN: case PhameBlogTransaction::TYPE_STATUS: return $xaction->getNewValue(); + case PhameBlogTransaction::TYPE_DOMAIN: + $domain = $xaction->getNewValue(); + if (!strlen($xaction->getNewValue())) { + return null; + } + return $domain; } }
A unique key allows multiple null values, just not multiple identical non-null values. I think blogs are getting their domain set to '' (empty string), which causes a unique key collision, when it should be null, which does not.
Removing this constraint will allow users to create two cat.dog blogs if they're fast/sneaky enough, by creating them simultaneously and racing against the existence check.