2013-07-09 02:06:49 +02:00
|
|
|
<?php
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht(
|
|
|
|
"Populating Legalpad Documents with titles, %s, and %s...\n",
|
|
|
|
'recentContributorPHIDs',
|
|
|
|
'contributorCounts');
|
2013-07-09 02:06:49 +02:00
|
|
|
$table = new LegalpadDocument();
|
|
|
|
$table->openTransaction();
|
|
|
|
|
|
|
|
foreach (new LiskMigrationIterator($table) as $document) {
|
|
|
|
$updated = false;
|
|
|
|
$id = $document->getID();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Document %d: ', $id);
|
2013-07-09 02:06:49 +02:00
|
|
|
if (!$document->getTitle()) {
|
|
|
|
$document_body = id(new LegalpadDocumentBody())
|
|
|
|
->loadOneWhere('phid = %s', $document->getDocumentBodyPHID());
|
|
|
|
$title = $document_body->getTitle();
|
|
|
|
$document->setTitle($title);
|
|
|
|
$updated = true;
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Added title: %s', $title)."\n";
|
2013-07-09 02:06:49 +02:00
|
|
|
} else {
|
|
|
|
echo "-\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$document->getContributorCount() ||
|
|
|
|
!$document->getRecentContributorPHIDs()) {
|
|
|
|
$updated = true;
|
2015-01-03 00:33:25 +01:00
|
|
|
$type = PhabricatorObjectHasContributorEdgeType::EDGECONST;
|
2013-07-09 02:06:49 +02:00
|
|
|
$contributors = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
|
|
$document->getPHID(),
|
|
|
|
$type);
|
|
|
|
$document->setRecentContributorPHIDs(array_slice($contributors, 0, 3));
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Added recent contributor PHIDs.')."\n";
|
2013-07-09 02:06:49 +02:00
|
|
|
$document->setContributorCount(count($contributors));
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Added contributor count.')."\n";
|
2013-07-09 02:06:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$updated) {
|
|
|
|
echo "-\n";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$document->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->saveTransaction();
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|