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

Add storage for new audit transactions and comments

Summary:
Ref T4896. This adds the new storage, without any code changes.

This storage is substantially identical to the Differential storage, except that `changesetID` has been replaced by `pathID`.

I've retained the properties intended to be used to implement T1460. They might not be quite right, but at least we'll be able to make any fixes consistently to both applications. For now, these fields are empty and ignored.

Test Plan: Ran `./bin/storage upgrade`. Nothing calls this code yet.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T4896

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

+107
+19
resources/sql/autopatches/20140722.audit.1.xactions.sql
··· 1 + CREATE TABLE {$NAMESPACE}_audit.audit_transaction ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARCHAR(64) COLLATE utf8_bin NOT NULL, 4 + authorPHID VARCHAR(64) COLLATE utf8_bin NOT NULL, 5 + objectPHID VARCHAR(64) COLLATE utf8_bin NOT NULL, 6 + viewPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL, 7 + editPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL, 8 + commentPHID VARCHAR(64) COLLATE utf8_bin DEFAULT NULL, 9 + commentVersion INT UNSIGNED NOT NULL, 10 + transactionType VARCHAR(32) COLLATE utf8_bin NOT NULL, 11 + oldValue LONGTEXT COLLATE utf8_bin NOT NULL, 12 + newValue LONGTEXT COLLATE utf8_bin NOT NULL, 13 + contentSource LONGTEXT COLLATE utf8_bin NOT NULL, 14 + metadata LONGTEXT COLLATE utf8_bin NOT NULL, 15 + dateCreated INT UNSIGNED NOT NULL, 16 + dateModified INT UNSIGNED NOT NULL, 17 + UNIQUE KEY `key_phid` (`phid`), 18 + KEY `key_object` (`objectPHID`) 19 + ) ENGINE=InnoDB, COLLATE utf8_general_ci;
+29
resources/sql/autopatches/20140722.audit.2.comments.sql
··· 1 + CREATE TABLE {$NAMESPACE}_audit.audit_transaction_comment ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARCHAR(64) COLLATE utf8_bin NOT NULL, 4 + transactionPHID VARCHAR(64) COLLATE utf8_bin, 5 + authorPHID VARCHAR(64) COLLATE utf8_bin NOT NULL, 6 + viewPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL, 7 + editPolicy VARCHAR(64) COLLATE utf8_bin NOT NULL, 8 + commentVersion INT UNSIGNED NOT NULL, 9 + content longtext COLLATE utf8_bin NOT NULL, 10 + contentSource longtext COLLATE utf8_bin NOT NULL, 11 + isDeleted BOOL NOT NULL, 12 + dateCreated INT UNSIGNED NOT NULL, 13 + dateModified INT UNSIGNED NOT NULL, 14 + commitPHID VARCHAR(64) COLLATE utf8_bin, 15 + pathID INT UNSIGNED, 16 + isNewFile BOOL NOT NULL, 17 + lineNumber INT UNSIGNED NOT NULL, 18 + lineLength INT UNSIGNED NOT NULL, 19 + fixedState VARCHAR(12) COLLATE utf8_bin, 20 + hasReplies BOOL NOT NULL, 21 + replyToCommentPHID VARCHAR(64) COLLATE utf8_bin, 22 + legacyCommentID INT UNSIGNED, 23 + UNIQUE KEY `key_phid` (phid), 24 + UNIQUE KEY `key_version` (transactionPHID, commentVersion), 25 + KEY `key_path` (pathID), 26 + KEY `key_draft` (authorPHID, transactionPHID), 27 + KEY `key_commit` (commitPHID), 28 + KEY `key_legacy` (legacyCommentID) 29 + ) ENGINE=InnoDB, COLLATE utf8_general_ci;
+6
src/__phutil_library_map__.php
··· 1148 1148 'PhabricatorAuditPreviewController' => 'applications/audit/controller/PhabricatorAuditPreviewController.php', 1149 1149 'PhabricatorAuditReplyHandler' => 'applications/audit/mail/PhabricatorAuditReplyHandler.php', 1150 1150 'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php', 1151 + 'PhabricatorAuditTransaction' => 'applications/audit/storage/PhabricatorAuditTransaction.php', 1152 + 'PhabricatorAuditTransactionComment' => 'applications/audit/storage/PhabricatorAuditTransactionComment.php', 1153 + 'PhabricatorAuditTransactionQuery' => 'applications/audit/query/PhabricatorAuditTransactionQuery.php', 1151 1154 'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php', 1152 1155 'PhabricatorAuthApplication' => 'applications/auth/application/PhabricatorAuthApplication.php', 1153 1156 'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php', ··· 3940 3943 'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow', 3941 3944 'PhabricatorAuditPreviewController' => 'PhabricatorAuditController', 3942 3945 'PhabricatorAuditReplyHandler' => 'PhabricatorMailReplyHandler', 3946 + 'PhabricatorAuditTransaction' => 'PhabricatorApplicationTransaction', 3947 + 'PhabricatorAuditTransactionComment' => 'PhabricatorApplicationTransactionComment', 3948 + 'PhabricatorAuditTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 3943 3949 'PhabricatorAuthAccountView' => 'AphrontView', 3944 3950 'PhabricatorAuthApplication' => 'PhabricatorApplication', 3945 3951 'PhabricatorAuthAuthFactorPHIDType' => 'PhabricatorPHIDType',
+10
src/applications/audit/query/PhabricatorAuditTransactionQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuditTransactionQuery 4 + extends PhabricatorApplicationTransactionQuery { 5 + 6 + public function getTemplateApplicationTransaction() { 7 + return new PhabricatorAuditTransaction(); 8 + } 9 + 10 + }
+18
src/applications/audit/storage/PhabricatorAuditTransaction.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuditTransaction 4 + extends PhabricatorApplicationTransaction { 5 + 6 + public function getApplicationName() { 7 + return 'audit'; 8 + } 9 + 10 + public function getApplicationTransactionType() { 11 + return PhabricatorRepositoryCommitPHIDType::TYPECONST; 12 + } 13 + 14 + public function getApplicationTransactionCommentObject() { 15 + return new PhabricatorAuditTransactionComment(); 16 + } 17 + 18 + }
+25
src/applications/audit/storage/PhabricatorAuditTransactionComment.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuditTransactionComment 4 + extends PhabricatorApplicationTransactionComment { 5 + 6 + protected $commitPHID; 7 + protected $pathID; 8 + protected $isNewFile = 0; 9 + protected $lineNumber = 0; 10 + protected $lineLength = 0; 11 + protected $fixedState; 12 + protected $hasReplies = 0; 13 + protected $replyToCommentPHID; 14 + protected $legacyCommentID; 15 + 16 + public function getApplicationTransactionObject() { 17 + return new PhabricatorAuditTransaction(); 18 + } 19 + 20 + public function shouldUseMarkupCache($field) { 21 + // Only cache submitted comments. 22 + return ($this->getTransactionPHID() != null); 23 + } 24 + 25 + }