Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2889542
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/resources/sql/autopatches/20180828.phriction.06.c.documentid.php b/resources/sql/autopatches/20180828.phriction.06.c.documentid.php
new file mode 100644
index 0000000000..474643d620
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.06.c.documentid.php
@@ -0,0 +1,20 @@
+<?php
+
+// See T13193. We're about to drop the "documentID" column, which is part of
+// a UNIQUE KEY. In MariaDB, we must first drop the "documentID" key or we get
+// into deep trouble.
+
+// There's no "IF EXISTS" modifier for "ALTER TABLE" so run this as a PHP patch
+// instead of an SQL patch.
+
+$table = new PhrictionContent();
+$conn = $table->establishConnection('w');
+
+try {
+ queryfx(
+ $conn,
+ 'ALTER TABLE %T DROP KEY documentID',
+ $table->getTableName());
+} catch (AphrontQueryException $ex) {
+ // Ignore.
+}
diff --git a/resources/sql/autopatches/20180828.phriction.07.documentkey.sql b/resources/sql/autopatches/20180828.phriction.07.documentkey.sql
new file mode 100644
index 0000000000..aea3c97130
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.07.documentkey.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_content
+ ADD UNIQUE KEY `key_version` (documentPHID, version);
diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php
index 287974715f..5c597ab885 100644
--- a/src/applications/phriction/storage/PhrictionContent.php
+++ b/src/applications/phriction/storage/PhrictionContent.php
@@ -1,139 +1,139 @@
<?php
final class PhrictionContent
extends PhrictionDAO
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface,
PhabricatorConduitResultInterface {
protected $documentPHID;
protected $version;
protected $authorPHID;
protected $title;
protected $slug;
protected $content;
protected $description;
protected $changeType;
protected $changeRef;
private $document = self::ATTACHABLE;
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'version' => 'uint32',
'title' => 'sort',
'slug' => 'text128',
'content' => 'text',
'changeType' => 'uint32',
'changeRef' => 'uint32?',
'description' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
- 'documentID' => array(
+ 'key_version' => array(
'columns' => array('documentPHID', 'version'),
'unique' => true,
),
'authorPHID' => array(
'columns' => array('authorPHID'),
),
'slug' => array(
'columns' => array('slug'),
),
),
) + parent::getConfiguration();
}
public function getPHIDType() {
return PhrictionContentPHIDType::TYPECONST;
}
public function newRemarkupView(PhabricatorUser $viewer) {
return id(new PHUIRemarkupView($viewer, $this->getContent()))
->setContextObject($this)
->setRemarkupOption(PHUIRemarkupView::OPTION_GENERATE_TOC, true)
->setGenerateTableOfContents(true);
}
public function attachDocument(PhrictionDocument $document) {
$this->document = $document;
return $this;
}
public function getDocument() {
return $this->assertAttached($this->document);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
return PhabricatorPolicies::getMostOpenPolicy();
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */
public function getExtendedPolicy($capability, PhabricatorUser $viewer) {
return array(
array($this->getDocument(), PhabricatorPolicyCapability::CAN_VIEW),
);
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->delete();
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('documentPHID')
->setType('phid')
->setDescription(pht('Document this content is for.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('version')
->setType('int')
->setDescription(pht('Content version.')),
);
}
public function getFieldValuesForConduit() {
return array(
'documentPHID' => $this->getDocument()->getPHID(),
'version' => (int)$this->getVersion(),
);
}
public function getConduitSearchAttachments() {
return array(
id(new PhrictionContentSearchEngineAttachment())
->setAttachmentKey('content'),
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 12:19 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1124485
Default Alt Text
(5 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment