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:38XHP63Useless Overriding Method
Unit
Tests Passed
Build Status
Buildable 7355
Build 7750: [Placeholder Plan] Wait for 30 Seconds
Build 7749: 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

Whatever we use as name/alias/code should have a UNIQUE KEY on it.

6–7

description and longURL be LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}, not VARCHAR(2047).

src/applications/phurl/application/PhabricatorPhurlApplication.php
37

This is correct/desirable.

42–43

This one probably won't exist (just /U123 instead).

46

We probably don't need sequence in this app

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

Prefer to simplify this as:

$id = $request->getURIData('id');
$is_create = !$id;
31

Probably unused.

55

Probably just /U123.

107–111

Prefer $view_policy / $edit_policy for consistency.

130

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
16

Prefer handleRequest(AphrontRequest $request) + $id = $request->getURIData('id'); to simplify this stuff slightly.

18

Prefer $this->getViewer().

30–33

(You could implement $url->getMonogram() to return U123 if you want to simplify this a little.)

30–33

Oh, you already did. Consider using getMonogram() and getURI() to simplify slightly.

94

Prefer $this->getViewer().

98

getApplicationURI() prepends the phurl/ part, this should just be /U123 (not `getApplicationURI()).

111

I'd expect this to end up pointing at /phurl/phurl/, the leading phurl should be redundant.

src/applications/phurl/editor/PhabricatorPhurlURLEditor.php
65

Debugging leftovers.

90–109

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
35–45

You shouldn't need this, the id column is automatically orderable.

54–70

You should be able to implement this as return $this->loadStandardPage($this->newResultObject()) now.

72

In modern code, implement buildWhereClauseParts(AphrontDatabaseConnection $conn) instead. This is a similar method but gets you more stuff "for free".

75

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

103

Particualrly, you get this (and some other similar auto-includes) "free" when you implement buildWhereClauseParts() instead of buildWhereClause().

112–114

You should be able to just omit this, since this Query class doesn't do anything unusual. The default behavior will work properly.

121–123

You should be able to omit this as unused.

src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php
18–20

Seems fine/desirable to show the order field in this app?

33

Unused.

36

This isn't correct -- it finds URLs with the given PHIDs (always empty), not URLs authored by specific users.

70–78

In modern code, just omit this.

88

Instead, load handles here:

$handles = $viewer->loadHandles(mpull($url, 'getUserPHID'));
90

Unused.

95

Omit render() if possible, not sure if you can.

107–109

You can omit this, this is the default behavior.

src/applications/phurl/storage/PhabricatorPhurlURL.php
6

MarkupInterface probably isn't worth implementing. This change doesn't do anything with it, in particular.

53–54

These properties don't actually exist.

85–130

Yeah, I'd just junk this.

151–161

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.

152

This PHID is the PHID of the URL, not of the author, so the policy is meaningless.

163–167

Describing the wrong application.

195

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

210

Property doesn't exist.

src/applications/phurl/storage/PhabricatorPhurlURLTransaction.php
84

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
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
30–33

(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?

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.