Page MenuHomePhabricator

Drop domain key on PhameBlog

Authored by chad on Dec 30 2015, 8:30 PM.


Maniphest Tasks
T9360: Unbeta Phame
Restricted Diffusion Commit
rP4acb7f63e85c: Drop domain key on PhameBlog

Right now you can't create two blogs without a domain name, since it has a unique key on the column. Removing the key.

Test Plan

Create two blogs with no domain name, works as expected. Create two blogs with as domain name, get duplicate domain error.

Diff Detail

rP Phabricator
Lint Not Applicable
Tests Not Applicable

Event Timeline

chad retitled this revision from to Drop domain key on PhameBlog.
chad updated this object.
chad edited the test plan for this revision. (Show Details)
chad added a reviewer: epriestley.

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 blogs if they're fast/sneaky enough, by creating them simultaneously and racing against the existence check.

chad edited edge metadata.
  • update per comments
epriestley edited edge metadata.
This revision is now accepted and ready to land.Dec 30 2015, 8:54 PM
This revision was automatically updated to reflect the committed changes.