Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90987197
20140420.rel.2.objectmig.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
Wed, Nov 6, 16:41
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 8, 16:41 (2 d)
Engine
blob
Format
Raw Data
Handle
22161355
Attached To
rPH Phabricator
20140420.rel.2.objectmig.php
View Options
<?php
$pull_table
=
new
ReleephRequest
();
$table_name
=
$pull_table
->
getTableName
();
$conn_w
=
$pull_table
->
establishConnection
(
'w'
);
echo
pht
(
'Setting object PHIDs for requests...'
).
"
\n
"
;
foreach
(
new
LiskMigrationIterator
(
$pull_table
)
as
$pull
)
{
$id
=
$pull
->
getID
();
echo
pht
(
'Migrating pull request %d...'
,
$id
).
"
\n
"
;
if
(
$pull
->
getRequestedObjectPHID
())
{
// We already have a valid PHID, so skip this request.
continue
;
}
$commit_phids
=
$pull
->
getCommitPHIDs
();
if
(
count
(
$commit_phids
)
!=
1
)
{
// At the time this migration was written, all requests had exactly one
// commit. If a request has more than one, we don't have the information
// we need to process it.
continue
;
}
$commit_phid
=
head
(
$commit_phids
);
$revision_phids
=
PhabricatorEdgeQuery
::
loadDestinationPHIDs
(
$commit_phid
,
DiffusionCommitHasRevisionEdgeType
::
EDGECONST
);
if
(
$revision_phids
)
{
$object_phid
=
head
(
$revision_phids
);
}
else
{
$object_phid
=
$commit_phid
;
}
queryfx
(
$conn_w
,
'UPDATE %T SET requestedObjectPHID = %s WHERE id = %d'
,
$table_name
,
$object_phid
,
$id
);
}
echo
pht
(
'Done.'
).
"
\n
"
;
Event Timeline
Log In to Comment