Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80232561
20141106.uniqdrafts.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
Fri, Aug 30, 14:38
Size
832 B
Mime Type
text/x-php
Expires
Sun, Sep 1, 14:38 (2 d)
Engine
blob
Format
Raw Data
Handle
20327920
Attached To
rPH Phabricator
20141106.uniqdrafts.php
View Options
<?php
// Destroy duplicate drafts before storage adjustment adds a unique key to this
// table. See T1191. We retain the newest draft.
// (We can't easily do this in a single SQL statement because MySQL won't let us
// modify a table that's joined in a subquery.)
$table
=
new
DifferentialDraft
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
$duplicates
=
queryfx_all
(
$conn_w
,
'SELECT DISTINCT u.id id FROM %T u
JOIN %T v
ON u.objectPHID = v.objectPHID
AND u.authorPHID = v.authorPHID
AND u.draftKey = v.draftKey
AND u.id < v.id'
,
$table
->
getTableName
(),
$table
->
getTableName
());
$duplicates
=
ipull
(
$duplicates
,
'id'
);
foreach
(
PhabricatorLiskDAO
::
chunkSQL
(
$duplicates
)
as
$chunk
)
{
queryfx
(
$conn_w
,
'DELETE FROM %T WHERE id IN (%Q)'
,
$table
->
getTableName
(),
$chunk
);
}
Event Timeline
Log In to Comment