Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F464029
20130715.votecomments.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
20130715.votecomments.php
View Options
<?php
echo
pht
(
'Moving Slowvote comments to transactions...'
).
"
\n
"
;
$viewer
=
PhabricatorUser
::
getOmnipotentUser
();
$table_xaction
=
new
PhabricatorSlowvoteTransaction
();
$table_comment
=
new
PhabricatorSlowvoteTransactionComment
();
$conn_w
=
$table_xaction
->
establishConnection
(
'w'
);
$comments
=
new
LiskRawMigrationIterator
(
$conn_w
,
'slowvote_comment'
);
$conn_w
->
openTransaction
();
foreach
(
$comments
as
$comment
)
{
$id
=
$comment
[
'id'
];
$poll_id
=
$comment
[
'pollID'
];
$author_phid
=
$comment
[
'authorPHID'
];
$text
=
$comment
[
'commentText'
];
$date_created
=
$comment
[
'dateCreated'
];
$date_modified
=
$comment
[
'dateModified'
];
echo
pht
(
'Migrating comment %d.'
,
$id
).
"
\n
"
;
$poll
=
id
(
new
PhabricatorSlowvoteQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$poll_id
))
->
executeOne
();
if
(!
$poll
)
{
echo
pht
(
'No poll.'
).
"
\n
"
;
continue
;
}
$user
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$author_phid
))
->
executeOne
();
if
(!
$user
)
{
echo
pht
(
'No user.'
).
"
\n
"
;
continue
;
}
$comment_phid
=
PhabricatorPHID
::
generateNewPHID
(
PhabricatorPHIDConstants
::
PHID_TYPE_XCMT
);
$xaction_phid
=
PhabricatorPHID
::
generateNewPHID
(
PhabricatorApplicationTransactionTransactionPHIDType
::
TYPECONST
,
PhabricatorSlowvotePollPHIDType
::
TYPECONST
);
$source
=
PhabricatorContentSource
::
newForSource
(
PhabricatorContentSource
::
SOURCE_LEGACY
,
array
())->
serialize
();
queryfx
(
$conn_w
,
'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
commentVersion, content, contentSource, isDeleted,
dateCreated, dateModified)
VALUES (%s, %s, %s, %s, %s,
%d, %s, %s, %d,
%d, %d)'
,
$table_comment
->
getTableName
(),
$comment_phid
,
$xaction_phid
,
$user
->
getPHID
(),
PhabricatorPolicies
::
POLICY_PUBLIC
,
$user
->
getPHID
(),
1
,
$text
,
$source
,
0
,
$date_created
,
$date_modified
);
queryfx
(
$conn_w
,
'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy,
commentPHID, commentVersion, transactionType, oldValue, newValue,
contentSource, metadata, dateCreated, dateModified)
VALUES (%s, %s, %s, %s, %s,
%s, %d, %s, %s, %s,
%s, %s, %d, %d)'
,
$table_xaction
->
getTableName
(),
$xaction_phid
,
$user
->
getPHID
(),
$poll
->
getPHID
(),
PhabricatorPolicies
::
POLICY_PUBLIC
,
$user
->
getPHID
(),
$comment_phid
,
1
,
PhabricatorTransactions
::
TYPE_COMMENT
,
null
,
null
,
$source
,
'{}'
,
$date_created
,
$date_modified
);
}
$conn_w
->
saveTransaction
();
echo
pht
(
'Done.'
).
"
\n
"
;
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 8:32 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
73878
Default Alt Text
20130715.votecomments.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment