Page MenuHomePhabricator

nuker.php

Authored By
epriestley
Apr 6 2018, 12:03 AM
Size
1 KB
Referenced Files
None
Subscribers
None

nuker.php

<?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 '.';
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
994023
Default Alt Text
nuker.php (1 KB)

Event Timeline