Page MenuHomePhabricator
Paste P2088

nuker.php
ActivePublic

Authored by epriestley on Apr 6 2018, 12:03 AM.
<?php
require_once '/usr/local/phab/phabricator/scripts/__init_script__.php';
$phids = file_get_contents('php://stdin');
$phids = explode("\n", $phids);
$phids = array_filter($phids);
$diff_table = id(new DifferentialDiff())->getTableName();
$changeset_table = id(new DifferentialChangeset())->getTableName();
$property_table = id(new DifferentialDiffProperty())->getTableName();
$hunk_table = id(new DifferentialHunk())->getTableName();
$modern_table = id(new DifferentialHunkModern())->getTableName();
$conn = id(new DifferentialDiff())->establishConnection('w');
foreach ($phids as $phid) {
$diff = id(new DifferentialDiff())->loadOneWhere(
'phid = %s',
$phid);
if (!$diff) {
echo 'x';
continue;
}
$diff_id = $diff->getID();
queryfx(
$conn,
'DELETE FROM %T WHERE diffID = %d',
$property_table,
$diff_id);
$changesets = queryfx_all(
$conn,
'SELECT id FROM %T WHERE diffID = %d',
$changeset_table,
$diff_id)
$changeset_ids = ipull($changesets, 'id');
if ($changeset_ids) {
queryfx(
$conn,
'DELETE FROM %T WHERE changesetID IN (%Ld)',
$hunk_table,
$changeset_ids);
queryfx(
$conn,
'DELETE FROM %T WHERE changesetID IN (%Ld)',
$modern_table,
$changeset_ids);
}
quefyfx(
$conn,
'DELETE FROM %T WHERE diffID = %d',
$changeset_table,
$diff_id);
queryfx(
$conn,
'DELETE FROM %T WHERE id = %d',
$diff_table,
$diff_id);
echo '.';
}

Event Timeline

epriestley created this paste.Apr 6 2018, 12:03 AM