[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 echo "Moving Slowvote comments to transactions...\n"; 4 5 $viewer = PhabricatorUser::getOmnipotentUser(); 6 7 $table_xaction = new PhabricatorSlowvoteTransaction(); 8 $table_comment = new PhabricatorSlowvoteTransactionComment(); 9 $conn_w = $table_xaction->establishConnection('w'); 10 11 $comments = new LiskRawMigrationIterator($conn_w, 'slowvote_comment'); 12 13 $conn_w->openTransaction(); 14 15 foreach ($comments as $comment) { 16 $id = $comment['id']; 17 $poll_id = $comment['pollID']; 18 $author_phid = $comment['authorPHID']; 19 $text = $comment['commentText']; 20 $date_created = $comment['dateCreated']; 21 $date_modified = $comment['dateModified']; 22 23 echo "Migrating comment {$id}.\n"; 24 25 $poll = id(new PhabricatorSlowvoteQuery()) 26 ->setViewer($viewer) 27 ->withIDs(array($poll_id)) 28 ->executeOne(); 29 if (!$poll) { 30 echo "No poll.\n"; 31 continue; 32 } 33 34 $user = id(new PhabricatorPeopleQuery()) 35 ->setViewer($viewer) 36 ->withPHIDs(array($author_phid)) 37 ->executeOne(); 38 if (!$user) { 39 echo "No user.\n"; 40 continue; 41 } 42 43 $comment_phid = PhabricatorPHID::generateNewPHID( 44 PhabricatorPHIDConstants::PHID_TYPE_XCMT); 45 $xaction_phid = PhabricatorPHID::generateNewPHID( 46 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST, 47 PhabricatorSlowvotePollPHIDType::TYPECONST); 48 49 $source = PhabricatorContentSource::newForSource( 50 PhabricatorContentSource::SOURCE_LEGACY, 51 array())->serialize(); 52 53 queryfx( 54 $conn_w, 55 'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy, 56 commentVersion, content, contentSource, isDeleted, 57 dateCreated, dateModified) 58 VALUES (%s, %s, %s, %s, %s, 59 %d, %s, %s, %d, 60 %d, %d)', 61 $table_comment->getTableName(), 62 $comment_phid, 63 $xaction_phid, 64 $user->getPHID(), 65 PhabricatorPolicies::POLICY_PUBLIC, 66 $user->getPHID(), 67 1, 68 $text, 69 $source, 70 0, 71 $date_created, 72 $date_modified); 73 74 queryfx( 75 $conn_w, 76 'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy, 77 commentPHID, commentVersion, transactionType, oldValue, newValue, 78 contentSource, metadata, dateCreated, dateModified) 79 VALUES (%s, %s, %s, %s, %s, 80 %s, %d, %s, %s, %s, 81 %s, %s, %d, %d)', 82 $table_xaction->getTableName(), 83 $xaction_phid, 84 $user->getPHID(), 85 $poll->getPHID(), 86 PhabricatorPolicies::POLICY_PUBLIC, 87 $user->getPHID(), 88 $comment_phid, 89 1, 90 PhabricatorTransactions::TYPE_COMMENT, 91 null, 92 null, 93 $source, 94 '{}', 95 $date_created, 96 $date_modified); 97 } 98 99 $conn_w->saveTransaction(); 100 101 echo "Done.\n";
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |