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)
Wed, Dec 18, 12:47 AM
Unknown Object (File)
Mon, Dec 16, 1:18 AM
Unknown Object (File)
Fri, Dec 13, 3:31 AM
Unknown Object (File)
Sat, Dec 7, 6:17 PM
Unknown Object (File)
Wed, Nov 27, 3:37 PM
Unknown Object (File)
Nov 16 2024, 5:29 PM
Unknown Object (File)
Nov 10 2024, 9:55 AM
Unknown Object (File)
Nov 1 2024, 5:33 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
Lint
Lint Not Applicable
Unit
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 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.