[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 echo 'Populating Legalpad Documents with ', 4 "titles, recentContributorPHIDs, and contributorCounts...\n"; 5 $table = new LegalpadDocument(); 6 $table->openTransaction(); 7 8 foreach (new LiskMigrationIterator($table) as $document) { 9 $updated = false; 10 $id = $document->getID(); 11 12 echo "Document {$id}: "; 13 if (!$document->getTitle()) { 14 $document_body = id(new LegalpadDocumentBody()) 15 ->loadOneWhere('phid = %s', $document->getDocumentBodyPHID()); 16 $title = $document_body->getTitle(); 17 $document->setTitle($title); 18 $updated = true; 19 echo "Added title: $title\n"; 20 } else { 21 echo "-\n"; 22 } 23 24 if (!$document->getContributorCount() || 25 !$document->getRecentContributorPHIDs()) { 26 $updated = true; 27 $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR; 28 $contributors = PhabricatorEdgeQuery::loadDestinationPHIDs( 29 $document->getPHID(), 30 $type); 31 $document->setRecentContributorPHIDs(array_slice($contributors, 0, 3)); 32 echo "Added recent contributor phids.\n"; 33 $document->setContributorCount(count($contributors)); 34 echo "Added contributor count.\n"; 35 } 36 37 if (!$updated) { 38 echo "-\n"; 39 continue; 40 } 41 42 $document->save(); 43 } 44 45 $table->saveTransaction(); 46 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 |