Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80230495
20141107.ssh.4.keymig.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
Fri, Aug 30, 14:20
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Sep 1, 14:20 (2 d)
Engine
blob
Format
Raw Data
Handle
20323853
Attached To
rPH Phabricator
20141107.ssh.4.keymig.php
View Options
<?php
$table
=
new
PhabricatorAuthSSHKey
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
echo
pht
(
'Updating SSH public key indexes...'
).
"
\n
"
;
$keys
=
new
LiskMigrationIterator
(
$table
);
foreach
(
$keys
as
$key
)
{
$id
=
$key
->
getID
();
echo
pht
(
'Updating key %d...'
,
$id
).
"
\n
"
;
try
{
$hash
=
$key
->
toPublicKey
()->
getHash
();
}
catch
(
Exception
$ex
)
{
echo
pht
(
'Key has bad format! Removing key.'
).
"
\n
"
;
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id = %d'
,
$table
->
getTableName
(),
$id
);
continue
;
}
$collision
=
queryfx_all
(
$conn_w
,
'SELECT * FROM %T WHERE keyIndex = %s AND id < %d'
,
$table
->
getTableName
(),
$hash
,
$key
->
getID
());
if
(
$collision
)
{
echo
pht
(
'Key is a duplicate! Removing key.'
).
"
\n
"
;
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id = %d'
,
$table
->
getTableName
(),
$id
);
continue
;
}
queryfx
(
$conn_w
,
'UPDATE %T SET keyIndex = %s WHERE id = %d'
,
$table
->
getTableName
(),
$hash
,
$key
->
getID
());
}
echo
pht
(
'Done.'
).
"
\n
"
;
Event Timeline
Log In to Comment