1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

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
This commit is contained in:
Chad Little 2017-08-25 08:30:23 -07:00
parent 213e4ec9b5
commit 79c6b50049
6 changed files with 3 additions and 60 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phame.phame_post
DROP COLUMN views;

View file

@ -4421,7 +4421,6 @@ phutil_register_library_map(array(
'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php', 'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php',
'PhamePostTransactionType' => 'applications/phame/xaction/PhamePostTransactionType.php', 'PhamePostTransactionType' => 'applications/phame/xaction/PhamePostTransactionType.php',
'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php', 'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php',
'PhamePostViewsTransaction' => 'applications/phame/xaction/PhamePostViewsTransaction.php',
'PhamePostVisibilityTransaction' => 'applications/phame/xaction/PhamePostVisibilityTransaction.php', 'PhamePostVisibilityTransaction' => 'applications/phame/xaction/PhamePostVisibilityTransaction.php',
'PhameSchemaSpec' => 'applications/phame/storage/PhameSchemaSpec.php', 'PhameSchemaSpec' => 'applications/phame/storage/PhameSchemaSpec.php',
'PhameSite' => 'applications/phame/site/PhameSite.php', 'PhameSite' => 'applications/phame/site/PhameSite.php',
@ -10054,7 +10053,6 @@ phutil_register_library_map(array(
'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhamePostTransactionType' => 'PhabricatorModularTransactionType', 'PhamePostTransactionType' => 'PhabricatorModularTransactionType',
'PhamePostViewController' => 'PhameLiveController', 'PhamePostViewController' => 'PhameLiveController',
'PhamePostViewsTransaction' => 'PhamePostTransactionType',
'PhamePostVisibilityTransaction' => 'PhamePostTransactionType', 'PhamePostVisibilityTransaction' => 'PhamePostTransactionType',
'PhameSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PhameSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhameSite' => 'PhabricatorSite', 'PhameSite' => 'PhabricatorSite',

View file

@ -18,25 +18,6 @@ final class PhamePostViewController
$is_live = $this->getIsLive(); $is_live = $this->getIsLive();
$is_external = $this->getIsExternal(); $is_external = $this->getIsExternal();
// Register a blog "view" count
//
if (!$post->isDraft() && !$post->isArchived()) {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$xactions = array();
$xactions[] = id(new PhamePostTransaction())
->setTransactionType(PhamePostViewsTransaction::TRANSACTIONTYPE)
->setNewValue(null);
$editor = id(new PhamePostEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($post, $xactions);
unset($unguarded);
}
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->addClass('phame-header-bar') ->addClass('phame-header-bar')
->setUser($viewer); ->setUser($viewer);
@ -170,11 +151,6 @@ final class PhamePostViewController
->setUser($viewer) ->setUser($viewer)
->setObject($post); ->setObject($post);
$views = id(new PhutilNumber($post->getViews()));
$properties->addProperty(
pht('Views'),
pht('%s', $views));
$is_live = $this->getIsLive(); $is_live = $this->getIsLive();
$is_external = $this->getIsExternal(); $is_external = $this->getIsExternal();
$next_view = new PhameNextPostView(); $next_view = new PhameNextPostView();

View file

@ -32,12 +32,6 @@ final class PhamePostEditor
if ($object->isDraft() || ($object->isArchived())) { if ($object->isDraft() || ($object->isArchived())) {
return false; return false;
} }
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PhamePostViewsTransaction::TRANSACTIONTYPE:
return false;
}
}
return true; return true;
} }
@ -47,12 +41,6 @@ final class PhamePostEditor
if ($object->isDraft() || $object->isArchived()) { if ($object->isDraft() || $object->isArchived()) {
return false; return false;
} }
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case PhamePostViewsTransaction::TRANSACTIONTYPE:
return false;
}
}
return true; return true;
} }

View file

@ -22,7 +22,6 @@ final class PhamePost extends PhameDAO
protected $phameTitle; protected $phameTitle;
protected $body; protected $body;
protected $visibility; protected $visibility;
protected $views;
protected $configData; protected $configData;
protected $datePublished; protected $datePublished;
protected $blogPHID; protected $blogPHID;
@ -41,8 +40,7 @@ final class PhamePost extends PhameDAO
->setBlogPHID($blog->getPHID()) ->setBlogPHID($blog->getPHID())
->attachBlog($blog) ->attachBlog($blog)
->setDatePublished(PhabricatorTime::getNow()) ->setDatePublished(PhabricatorTime::getNow())
->setVisibility(PhameConstants::VISIBILITY_PUBLISHED) ->setVisibility(PhameConstants::VISIBILITY_PUBLISHED);
->setViews(0);
return $post; return $post;
} }
@ -130,7 +128,6 @@ final class PhamePost extends PhameDAO
'subtitle' => 'text64', 'subtitle' => 'text64',
'phameTitle' => 'sort64?', 'phameTitle' => 'sort64?',
'visibility' => 'uint32', 'visibility' => 'uint32',
'views' => 'uint32',
'mailKey' => 'bytes20', 'mailKey' => 'bytes20',
'headerImagePHID' => 'phid?', 'headerImagePHID' => 'phid?',

View file

@ -1,18 +0,0 @@
<?php
final class PhamePostViewsTransaction
extends PhamePostTransactionType {
const TRANSACTIONTYPE = 'phame.post.views';
public function generateOldValue($object) {
return $object->getViews();
}
public function applyInternalEffects($object, $value) {
$views = $object->getViews();
$views++;
$object->setViews($views);
}
}