Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14356754
D17504.id42092.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17504.id42092.diff
View Options
diff --git a/resources/sql/autopatches/20170316.rawfiles.01.php b/resources/sql/autopatches/20170316.rawfiles.01.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170316.rawfiles.01.php
@@ -0,0 +1,57 @@
+<?php
+
+// Previously, files generated by "View Raw File" were written as permanent
+// files with excessively wide view permissions. This destroys these files
+// so they are recreated as temporary files with correct permissions when
+// next accessed.
+
+$table = new DifferentialChangeset();
+$conn = $table->establishConnection('w');
+$viewer = PhabricatorUser::getOmnipotentUser();
+
+$iterator = new LiskRawMigrationIterator(
+ $conn,
+ $table->getTableName());
+
+echo tsprintf(
+ "%s\n",
+ pht('Purging old raw changeset file caches...'));
+
+$keys = array(
+ 'raw:new:phid',
+ 'raw:old:phid',
+);
+
+foreach ($iterator as $changeset) {
+ try {
+ $metadata = phutil_json_decode($changeset['metadata']);
+
+ $phids = array();
+ foreach ($keys as $key) {
+ if (isset($metadata[$key])) {
+ $phids[] = $metadata[$key];
+ }
+ }
+
+ if ($phids) {
+ var_dump($phids);
+ }
+
+ foreach ($phids as $phid) {
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($phid))
+ ->executeOne();
+ if ($file) {
+ id(new PhabricatorDestructionEngine())
+ ->destroyObject($file);
+ }
+ }
+
+ // NOTE: We don't bother updating the changeset record itself: we already
+ // regenerate the cache properly if the stored value isn't valid.
+
+ } catch (Exception $ex) {
+ // Just move on if we run into trouble.
+ }
+}
diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php
--- a/src/applications/differential/controller/DifferentialChangesetViewController.php
+++ b/src/applications/differential/controller/DifferentialChangesetViewController.php
@@ -350,13 +350,19 @@
$data = $changeset->makeOldFile();
}
+ $diff = $changeset->getDiff();
+
$file = PhabricatorFile::newFromFileData(
$data,
array(
- 'name' => $changeset->getFilename(),
+ 'name' => $changeset->getFilename(),
'mime-type' => 'text/plain',
+ 'ttl' => phutil_units('24 hours in seconds'),
+ 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
));
+ $file->attachToObject($diff->getPHID());
+
$metadata[$key] = $file->getPHID();
$changeset->setMetadata($metadata);
$changeset->save();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 11:47 PM (12 h, 32 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6912276
Default Alt Text
D17504.id42092.diff (2 KB)
Attached To
Mode
D17504: Correct an issue where "View Raw File" in Differential generated a file with overbroad permissions
Attached
Detach File
Event Timeline
Log In to Comment