1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00
phorge-phorge/resources/sql/patches/20130703.legalpaddocdenorm.php
Joshua Spence 36e2d02d6e phtize all the things
Summary: `pht`ize a whole bunch of strings in rP.

Test Plan: Intense eyeballing.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: hach-que, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12797
2015-05-22 21:16:39 +10:00

48 lines
1.3 KiB
PHP

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