Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2680770
D25475.1734622677.diff
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
3 KB
Referenced Files
None
Subscribers
None
D25475.1734622677.diff
View Options
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -1414,11 +1414,27 @@
/**
* Write the policy edge between this file and some object.
+ * This method is successful even if the file is already attached.
*
* @param phid Object PHID to attach to.
* @return this
*/
public function attachToObject($phid) {
+ self::attachFileToObject($this->getPHID(), $phid);
+ return $this;
+ }
+
+ /**
+ * Write the policy edge between a file and some object.
+ * This method is successful even if the file is already attached.
+ * NOTE: Please avoid to use this static method directly.
+ * Instead, use PhabricatorFile#attachToObject(phid).
+ *
+ * @param phid File PHID to attach from.
+ * @param phid Object PHID to attach to.
+ * @return void
+ */
+ public static function attachFileToObject($file_phid, $object_phid) {
$attachment_table = new PhabricatorFileAttachment();
$attachment_conn = $attachment_table->establishConnection('w');
@@ -1432,14 +1448,12 @@
attacherPHID = VALUES(attacherPHID),
dateModified = VALUES(dateModified)',
$attachment_table,
- $phid,
- $this->getPHID(),
+ $object_phid,
+ $file_phid,
PhabricatorFileAttachment::MODE_ATTACH,
null,
PhabricatorTime::getNow(),
PhabricatorTime::getNow());
-
- return $this;
}
diff --git a/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
--- a/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskCoverImageTransaction.php
@@ -27,14 +27,31 @@
return;
}
+ // Generate an image transformation, usually smaller (orphan now).
$xform_key = PhabricatorFileThumbnailTransform::TRANSFORM_WORKCARD;
$xform = PhabricatorFileTransform::getTransformByKey($xform_key)
->executeTransform($file);
+ // Make that image transformation non-orphan.
+ id(new PhabricatorTransformedFile())
+ ->setOriginalPHID($file_phid)
+ ->setTransformedPHID($xform->getPHID())
+ ->setTransform($xform_key)
+ ->save();
+
$object->setProperty('cover.filePHID', $file->getPHID());
$object->setProperty('cover.thumbnailPHID', $xform->getPHID());
}
+ public function applyExternalEffects($object, $value) {
+ // If the File has a Cover Image, attach that as side-effect.
+ // Otherwise, the Cover Image may be invisible to participants.
+ $file_phid = $object->getProperty('cover.filePHID');
+ if ($file_phid) {
+ PhabricatorFile::attachFileToObject($file_phid, $object->getPHID());
+ }
+ }
+
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
diff --git a/src/applications/project/controller/PhabricatorProjectCoverController.php b/src/applications/project/controller/PhabricatorProjectCoverController.php
--- a/src/applications/project/controller/PhabricatorProjectCoverController.php
+++ b/src/applications/project/controller/PhabricatorProjectCoverController.php
@@ -35,6 +35,7 @@
$xactions = array();
+ // Set the new Cover Image.
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskCoverImageTransaction::TRANSACTIONTYPE)
->setNewValue($file->getPHID());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 15:37 (9 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015139
Default Alt Text
D25475.1734622677.diff (3 KB)
Attached To
Mode
D25475: Drag & Drop Task Cover Image: also attach
Attached
Detach File
Event Timeline
Log In to Comment