Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93609664
20130820.file-mailkey-populate.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
Sat, Nov 30, 03:32
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 03:32 (2 d)
Engine
blob
Format
Raw Data
Handle
22673430
Attached To
rPH Phabricator
20130820.file-mailkey-populate.php
View Options
<?php
echo
pht
(
'Populating Phabricator files with mail keys xactions...'
).
"
\n
"
;
$table
=
new
PhabricatorFile
();
$table_name
=
$table
->
getTableName
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
$conn_w
->
openTransaction
();
$sql
=
array
();
foreach
(
new
LiskRawMigrationIterator
(
$conn_w
,
'file'
)
as
$row
)
{
// NOTE: MySQL requires that the INSERT specify all columns which don't
// have default values when configured in strict mode. This query will
// never actually insert rows, but we need to hand it values anyway.
$sql
[]
=
qsprintf
(
$conn_w
,
'(%d, %s, 0, 0, 0, 0, 0, 0, 0, 0)'
,
$row
[
'id'
],
Filesystem
::
readRandomCharacters
(
20
));
}
if
(
$sql
)
{
foreach
(
PhabricatorLiskDAO
::
chunkSQL
(
$sql
,
', '
)
as
$chunk
)
{
queryfx
(
$conn_w
,
'INSERT INTO %T
(id, mailKey, phid, byteSize, storageEngine, storageFormat,
storageHandle, dateCreated, dateModified, metadata) VALUES %Q '
.
'ON DUPLICATE KEY UPDATE mailKey = VALUES(mailKey)'
,
$table_name
,
$chunk
);
}
}
$table
->
saveTransaction
();
echo
pht
(
'Done.'
).
"
\n
"
;
Event Timeline
Log In to Comment