@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix fatal on logged out Phame Post

Summary: Just deletes the view code until I have time to better plan this out, or just not ship.

Test Plan: Visit Phame post on public logged out page, view count doesnt cause transaction fatal.

Reviewers: epriestley

Reviewed By: epriestley

Spies: Korvin

Differential Revision: https://secure.phabricator.com/D18475

+3 -60
+2
resources/sql/autopatches/20170825.phame.01.post.views.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phame.phame_post 2 + DROP COLUMN views;
-2
src/__phutil_library_map__.php
··· 4421 4421 'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php', 4422 4422 'PhamePostTransactionType' => 'applications/phame/xaction/PhamePostTransactionType.php', 4423 4423 'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php', 4424 - 'PhamePostViewsTransaction' => 'applications/phame/xaction/PhamePostViewsTransaction.php', 4425 4424 'PhamePostVisibilityTransaction' => 'applications/phame/xaction/PhamePostVisibilityTransaction.php', 4426 4425 'PhameSchemaSpec' => 'applications/phame/storage/PhameSchemaSpec.php', 4427 4426 'PhameSite' => 'applications/phame/site/PhameSite.php', ··· 10054 10053 'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 10055 10054 'PhamePostTransactionType' => 'PhabricatorModularTransactionType', 10056 10055 'PhamePostViewController' => 'PhameLiveController', 10057 - 'PhamePostViewsTransaction' => 'PhamePostTransactionType', 10058 10056 'PhamePostVisibilityTransaction' => 'PhamePostTransactionType', 10059 10057 'PhameSchemaSpec' => 'PhabricatorConfigSchemaSpec', 10060 10058 'PhameSite' => 'PhabricatorSite',
-24
src/applications/phame/controller/post/PhamePostViewController.php
··· 18 18 $is_live = $this->getIsLive(); 19 19 $is_external = $this->getIsExternal(); 20 20 21 - // Register a blog "view" count 22 - // 23 - if (!$post->isDraft() && !$post->isArchived()) { 24 - $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 25 - $xactions = array(); 26 - $xactions[] = id(new PhamePostTransaction()) 27 - ->setTransactionType(PhamePostViewsTransaction::TRANSACTIONTYPE) 28 - ->setNewValue(null); 29 - 30 - $editor = id(new PhamePostEditor()) 31 - ->setActor($viewer) 32 - ->setContentSourceFromRequest($request) 33 - ->setContinueOnMissingFields(true) 34 - ->setContinueOnNoEffect(true); 35 - 36 - $editor->applyTransactions($post, $xactions); 37 - unset($unguarded); 38 - } 39 - 40 21 $header = id(new PHUIHeaderView()) 41 22 ->addClass('phame-header-bar') 42 23 ->setUser($viewer); ··· 169 150 $properties = id(new PHUIPropertyListView()) 170 151 ->setUser($viewer) 171 152 ->setObject($post); 172 - 173 - $views = id(new PhutilNumber($post->getViews())); 174 - $properties->addProperty( 175 - pht('Views'), 176 - pht('%s', $views)); 177 153 178 154 $is_live = $this->getIsLive(); 179 155 $is_external = $this->getIsExternal();
-12
src/applications/phame/editor/PhamePostEditor.php
··· 32 32 if ($object->isDraft() || ($object->isArchived())) { 33 33 return false; 34 34 } 35 - foreach ($xactions as $xaction) { 36 - switch ($xaction->getTransactionType()) { 37 - case PhamePostViewsTransaction::TRANSACTIONTYPE: 38 - return false; 39 - } 40 - } 41 35 return true; 42 36 } 43 37 ··· 46 40 array $xactions) { 47 41 if ($object->isDraft() || $object->isArchived()) { 48 42 return false; 49 - } 50 - foreach ($xactions as $xaction) { 51 - switch ($xaction->getTransactionType()) { 52 - case PhamePostViewsTransaction::TRANSACTIONTYPE: 53 - return false; 54 - } 55 43 } 56 44 return true; 57 45 }
+1 -4
src/applications/phame/storage/PhamePost.php
··· 22 22 protected $phameTitle; 23 23 protected $body; 24 24 protected $visibility; 25 - protected $views; 26 25 protected $configData; 27 26 protected $datePublished; 28 27 protected $blogPHID; ··· 41 40 ->setBlogPHID($blog->getPHID()) 42 41 ->attachBlog($blog) 43 42 ->setDatePublished(PhabricatorTime::getNow()) 44 - ->setVisibility(PhameConstants::VISIBILITY_PUBLISHED) 45 - ->setViews(0); 43 + ->setVisibility(PhameConstants::VISIBILITY_PUBLISHED); 46 44 47 45 return $post; 48 46 } ··· 130 128 'subtitle' => 'text64', 131 129 'phameTitle' => 'sort64?', 132 130 'visibility' => 'uint32', 133 - 'views' => 'uint32', 134 131 'mailKey' => 'bytes20', 135 132 'headerImagePHID' => 'phid?', 136 133
-18
src/applications/phame/xaction/PhamePostViewsTransaction.php
··· 1 - <?php 2 - 3 - final class PhamePostViewsTransaction 4 - extends PhamePostTransactionType { 5 - 6 - const TRANSACTIONTYPE = 'phame.post.views'; 7 - 8 - public function generateOldValue($object) { 9 - return $object->getViews(); 10 - } 11 - 12 - public function applyInternalEffects($object, $value) { 13 - $views = $object->getViews(); 14 - $views++; 15 - $object->setViews($views); 16 - } 17 - 18 - }