Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98040603
20130703.legalpaddocdenorm.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 8, 23:55
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jan 10, 23:55 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23500456
Attached To
rPH Phabricator
20130703.legalpaddocdenorm.php
View Options
<?php
echo
"Populating Legalpad Documents with "
,
"titles, recentContributorPHIDs, and contributorCounts...
\n
"
;
$table
=
new
LegalpadDocument
();
$table
->
openTransaction
();
foreach
(
new
LiskMigrationIterator
(
$table
)
as
$document
)
{
$updated
=
false
;
$id
=
$document
->
getID
();
echo
"Document {$id}: "
;
if
(!
$document
->
getTitle
())
{
$document_body
=
id
(
new
LegalpadDocumentBody
())
->
loadOneWhere
(
'phid = %s'
,
$document
->
getDocumentBodyPHID
());
$title
=
$document_body
->
getTitle
();
$document
->
setTitle
(
$title
);
$updated
=
true
;
echo
"Added title: $title
\n
"
;
}
else
{
echo
"-
\n
"
;
}
if
(!
$document
->
getContributorCount
()
||
!
$document
->
getRecentContributorPHIDs
())
{
$updated
=
true
;
$type
=
PhabricatorEdgeConfig
::
TYPE_OBJECT_HAS_CONTRIBUTOR
;
$contributors
=
PhabricatorEdgeQuery
::
loadDestinationPHIDs
(
$document
->
getPHID
(),
$type
);
$document
->
setRecentContributorPHIDs
(
array_slice
(
$contributors
,
0
,
3
));
echo
"Added recent contributor phids.
\n
"
;
$document
->
setContributorCount
(
count
(
$contributors
));
echo
"Added contributor count.
\n
"
;
}
if
(!
$updated
)
{
echo
"-
\n
"
;
continue
;
}
$document
->
save
();
}
$table
->
saveTransaction
();
echo
"Done.
\n
"
;
Event Timeline
Log In to Comment