Page MenuHomePhabricator

Drop domain key on PhameBlog
ClosedPublic

Authored by chad on Dec 30 2015, 8:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 23, 5:48 AM
Unknown Object (File)
Wed, Mar 20, 2:30 PM
Unknown Object (File)
Tue, Mar 5, 5:19 PM
Unknown Object (File)
Tue, Mar 5, 5:19 PM
Unknown Object (File)
Tue, Mar 5, 5:19 PM
Unknown Object (File)
Tue, Mar 5, 5:19 PM
Unknown Object (File)
Tue, Mar 5, 5:19 PM
Unknown Object (File)
Tue, Mar 5, 3:52 AM
Subscribers

Details

Reviewers
epriestley
Maniphest Tasks
T9360: Unbeta Phame
Commits
Restricted Diffusion Commit
rP4acb7f63e85c: Drop domain key on PhameBlog
Summary

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 cat.dog as domain name, get duplicate domain error.

Diff Detail

Repository
rP Phabricator
Branch
phame-domain-key (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 9864
Build 11886: Run Core Tests
Build 11885: arc lint + arc unit

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 cat.dog 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.