Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96118771
20170316.rawfiles.01.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 22, 20:07
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 24, 20:07 (2 d)
Engine
blob
Format
Raw Data
Handle
23126624
Attached To
rPH Phabricator
20170316.rawfiles.01.php
View Options
<?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
];
}
}
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.
}
}
Event Timeline
Log In to Comment