Page MenuHomePhorge

D25622.1737202925.diff
No OneTemporary

D25622.1737202925.diff

diff --git a/src/applications/auth/controller/PhabricatorAuthRegisterController.php b/src/applications/auth/controller/PhabricatorAuthRegisterController.php
--- a/src/applications/auth/controller/PhabricatorAuthRegisterController.php
+++ b/src/applications/auth/controller/PhabricatorAuthRegisterController.php
@@ -706,7 +706,7 @@
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- return $xform->executeTransform($file);
+ return $xform->executeTransformExplicit($file);
}
protected function renderError($message) {
diff --git a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
--- a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
+++ b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
@@ -66,7 +66,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php b/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
@@ -67,7 +67,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}
diff --git a/src/applications/files/transform/PhabricatorFileTransform.php b/src/applications/files/transform/PhabricatorFileTransform.php
--- a/src/applications/files/transform/PhabricatorFileTransform.php
+++ b/src/applications/files/transform/PhabricatorFileTransform.php
@@ -27,6 +27,30 @@
return $this->getDefaultTransform($file);
}
+ /**
+ * Wrapper of executeTransform() that also persists the relationship
+ * between the original file and the transform, if it has sense to do so.
+ */
+ public function executeTransformExplicit(PhabricatorFile $file) {
+ // This can be NULL.
+ $xform = $this->executeTransform($file);
+
+ // Connect the original file to its transform, if any.
+ // Skip transforms that are derived from a builtin as cautionary measure:
+ // - Builtins may have a lot of transforms. We don't know if the UX scales.
+ // Example page: /file/transforms/1/
+ // - Tracking builtins gives unclear benefits.
+ if ($xform && !$file->isBuiltin()) {
+ id(new PhabricatorTransformedFile())
+ ->setOriginalPHID($file->getPHID())
+ ->setTransformedPHID($xform->getPHID())
+ ->setTransform($this->getTransformKey())
+ ->save();
+ }
+
+ return $xform;
+ }
+
public static function getAllTransforms() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
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
@@ -30,14 +30,7 @@
// 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();
+ ->executeTransformExplicit($file);
$object->setProperty('cover.filePHID', $file->getPHID());
$object->setProperty('cover.thumbnailPHID', $xform->getPHID());
diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
@@ -69,7 +69,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
--- a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
+++ b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
@@ -66,7 +66,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}
diff --git a/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php b/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
--- a/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
+++ b/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
@@ -56,7 +56,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}
diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
--- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
@@ -68,7 +68,7 @@
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
- $xformed = $xform->executeTransform($file);
+ $xformed = $xform->executeTransformExplicit($file);
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 18, 12:22 (12 h, 46 s ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116117
Default Alt Text
D25622.1737202925.diff (6 KB)

Event Timeline