Page MenuHomePhabricator

DRAFT - throw together Phurl skeleton.
ClosedPublic

Authored by lpriestley on Jul 22 2015, 7:35 PM.
Tags
None
Referenced Files
F14058361: D13681.diff
Sun, Nov 17, 11:14 AM
F14057423: D13681.id33095.diff
Sun, Nov 17, 3:03 AM
F14057349: D13681.id33067.diff
Sun, Nov 17, 2:22 AM
F14030207: D13681.id33116.diff
Sat, Nov 9, 12:32 AM
F14029890: D13681.id33067.diff
Fri, Nov 8, 10:25 PM
F14029858: D13681.id.diff
Fri, Nov 8, 9:56 PM
F13983253: D13681.id33073.diff
Sun, Oct 20, 5:06 AM
F13976762: D13681.id33122.diff
Oct 18 2024, 3:36 PM
Tokens
"Evil Spooky Haunted Tree" token, awarded by epriestley."Doubloon" token, awarded by joshuaspence."Piece of Eight" token, awarded by chad.

Details

Summary

DRAFT - throw together Phurl skeleton.

Test Plan

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
Branch
phurlskeleton
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/applications/phurl/storage/PhabricatorPhurlURL.php:40XHP63Useless Overriding Method
Unit
Tests Passed
Build Status
Buildable 7369
Build 7778: [Placeholder Plan] Wait for 30 Seconds
Build 7777: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Side nav should reference the right search engine

Seems to fix the original datasource error

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.

epriestley edited edge metadata.

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.

This revision now requires changes to proceed.Jul 22 2015, 8:59 PM
lpriestley edited edge metadata.
lpriestley marked 40 inline comments as done.

Some cleanup

epriestley edited edge metadata.

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
25–29

(Remove sooner or later.)

44

Should have a trailing slash.

src/applications/phurl/controller/PhabricatorPhurlController.php
8–13

(Cruft.)

src/applications/phurl/controller/PhabricatorPhurlURLEditController.php
6

Remove.

31

Just use $id.

125

Or $url->getURI() now.

189–190

I think these are copy/pasted out of something (Calendar?) and not used in this workflow.

223

Or getMonogram() / getURI().

224

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.)

71

Or $this->getViewer().

72

Unused.

89

Unused.

113

Or $this->getViewer().

119

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
97

I favor making this optional at some point, but not important for now.

176–179

Cruft / TODO?

src/applications/phurl/phid/PhabricatorPhurlURLPHIDType.php
40

Could simplify slightly with getMonogram()

src/applications/phurl/query/PhabricatorPhurlURLQuery.php
36

"$autho" should be "$author"

52–69

Cruft?

101

Prefer explicit !== null.

src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php
22–36

Consider "Author" language for consistency.

src/applications/phurl/storage/PhabricatorPhurlURL.php
57–58

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
10–12

Cruft / TODO?

This revision now requires changes to proceed.Jul 23 2015, 8:52 PM
lpriestley edited edge metadata.
lpriestley marked 21 inline comments as done.

Cleaning up junk

epriestley edited edge metadata.
This revision is now accepted and ready to land.Jul 24 2015, 6:01 PM
This revision was automatically updated to reflect the committed changes.