2013-12-27 13:15:40 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorManagementWorkflow extends PhutilArgumentWorkflow {
|
|
|
|
|
|
|
|
public function isExecutable() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewer() {
|
|
|
|
// Some day, we might provide a more general viewer mechanism to scripts.
|
|
|
|
// For now, workflows can call this method for convenience and future
|
|
|
|
// flexibility.
|
|
|
|
return PhabricatorUser::getOmnipotentUser();
|
|
|
|
}
|
|
|
|
|
2015-01-30 11:29:05 -08:00
|
|
|
protected function parseTimeArgument($time) {
|
|
|
|
if (!strlen($time)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$epoch = strtotime($time);
|
|
|
|
if ($epoch <= 0) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
pht('Unable to parse time "%s".', $time));
|
|
|
|
}
|
|
|
|
return $epoch;
|
|
|
|
}
|
|
|
|
|
2016-03-25 05:56:16 -07:00
|
|
|
protected function newContentSource() {
|
|
|
|
return PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorConsoleContentSource::SOURCECONST);
|
|
|
|
}
|
|
|
|
|
Provide "bin/files integrity" for debugging, maintaining and backfilling integrity hashes
Summary:
Ref T12470. Provides an "integrity" utility which runs in these modes:
- Verify: check that hashes match.
- Compute: backfill missing hashes.
- Strip: remove hashes. Useful for upgrading across a hash change.
- Corrupt: intentionally corrupt hashes. Useful for debugging.
- Overwrite: force hash recomputation.
Users normally shouldn't need to run any of this stuff, but this provides a reasonable toolkit for managing integrity hashes.
I'll recommend existing installs use `bin/files integrity --compute all` in the upgrade guidance to backfill hashes for existing files.
Test Plan:
- Ran the script in many modes against various files, saw expected operation, including:
- Verified a file, corrupted it, saw it fail.
- Verified a file, stripped it, saw it have no hash.
- Stripped a file, computed it, got a clean verify.
- Stripped a file, overwrote it, got a clean verify.
- Corrupted a file, overwrote it, got a clean verify.
- Overwrote a file, overwrote again, got a no-op.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T12470
Differential Revision: https://secure.phabricator.com/D17629
2017-04-06 05:53:51 -07:00
|
|
|
protected function logInfo($label, $message) {
|
|
|
|
$this->logRaw(
|
|
|
|
tsprintf(
|
|
|
|
"**<bg:blue> %s </bg>** %s\n",
|
|
|
|
$label,
|
|
|
|
$message));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function logOkay($label, $message) {
|
|
|
|
$this->logRaw(
|
|
|
|
tsprintf(
|
|
|
|
"**<bg:green> %s </bg>** %s\n",
|
|
|
|
$label,
|
|
|
|
$message));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function logWarn($label, $message) {
|
|
|
|
$this->logRaw(
|
|
|
|
tsprintf(
|
|
|
|
"**<bg:yellow> %s </bg>** %s\n",
|
|
|
|
$label,
|
|
|
|
$message));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function logFail($label, $message) {
|
|
|
|
$this->logRaw(
|
|
|
|
tsprintf(
|
|
|
|
"**<bg:red> %s </bg>** %s\n",
|
|
|
|
$label,
|
|
|
|
$message));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function logRaw($message) {
|
|
|
|
fprintf(STDERR, '%s', $message);
|
|
|
|
}
|
|
|
|
|
2013-12-27 13:15:40 -08:00
|
|
|
}
|