DRAFT - throw together Phurl skeleton.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Maniphest Tasks
- T6049: Implement Phurl, a URL shortener/bookmarking application
- Commits
- Restricted Diffusion Commit
rP930b6fec253b: DRAFT - throw together Phurl skeleton.
The idea is that some/long/url will become install/Udet4d and can be viewed and edited at install/Udet4d/view and install/Udet4d/edit, respectively?
Diff Detail
- Repository
- rP Phabricator
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
| src/applications/phurl/storage/PhabricatorPhurlURL.php | ||
|---|---|---|
| 34 | This is causing the "duplicate unique key error", by giving every URL the same PHID as the URL's author. | |
Only major thing I caught is that getPHID(), which is the PHID of the URL itself and looks like PHID-PHRL-abcdef is being used interchangeably with a property like authorPHID which isn't actually defined (and should look like PHID-USER-qwerty). You'd store the PHID of the user who created the URL in this property. To add it:
- Add authorPHID VARBINARY(64) NOT NULL to the table.
- Add an authorPHID property to the URL object.
- In initializeNewURL(), do setAuthorPHID($actor->getPHID()).
- Add a withAuthorPHIDs(...) method to the Query.
- Use withAuthorPHIDs() in the SearchEngine.
- If you implement author-based subscription or policy rules, use getAuthorPHID() to get the relevant user PHID, instead of getPHID().
| resources/sql/autopatches/20150721.phurl.url.1.sql | ||
|---|---|---|
| 4 ↗ | (On Diff #33073) | Whatever we use as name/alias/code should have a UNIQUE KEY on it. |
| 5–6 ↗ | (On Diff #33068) | description and longURL be LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, not VARCHAR(2047). |
| src/applications/phurl/application/PhabricatorPhurlApplication.php | ||
| 38 | This is correct/desirable. | |
| 43–44 | This one probably won't exist (just /U123 instead). | |
| 47 | We probably don't need sequence in this app | |
| src/applications/phurl/controller/PhabricatorPhurlURLEditController.php | ||
| 7–27 | Prefer to simplify this as: $id = $request->getURIData('id');
$is_create = !$id; | |
| 32 | Probably unused. | |
| 56 | Probably just /U123. | |
| 108–112 | Prefer $view_policy / $edit_policy for consistency. | |
| 131 | This needs ->setURL('/U1234'). We could also fix RedirectResponse to throw a better error if you forget to do this. | |
| src/applications/phurl/controller/PhabricatorPhurlURLViewController.php | ||
| 17 | Prefer handleRequest(AphrontRequest $request) + $id = $request->getURIData('id'); to simplify this stuff slightly. | |
| 19 | Prefer $this->getViewer(). | |
| 31–34 | (You could implement $url->getMonogram() to return U123 if you want to simplify this a little.) | |
| 31–34 | Oh, you already did. Consider using getMonogram() and getURI() to simplify slightly. | |
| 95 | Prefer $this->getViewer(). | |
| 99 | getApplicationURI() prepends the phurl/ part, this should just be /U123 (not `getApplicationURI()). | |
| 112 | I'd expect this to end up pointing at /phurl/phurl/, the leading phurl should be redundant. | |
| src/applications/phurl/editor/PhabricatorPhurlURLEditor.php | ||
| 66 | Debugging leftovers. | |
| 91–110 | I think you can just omit these methods, you aren't required to implement them if you don't have any behaviors you need to activate. | |
| src/applications/phurl/query/PhabricatorPhurlURLQuery.php | ||
| 36–46 | You shouldn't need this, the id column is automatically orderable. | |
| 55–71 | You should be able to implement this as return $this->loadStandardPage($this->newResultObject()) now. | |
| 73 | In modern code, implement buildWhereClauseParts(AphrontDatabaseConnection $conn) instead. This is a similar method but gets you more stuff "for free". | |
| 76 | Prefer to test the explicitly against !== null. For example: if ($this->ids !== null) This makes $query->withIDs(array()) fail in a relatively obvious way, instead of loading all results (which can cause non-obvious infinite loops / hangs once an install has millions of objects). | |
| 104 | Particualrly, you get this (and some other similar auto-includes) "free" when you implement buildWhereClauseParts() instead of buildWhereClause(). | |
| 113–115 | You should be able to just omit this, since this Query class doesn't do anything unusual. The default behavior will work properly. | |
| 122–124 | You should be able to omit this as unused. | |
| src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php | ||
| 19–21 | Seems fine/desirable to show the order field in this app? | |
| 34 | Unused. | |
| 37 | This isn't correct -- it finds URLs with the given PHIDs (always empty), not URLs authored by specific users. | |
| 71–79 | In modern code, just omit this. | |
| 89 | Instead, load handles here: $handles = $viewer->loadHandles(mpull($url, 'getUserPHID')); | |
| 91 | Unused. | |
| 96 | Omit render() if possible, not sure if you can. | |
| 108–110 | You can omit this, this is the default behavior. | |
| src/applications/phurl/storage/PhabricatorPhurlURL.php | ||
| 7 | MarkupInterface probably isn't worth implementing. This change doesn't do anything with it, in particular. | |
| 54–55 | These properties don't actually exist. | |
| 86–131 | Yeah, I'd just junk this. | |
| 152–162 | Since we have full edit policy support, maybe just no automatic capabilities for these? It doesn't seem to me like the author of a URL has a strong, enduring relationship which should give them permanent control over it. | |
| 153 | This PHID is the PHID of the URL, not of the author, so the policy is meaningless. | |
| 164–168 | Describing the wrong application. | |
| 196 | This will auto-subscribe the URL to itself, which doesn't make much sense. If we want to give authors long-term, enduring relationships to URLs they create, this should do return ($phid == $this->getAuthorPHID()). If not, just return false;. | |
| 211 | Property doesn't exist. | |
| src/applications/phurl/storage/PhabricatorPhurlURLTransaction.php | ||
| 85 | Add period for consistency. Since this transaction is always hidden, you could just omit this branch. | |
Some nits, but I think this is basically good to go if you want to land this chunk first.
| src/applications/phurl/application/PhabricatorPhurlApplication.php | ||
|---|---|---|
| 26–30 | (Remove sooner or later.) | |
| 45 | Should have a trailing slash. | |
| src/applications/phurl/controller/PhabricatorPhurlController.php | ||
| 9–14 | (Cruft.) | |
| src/applications/phurl/controller/PhabricatorPhurlURLEditController.php | ||
| 7 | Remove. | |
| 32 | Just use $id. | |
| 126 | Or $url->getURI() now. | |
| 190–191 | I think these are copy/pasted out of something (Calendar?) and not used in this workflow. | |
| 224 | Or getMonogram() / getURI(). | |
| 225 | In the else case here, I think most applications just add an addTextCrumb(pht('Create URL')) or something like that. | |
| src/applications/phurl/controller/PhabricatorPhurlURLViewController.php | ||
| 31–34 | (You could implement $url->getMonogram() to return U123 if you want to simplify this a little.) | |
| 72 | Or $this->getViewer(). | |
| 73 | Unused. | |
| 90 | Unused. | |
| 114 | Or $this->getViewer(). | |
| 120 | Maybe put this after "original URL"? It will cause stuff like "Projects" and "Subscribers" to populate when you invoke it, keeping them above "Description", which is likely desirable. | |
| src/applications/phurl/editor/PhabricatorPhurlURLEditor.php | ||
| 98 | I favor making this optional at some point, but not important for now. | |
| 177–180 | Cruft / TODO? | |
| src/applications/phurl/phid/PhabricatorPhurlURLPHIDType.php | ||
| 41 | Could simplify slightly with getMonogram() | |
| src/applications/phurl/query/PhabricatorPhurlURLQuery.php | ||
| 37 | "$autho" should be "$author" | |
| 53–70 | Cruft? | |
| 102 | Prefer explicit !== null. | |
| src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php | ||
| 23–37 | Consider "Author" language for consistency. | |
| src/applications/phurl/storage/PhabricatorPhurlURL.php | ||
| 58–59 | Since we let you query by authorPHID, you could also add a key here to improve the performance of that query: 'key_author' => array(
'columns' => array('authorPHID'),
),That will make queries with a WHERE authorPHID IN (...) part (and no better key) faster. | |
| src/applications/phurl/storage/PhabricatorPhurlURLTransaction.php | ||
| 11–13 | Cruft / TODO? | |