Page MenuHomestyx hydra

No OneTemporary

diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php
index ba3c9562ae..fef1107998 100644
--- a/scripts/__init_script__.php
+++ b/scripts/__init_script__.php
@@ -1,35 +1,68 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
$include_path = ini_get('include_path');
ini_set('include_path', $include_path.':'.dirname(__FILE__).'/../../');
@include_once 'libphutil/src/__phutil_library_init__.php';
if (!@constant('__LIBPHUTIL__')) {
echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
"include the parent directory of libphutil/.\n";
exit(1);
}
phutil_load_library(dirname(__FILE__).'/../src/');
// NOTE: This is dangerous in general, but we know we're in a script context and
// are not vulnerable to CSRF.
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
+
+$include_path = ini_get('include_path');
+ini_set('include_path', $include_path.':'.dirname(__FILE__).'/../../');
+
+require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php';
+
+$env = isset($_SERVER['PHABRICATOR_ENV'])
+ ? $_SERVER['PHABRICATOR_ENV']
+ : getenv('PHABRICATOR_ENV');
+if (!$env) {
+ echo "Define PHABRICATOR_ENV before running this script.\n";
+ exit(1);
+}
+
+$conf = phabricator_read_config_file($env);
+$conf['phabricator.env'] = $env;
+
+phutil_require_module('phabricator', 'infrastructure/env');
+PhabricatorEnv::setEnvConfig($conf);
+
+phutil_load_library('arcanist/src');
+
+foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
+ phutil_load_library($library);
+}
+
+PhutilErrorHandler::initialize();
+PhabricatorEventEngine::initialize();
+
+$tz = PhabricatorEnv::getEnvConfig('phabricator.timezone');
+if ($tz) {
+ date_default_timezone_set($tz);
+}
diff --git a/scripts/celerity_mapper.php b/scripts/celerity_mapper.php
index a270b47ca0..449be2b80c 100755
--- a/scripts/celerity_mapper.php
+++ b/scripts/celerity_mapper.php
@@ -1,227 +1,226 @@
#!/usr/bin/env php
<?php
$package_spec = array(
'javelin.pkg.js' => array(
'javelin-util',
'javelin-install',
'javelin-event',
'javelin-stratcom',
'javelin-behavior',
'javelin-request',
'javelin-vector',
'javelin-dom',
'javelin-json',
'javelin-uri',
),
'typeahead.pkg.js' => array(
'javelin-typeahead',
'javelin-typeahead-normalizer',
'javelin-typeahead-source',
'javelin-typeahead-preloaded-source',
'javelin-typeahead-ondemand-source',
'javelin-tokenizer',
'javelin-behavior-aphront-basic-tokenizer',
),
'workflow.pkg.js' => array(
'javelin-mask',
'javelin-workflow',
'javelin-behavior-workflow',
'javelin-behavior-aphront-form-disable-on-submit',
'phabricator-keyboard-shortcut-manager',
'phabricator-keyboard-shortcut',
'javelin-behavior-phabricator-keyboard-shortcuts',
),
'core.pkg.css' => array(
'phabricator-core-css',
'phabricator-core-buttons-css',
'phabricator-standard-page-view',
'aphront-dialog-view-css',
'aphront-form-view-css',
'aphront-panel-view-css',
'aphront-side-nav-view-css',
'aphront-table-view-css',
'aphront-crumbs-view-css',
'aphront-tokenizer-control-css',
'aphront-typeahead-control-css',
'aphront-list-filter-view-css',
'phabricator-directory-css',
'phabricator-remarkup-css',
'syntax-highlighting-css',
),
'differential.pkg.css' => array(
'differential-core-view-css',
'differential-changeset-view-css',
'differential-revision-detail-css',
'differential-revision-history-css',
'differential-table-of-contents-css',
'differential-revision-comment-css',
'differential-revision-add-comment-css',
'differential-revision-comment-list-css',
),
'differential.pkg.js' => array(
'javelin-behavior-differential-feedback-preview',
'javelin-behavior-differential-edit-inline-comments',
'javelin-behavior-differential-populate',
'javelin-behavior-differential-show-more',
'javelin-behavior-differential-diff-radios',
),
'diffusion.pkg.css' => array(
'diffusion-commit-view-css',
),
);
require_once dirname(__FILE__).'/__init_script__.php';
-require_once dirname(__FILE__).'/__init_env__.php';
if ($argc != 2) {
$self = basename($argv[0]);
echo "usage: {$self} <webroot>\n";
exit(1);
}
phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'filesystem/filefinder');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'parser/docblock');
$root = Filesystem::resolvePath($argv[1]);
echo "Finding static resources...\n";
$files = id(new FileFinder($root))
->withType('f')
->withSuffix('js')
->withSuffix('css')
->withFollowSymlinks(true)
->setGenerateChecksums(true)
->find();
echo "Processing ".count($files)." files";
$resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash');
$file_map = array();
foreach ($files as $path => $hash) {
echo ".";
$name = '/'.Filesystem::readablePath($path, $root);
$file_map[$name] = array(
'hash' => md5($hash.$name.$resource_hash),
'disk' => $path,
);
}
echo "\n";
$runtime_map = array();
$hash_map = array();
$parser = new PhutilDocblockParser();
foreach ($file_map as $path => $info) {
$data = Filesystem::readFile($info['disk']);
$matches = array();
$ok = preg_match('@/[*][*].*?[*]/@s', $data, $matches);
if (!$ok) {
throw new Exception(
"File {$path} does not have a header doc comment. Encode dependency ".
"data in a header docblock.");
}
list($description, $metadata) = $parser->parse($matches[0]);
$provides = preg_split('/\s+/', trim(idx($metadata, 'provides')));
$requires = preg_split('/\s+/', trim(idx($metadata, 'requires')));
$provides = array_filter($provides);
$requires = array_filter($requires);
if (count($provides) > 1) {
// NOTE: Documentation-only JS is permitted to @provide no targets.
throw new Exception(
"File {$path} must @provide at most one Celerity target.");
}
$provides = reset($provides);
$type = 'js';
if (preg_match('/\.css$/', $path)) {
$type = 'css';
}
$uri = '/res/'.substr($info['hash'], 0, 8).$path;
$hash_map[$provides] = $info['hash'];
$runtime_map[$provides] = array(
'uri' => $uri,
'type' => $type,
'requires' => $requires,
'disk' => $path,
);
}
$package_map = array();
foreach ($package_spec as $name => $package) {
$hashes = array();
$type = null;
foreach ($package as $symbol) {
if (empty($hash_map[$symbol])) {
throw new Exception(
"Package specification for '{$name}' includes '{$symbol}', but that ".
"symbol is not defined anywhere.");
}
if ($type === null) {
$type = $runtime_map[$symbol]['type'];
} else {
$ntype = $runtime_map[$symbol]['type'];
if ($type !== $ntype) {
throw new Exception(
"Package specification for '{$name}' mixes resources of type ".
"'{$type}' with resources of type '{$ntype}'. Each package may only ".
"contain one type of resource.");
}
}
$hashes[] = $symbol.':'.$hash_map[$symbol];
}
$key = substr(md5(implode("\n", $hashes)), 0, 8);
$package_map['packages'][$key] = array(
'name' => $name,
'symbols' => $package,
'uri' => '/res/pkg/'.$key.'/'.$name,
'type' => $type,
);
foreach ($package as $symbol) {
$package_map['reverse'][$symbol] = $key;
}
}
ksort($runtime_map);
$runtime_map = var_export($runtime_map, true);
$runtime_map = preg_replace('/\s+$/m', '', $runtime_map);
$runtime_map = preg_replace('/array \(/', 'array(', $runtime_map);
ksort($package_map['packages']);
ksort($package_map['reverse']);
$package_map = var_export($package_map, true);
$package_map = preg_replace('/\s+$/m', '', $package_map);
$package_map = preg_replace('/array \(/', 'array(', $package_map);
$resource_map = <<<EOFILE
<?php
/**
* This file is automatically generated. Use 'celerity_mapper.php' to rebuild
* it.
* @generated
*/
celerity_register_resource_map({$runtime_map}, {$package_map});
EOFILE;
echo "Writing map...\n";
Filesystem::writeFile(
$root.'/../src/__celerity_resource_map__.php',
$resource_map);
echo "Done.\n";
diff --git a/scripts/crossref/generate_php_symbols.php b/scripts/crossref/generate_php_symbols.php
index d46460c054..2a8de4738f 100755
--- a/scripts/crossref/generate_php_symbols.php
+++ b/scripts/crossref/generate_php_symbols.php
@@ -1,81 +1,80 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'parser/xhpast/bin');
if ($argc !== 1) {
echo phutil_console_format(
"usage: find . -type f -name '*.php' | ./generate_php_symbols.php\n");
exit(1);
}
$input = file_get_contents('php://stdin');
$input = trim($input);
$input = explode("\n", $input);
$data = array();
$futures = array();
foreach ($input as $file) {
$file = Filesystem::readablePath($file);
$data[$file] = Filesystem::readFile($file);
$futures[$file] = xhpast_get_parser_future($data[$file]);
}
foreach (Futures($futures)->limit(8) as $file => $future) {
$tree = XHPASTTree::newFromDataAndResolvedExecFuture(
$data[$file],
$future->resolve());
$root = $tree->getRootNode();
$functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($functions as $function) {
$name = $function->getChildByIndex(2);
print_symbol($file, 'function', $name);
}
$classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
foreach ($classes as $class) {
$class_name = $class->getChildByIndex(1);
print_symbol($file, 'class', $class_name);
}
$interfaces = $root->selectDescendantsOfType('n_INTERFACE_DECLARATION');
foreach ($interfaces as $interface) {
$interface_name = $interface->getChildByIndex(1);
print_symbol($file, 'interface', $interface_name);
}
}
function print_symbol($file, $type, $token) {
$parts = array(
$token->getConcreteString(),
$type,
'php',
$token->getLineNumber(),
'/'.ltrim($file, './'),
);
echo implode(' ', $parts)."\n";
}
diff --git a/scripts/crossref/import_project_symbols.php b/scripts/crossref/import_project_symbols.php
index 058e8d07f1..fde7fb9ebd 100755
--- a/scripts/crossref/import_project_symbols.php
+++ b/scripts/crossref/import_project_symbols.php
@@ -1,154 +1,153 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
if ($argc !== 2) {
echo phutil_console_format(
"usage: import_project_symbols.php __project_name__ < __symbol_file__\n");
exit(1);
}
$project_name = $argv[1];
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
'name = %s',
$project_name);
if (!$project) {
// TODO: Provide a less silly way to do this explicitly, or just do it right
// here.
echo "Project '{$project_name}' is unknown. Upload a diff to implicitly ".
"create it.\n";
exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
$input = explode("\n", $input);
$map = array();
$symbols = array();
foreach ($input as $key => $line) {
$line_no = $key + 1;
$matches = null;
$ok = preg_match('/^([^ ]+) ([^ ]+) ([^ ]+) (\d+) (.*)$/', $line, $matches);
if (!$ok) {
throw new Exception(
"Line #{$line_no} of input is invalid. Expected five space-delimited ".
"fields: symbol name, symbol type, symbol language, line number, path. ".
"For example:\n\n".
"idx function php 13 /path/to/some/file.php\n\n".
"Actual line was:\n\n".
"{$line}");
}
list($all, $name, $type, $lang, $line_number, $path) = $matches;
if (isset($map[$name][$type][$lang])) {
$previous = $map[$name][$type][$lang] + 1;
throw new Exception(
"Line #{$line_no} of input is invalid. It specifies a duplicate symbol ".
"(same name, language, and type) which has already been defined ".
"elsewhere. You must preprocess the symbol list to remove duplicates ".
"and choose exactly one master definition for each symbol. This symbol ".
"was previously defined on line #{$previous}.\n\n".
"Line #{$line_no}:\n".
$line."\n\n".
"Line #{$previous}:\n".
$input[$previous - 1]);
} else {
$map[$name][$type][$lang] = $key;
}
if (strlen($name) > 128) {
throw new Exception(
"Symbol name '{$name}' defined on line #{$line_no} is too long, maximum ".
"symbol name length is 128 characters.");
}
if (strlen($type) > 12) {
throw new Exception(
"Symbol type '{$type}' defined on line #{$line_no} is too long, maximum ".
"symbol type length is 12 characters.");
}
if (strlen($lang) > 32) {
throw new Exception(
"Symbol language '{$lang}' defined on line #{$line_no} is too long, ".
"maximum symbol language length is 32 characters.");
}
if (!strlen($path) || $path[0] != 0) {
throw new Exception(
"Path '{$path}' defined on line #{$line_no} is invalid. Paths should be ".
"begin with '/' and specify a path from the root of the project, like ".
"'/src/utils/utils.php'.");
}
$symbols[] = array(
'name' => $name,
'type' => $type,
'lang' => $lang,
'line' => $line_number,
'path' => $path,
);
}
echo "Looking up path IDs...\n";
$path_map = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths(
ipull($symbols, 'path'));
$symbol = new PhabricatorRepositorySymbol();
$conn_w = $symbol->establishConnection('w');
echo "Preparing queries...\n";
$sql = array();
foreach ($symbols as $dict) {
$sql[] = qsprintf(
$conn_w,
'(%d, %s, %s, %s, %d, %d)',
$project->getID(),
$dict['name'],
$dict['type'],
$dict['lang'],
$dict['line'],
$path_map[$dict['path']]);
}
echo "Purging old symbols...\n";
queryfx(
$conn_w,
'DELETE FROM %T WHERE arcanistProjectID = %d',
$symbol->getTableName(),
$project->getID());
echo "Loading ".number_format(count($sql))." symbols...\n";
foreach (array_chunk($sql, 128) as $chunk) {
queryfx(
$conn_w,
'INSERT INTO %T
(arcanistProjectID, symbolName, symbolType, symbolLanguage, lineNumber,
pathID) VALUES %Q',
$symbol->getTableName(),
implode(', ', $chunk));
}
echo "Done.\n";
diff --git a/scripts/daemon/phabricator_daemon_launcher.php b/scripts/daemon/phabricator_daemon_launcher.php
index 08a04356d3..c1e1e36970 100755
--- a/scripts/daemon/phabricator_daemon_launcher.php
+++ b/scripts/daemon/phabricator_daemon_launcher.php
@@ -1,263 +1,262 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phabricator', 'infrastructure/daemon/control');
$control = new PhabricatorDaemonControl();
must_have_extension('pcntl');
must_have_extension('posix');
function must_have_extension($ext) {
if (!extension_loaded($ext)) {
echo "ERROR: The PHP extension '{$ext}' is not installed. You must ".
"install it to run daemons on this machine.\n";
exit(1);
}
}
switch (isset($argv[1]) ? $argv[1] : 'help') {
case 'list':
$err = $control->executeListCommand();
exit($err);
case 'status':
$err = $control->executeStatusCommand();
exit($err);
case 'stop':
$pass_argv = array_slice($argv, 2);
$err = $control->executeStopCommand($pass_argv);
exit($err);
case 'repository-launch-readonly':
$need_launch = phd_load_tracked_repositories_of_type('git');
if (!$need_launch) {
echo "There are no repositories with tracking enabled.\n";
} else {
will_launch($control);
foreach ($need_launch as $repository) {
$name = $repository->getName();
$callsign = $repository->getCallsign();
$desc = "'{$name}' ({$callsign})";
$phid = $repository->getPHID();
echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositoryGitFetchDaemon',
array(
$phid,
));
}
}
break;
case 'repository-launch-master':
$need_launch = phd_load_tracked_repositories();
if (!$need_launch) {
echo "There are no repositories with tracking enabled.\n";
} else {
will_launch($control);
foreach ($need_launch as $repository) {
$name = $repository->getName();
$callsign = $repository->getCallsign();
$desc = "'{$name}' ({$callsign})";
$phid = $repository->getPHID();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositoryGitFetchDaemon',
array(
$phid,
));
echo "Launching discovery daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositoryGitCommitDiscoveryDaemon',
array(
$phid,
));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
echo "Launching discovery daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositorySvnCommitDiscoveryDaemon',
array(
$phid,
));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
echo "Launching 'hg pull' daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositoryMercurialPullDaemon',
array(
$phid,
));
echo "Launching discovery daemon on the {$desc} repository...\n";
$control->launchDaemon(
'PhabricatorRepositoryMercurialCommitDiscoveryDaemon',
array(
$phid,
));
break;
}
}
echo "Launching CommitTask daemon...\n";
$control->launchDaemon(
'PhabricatorRepositoryCommitTaskDaemon',
array());
echo "Done.\n";
}
break;
case 'launch':
case 'debug':
$is_debug = ($argv[1] == 'debug');
$daemon = idx($argv, 2);
if (!$daemon) {
throw new Exception("Daemon name required!");
}
$pass_argv = array_slice($argv, 3);
$n = 1;
if (!$is_debug) {
if (is_numeric($daemon)) {
$n = $daemon;
if ($n < 1) {
throw new Exception("Count must be at least 1!");
}
$daemon = idx($argv, 3);
if (!$daemon) {
throw new Exception("Daemon name required!");
}
$pass_argv = array_slice($argv, 4);
}
}
$loader = new PhutilSymbolLoader();
$symbols = $loader
->setAncestorClass('PhutilDaemon')
->selectSymbolsWithoutLoading();
$symbols = ipull($symbols, 'name');
$match = array();
foreach ($symbols as $symbol) {
if (stripos($symbol, $daemon) !== false) {
if (strtolower($symbol) == strtolower($daemon)) {
$match = array($symbol);
break;
} else {
$match[] = $symbol;
}
}
}
if (count($match) == 0) {
throw new Exception(
"No daemons match! Use 'phd list' for a list of daemons.");
} else if (count($match) > 1) {
throw new Exception(
"Which of these daemons did you mean?\n".
" ".implode("\n ", $match));
} else {
$daemon = reset($match);
}
$with_logs = true;
if ($is_debug) {
// In debug mode, we emit errors straight to stdout, so nothing useful
// will show up in the logs. Don't echo the message about stuff showing
// up in them, since it would be confusing.
$with_logs = false;
}
will_launch($control, $with_logs);
if ($is_debug) {
echo "Launching {$daemon} in debug mode (nondaemonized)...\n";
} else {
echo "Launching {$n} x {$daemon}";
}
for ($ii = 0; $ii < $n; $ii++) {
$control->launchDaemon($daemon, $pass_argv, $is_debug);
if (!$is_debug) {
echo ".";
}
}
echo "\n";
echo "Done.\n";
break;
case '--help':
case 'help':
default:
$err = $control->executeHelpCommand();
exit($err);
}
function phd_load_tracked_repositories_of_type($type) {
$repositories = phd_load_tracked_repositories();
foreach ($repositories as $key => $repository) {
if ($repository->getVersionControlSystem() != $type) {
unset($repositories[$key]);
}
}
return $repositories;
}
function phd_load_tracked_repositories() {
phutil_require_module(
'phabricator',
'applications/repository/storage/repository');
$repositories = id(new PhabricatorRepository())->loadAll();
foreach ($repositories as $key => $repository) {
if (!$repository->isTracked()) {
unset($repositories[$key]);
}
}
return $repositories;
}
function will_launch($control, $with_logs = true) {
echo "Staging launch...\n";
$control->pingConduit();
if ($with_logs) {
$log_dir = $control->getControlDirectory('log').'/daemons.log';
echo "NOTE: Logs will appear in '{$log_dir}'.\n\n";
}
}
diff --git a/scripts/mail/mail_handler.php b/scripts/mail/mail_handler.php
index e3225f3623..2b49c910bb 100755
--- a/scripts/mail/mail_handler.php
+++ b/scripts/mail/mail_handler.php
@@ -1,67 +1,66 @@
#!/usr/bin/php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if ($argc > 1) {
$_SERVER['PHABRICATOR_ENV'] = $argv[1];
}
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
require_once $root.'/externals/mimemailparser/MimeMailParser.class.php';
phutil_require_module(
'phabricator',
'applications/metamta/storage/receivedmail');
phutil_require_module(
'phabricator',
'applications/files/storage/file');
$parser = new MimeMailParser();
$parser->setText(file_get_contents('php://stdin'));
$received = new PhabricatorMetaMTAReceivedMail();
$received->setHeaders($parser->getHeaders());
$received->setBodies(array(
'text' => $parser->getMessageBody('text'),
'html' => $parser->getMessageBody('html'),
));
$attachments = array();
foreach ($parser->getAttachments() as $attachment) {
if (preg_match('@text/(plain|html)@', $attachment->getContentType()) &&
$attachment->getContentDisposition() == 'inline') {
// If this is an "inline" attachment with some sort of text content-type,
// do not treat it as a file for attachment. MimeMailParser already picked
// it up in the getMessageBody() call above. We still want to treat 'inline'
// attachments with other content types (e.g., images) as attachments.
continue;
}
$file = PhabricatorFile::newFromFileData(
$attachment->getContent(),
array(
'name' => $attachment->getFilename(),
));
$attachments[] = $file->getPHID();
}
$received->setAttachments($attachments);
$received->save();
$received->processReceivedMail();
diff --git a/scripts/repository/rebuild_summaries.php b/scripts/repository/rebuild_summaries.php
index 68fa69ecc3..a248d370ba 100755
--- a/scripts/repository/rebuild_summaries.php
+++ b/scripts/repository/rebuild_summaries.php
@@ -1,74 +1,73 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'symbols');
PhutilSymbolLoader::loadClass('PhabricatorRepository');
PhutilSymbolLoader::loadClass('PhabricatorRepositoryCommit');
$commit = new PhabricatorRepositoryCommit();
$conn_w = id(new PhabricatorRepository())->establishConnection('w');
$sizes = queryfx_all(
$conn_w,
'SELECT repositoryID, count(*) N FROM %T GROUP BY repositoryID',
$commit->getTableName());
$sizes = ipull($sizes, 'N', 'repositoryID');
$maxes = queryfx_all(
$conn_w,
'SELECT repositoryID, max(epoch) maxEpoch FROM %T GROUP BY repositoryID',
$commit->getTableName());
$maxes = ipull($maxes, 'maxEpoch', 'repositoryID');
$repository_ids = array_keys($sizes + $maxes);
echo "Updating ".count($repository_ids)." repositories";
foreach ($repository_ids as $repository_id) {
$last_commit = queryfx_one(
$conn_w,
'SELECT id FROM %T WHERE repositoryID = %d AND epoch = %d LIMIT 1',
$commit->getTableName(),
$repository_id,
idx($maxes, $repository_id, 0));
if ($last_commit) {
$last_commit = $last_commit['id'];
} else {
$last_commit = 0;
}
queryfx(
$conn_w,
'INSERT INTO %T (repositoryID, lastCommitID, size, epoch)
VALUES (%d, %d, %d, %d) ON DUPLICATE KEY UPDATE
lastCommitID = VALUES(lastCommitID),
size = VALUES(size),
epoch = VALUES(epoch)',
PhabricatorRepository::TABLE_SUMMARY,
$repository_id,
$last_commit,
idx($sizes, $repository_id, 0),
idx($maxes, $repository_id, 0));
echo ".";
}
echo "\ndone.\n";
diff --git a/scripts/repository/reparse.php b/scripts/repository/reparse.php
index c9d435fff5..f6e0fff060 100755
--- a/scripts/repository/reparse.php
+++ b/scripts/repository/reparse.php
@@ -1,236 +1,235 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
$is_all = false;
$reparse_message = false;
$reparse_change = false;
$reparse_herald = false;
$reparse_what = false;
$args = array_slice($argv, 1);
foreach ($args as $arg) {
if (!strncmp($arg, '--', 2)) {
$flag = substr($arg, 2);
switch ($flag) {
case 'all':
$is_all = true;
break;
case 'message':
case 'messages':
$reparse_message = true;
break;
case 'change':
case 'changes':
$reparse_change = true;
break;
case 'herald':
$reparse_herald = true;
break;
case 'trace':
PhutilServiceProfiler::installEchoListener();
break;
case 'help':
help();
break;
default:
usage("Unknown flag '{$arg}'.");
}
} else {
if ($reparse_what) {
usage("Specify exactly one thing to reparse.");
}
$reparse_what = $arg;
}
}
if (!$reparse_what) {
usage("Specify a commit or repository to reparse.");
}
if (!$reparse_message && !$reparse_change && !$reparse_herald) {
usage("Specify what information to reparse with --message, --change, and/or ".
"--herald.");
}
$commits = array();
if ($is_all) {
$repository = id(new PhabricatorRepository())->loadOneWhere(
'callsign = %s OR phid = %s',
$reparse_what,
$reparse_what);
if (!$repository) {
throw new Exception("Unknown repository '{$reparse_what}'!");
}
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
'repositoryID = %d',
$repository->getID());
if (!$commits) {
throw new Exception("No commits have been discovered in that repository!");
}
$callsign = $repository->getCallsign();
} else {
$matches = null;
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $reparse_what, $matches)) {
throw new Exception("Can't parse commit identifier!");
}
$callsign = $matches[1];
$commit_identifier = $matches[2];
$repository = id(new PhabricatorRepository())->loadOneWhere(
'callsign = %s',
$callsign);
if (!$repository) {
throw new Exception("No repository with callsign '{$callsign}'!");
}
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d AND commitIdentifier = %s',
$repository->getID(),
$commit_identifier);
if (!$commit) {
throw new Exception(
"No matching commit '{$commit_identifier}' in repository '{$callsign}'. ".
"(For git and mercurial repositories, you must specify the entire ".
"commit hash.)");
}
$commits = array($commit);
}
if ($is_all) {
echo phutil_console_format(
'**NOTE**: This script will queue tasks to reparse the data. Once the '.
'tasks have been queued, you need to run Taskmaster daemons to execute '.
'them.');
echo "\n\n";
echo "QUEUEING TASKS (".number_format(count($commits))." Commits):\n";
}
$tasks = array();
foreach ($commits as $commit) {
$classes = array();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
if ($reparse_message) {
$classes[] = 'PhabricatorRepositoryGitCommitMessageParserWorker';
}
if ($reparse_change) {
$classes[] = 'PhabricatorRepositoryGitCommitChangeParserWorker';
}
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
if ($reparse_message) {
$classes[] = 'PhabricatorRepositoryMercurialCommitMessageParserWorker';
}
if ($reparse_change) {
$classes[] = 'PhabricatorRepositoryMercurialCommitChangeParserWorker';
}
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
if ($reparse_message) {
$classes[] = 'PhabricatorRepositorySvnCommitMessageParserWorker';
}
if ($reparse_change) {
$classes[] = 'PhabricatorRepositorySvnCommitChangeParserWorker';
}
break;
}
if ($reparse_herald) {
$classes[] = 'PhabricatorRepositoryCommitHeraldWorker';
}
$spec = array(
'commitID' => $commit->getID(),
'only' => true,
);
if ($is_all) {
foreach ($classes as $class) {
$task = new PhabricatorWorkerTask();
$task->setTaskClass($class);
$task->setData($spec);
$task->save();
$commit_name = 'r'.$callsign.$commit->getCommitIdentifier();
echo " Queued '{$class}' for commit '{$commit_name}'.\n";
}
} else {
foreach ($classes as $class) {
$worker = newv($class, array($spec));
echo "Running '{$class}'...\n";
$worker->doWork();
}
}
}
echo "\nDone.\n";
function usage($message) {
echo "Usage Error: {$message}";
echo "\n\n";
echo "Run 'reparse.php --help' for detailed help.\n";
exit(1);
}
function help() {
$help = <<<EOHELP
**SUMMARY**
**reparse.php** __what__ __which_parts__ [--trace]
Rerun the Diffusion parser on specific commits and repositories. Mostly
useful for debugging changes to Diffusion.
__what__: what to reparse
__commit__
Reparse one commit. This mode will reparse the commit in-process.
--all __repository_callsign__
--all __repository_phid__
Reparse all commits in the specified repository. These modes queue
parsers into the task queue, you must run taskmasters to actually
do the parses them.
__which_parts__: which parts of the thing to reparse
__--message__
Reparse commit messages.
__--change__
Reparse changes.
__--herald__
Reevaluate Herald rules (may send huge amounts of email!)
__--trace__: run with debug tracing
__--help__: show this help
**EXAMPLES**
reparse.php rX123 --change # Reparse change for "rX123".
reparse.php --all E --message # Reparse all messages in "E" repository.
EOHELP;
echo phutil_console_format($help);
exit(1);
}
diff --git a/scripts/repository/test_connection.php b/scripts/repository/test_connection.php
index 9757f9161d..9325ae2207 100755
--- a/scripts/repository/test_connection.php
+++ b/scripts/repository/test_connection.php
@@ -1,100 +1,99 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');
if (empty($argv[1])) {
echo "usage: test_connection.php <repository_callsign>\n";
exit(1);
}
echo phutil_console_wrap(
phutil_console_format(
'This script will test that you have configured valid credentials for '.
'access to a repository, so the Phabricator daemons can pull from it. '.
'You should run this as the **same user you will run the daemons as**, '.
'from the **same machine they will run from**. Doing this will help '.
'detect various problems with your configuration, such as SSH issues.'));
list($whoami) = execx('whoami');
$whoami = trim($whoami);
$ok = phutil_console_confirm("Do you want to continue as '{$whoami}'?");
if (!$ok) {
die(1);
}
$callsign = $argv[1];
echo "Loading '{$callsign}' repository...\n";
$repository = id(new PhabricatorRepository())->loadOneWhere(
'callsign = %s',
$argv[1]);
if (!$repository) {
throw new Exception("No such repository exists!");
}
$vcs = $repository->getVersionControlSystem();
PhutilServiceProfiler::installEchoListener();
echo "Trying to connect to the remote...\n";
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$err = $repository->passthruRemoteCommand(
'--limit 1 log %s',
$repository->getRemoteURI());
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
// Do an ls-remote on a nonexistent ref, which we expect to just return
// nothing.
$err = $repository->passthruRemoteCommand(
'ls-remote %s %s',
$repository->getRemoteURI(),
'just-testing');
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
// TODO: 'hg id' doesn't support --insecure so we can't tell it not to
// spew. If 'hg id' eventually supports --insecure, consider using it.
echo "(It is safe to ignore any 'certificate with fingerprint ... not ".
"verified' warnings, although you may want to configure Mercurial ".
"to recognize the server's fingerprint/certificate.)\n";
$err = $repository->passthruRemoteCommand(
'id --rev tip %s',
$repository->getRemoteURI());
break;
default:
throw new Exception("Unsupported repository type.");
}
if ($err) {
echo phutil_console_format(
"<bg:red>** FAIL **</bg> Connection failed. The credentials for this ".
"repository appear to be incorrectly configured.\n");
exit(1);
} else {
echo phutil_console_format(
"<bg:green>** OKAY **</bg> Connection successful. The credentials for ".
"this repository appear to be correctly configured.\n");
}
diff --git a/scripts/search/index_one_commit.php b/scripts/search/index_one_commit.php
index b89faefe10..d75f8c3184 100755
--- a/scripts/search/index_one_commit.php
+++ b/scripts/search/index_one_commit.php
@@ -1,53 +1,52 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
if (empty($argv[1])) {
echo "usage: index_one_commit.php <commit_name>\n";
die(1);
}
$commit = isset($argv[1]) ? $argv[1] : null;
if (!$commit) {
throw new Exception("Provide a commit to index!");
}
$matches = null;
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $commit, $matches)) {
throw new Exception("Can't parse commit identifier!");
}
$repo = id(new PhabricatorRepository())->loadOneWhere(
'callsign = %s',
$matches[1]);
if (!$repo) {
throw new Exception("Unknown repository!");
}
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %d AND commitIdentifier = %s',
$repo->getID(),
$matches[2]);
if (!$commit) {
throw new Exception('Unknown commit.');
}
PhabricatorSearchCommitIndexer::indexCommit($commit);
echo "Done.\n";
diff --git a/scripts/search/reindex_all_users.php b/scripts/search/reindex_all_users.php
index 3c9f576404..b829d5843a 100755
--- a/scripts/search/reindex_all_users.php
+++ b/scripts/search/reindex_all_users.php
@@ -1,32 +1,31 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
$users = id(new PhabricatorUser())->loadAll();
echo "Indexing ".count($users)." users";
foreach ($users as $user) {
PhabricatorSearchUserIndexer::indexUser($user);
echo '.';
}
echo "\n";
echo "Done.\n";
diff --git a/scripts/search/reindex_everything.php b/scripts/search/reindex_everything.php
index d0ee0079c6..0e4eea2c03 100755
--- a/scripts/search/reindex_everything.php
+++ b/scripts/search/reindex_everything.php
@@ -1,57 +1,56 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
// TODO: Get rid of this script eventually, once this stuff is better-formalized
// in Timeline consumers.
echo "Loading revisions...\n";
$revs = id(new DifferentialRevision())->loadAll();
$count = count($revs);
echo "Reindexing {$count} revisions";
foreach ($revs as $rev) {
PhabricatorSearchDifferentialIndexer::indexRevision($rev);
echo '.';
}
echo "\n";
echo "Loading commits...\n";
$commits = id(new PhabricatorRepositoryCommit())->loadAll();
$count = count($commits);
echo "Reindexing {$count} commits";
foreach ($commits as $commit) {
PhabricatorSearchCommitIndexer::indexCommit($commit);
echo '.';
}
echo "\n";
echo "Loading tasks...\n";
$tasks = id(new ManiphestTask())->loadAll();
$count = count($tasks);
echo "Reindexing {$count} tasks";
foreach ($tasks as $task) {
PhabricatorSearchManiphestIndexer::indexTask($task);
echo '.';
}
echo "\n";
echo "Done.\n";
diff --git a/scripts/search/reindex_maniphest.php b/scripts/search/reindex_maniphest.php
index 45a99b4788..89235c6590 100755
--- a/scripts/search/reindex_maniphest.php
+++ b/scripts/search/reindex_maniphest.php
@@ -1,33 +1,32 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
ini_set('memory_limit', -1);
$tasks = id(new ManiphestTask())->loadAll();
echo "Updating relationships for ".count($tasks)." tasks";
foreach ($tasks as $task) {
ManiphestTaskProject::updateTaskProjects($task);
ManiphestTaskSubscriber::updateTaskSubscribers($task);
echo '.';
}
echo "\nDone.\n";
diff --git a/scripts/sql/upgrade_schema.php b/scripts/sql/upgrade_schema.php
index 04bc25efab..673b0608d8 100755
--- a/scripts/sql/upgrade_schema.php
+++ b/scripts/sql/upgrade_schema.php
@@ -1,201 +1,200 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phabricator', 'infrastructure/setup/sql');
define('SCHEMA_VERSION_TABLE_NAME', 'schema_version');
// TODO: getopt() is super terrible, move to something less terrible.
$options = getopt('fhv:u:p:') + array(
'v' => null, // Upgrade from specific version
'u' => null, // Override MySQL User
'p' => null, // Override MySQL Pass
);
foreach (array('h', 'f') as $key) {
// By default, these keys are set to 'false' to indicate that the flag was
// passed.
if (array_key_exists($key, $options)) {
$options[$key] = true;
}
}
if (!empty($options['h']) || ($options['v'] && !is_numeric($options['v']))) {
usage();
}
if (empty($options['f'])) {
echo phutil_console_wrap(
"Before running this script, you should take down the Phabricator web ".
"interface and stop any running Phabricator daemons.");
if (!phutil_console_confirm('Are you ready to continue?')) {
echo "Cancelled.\n";
exit(1);
}
}
// Use always the version from the commandline if it is defined
$next_version = isset($options['v']) ? (int)$options['v'] : null;
$conf = DatabaseConfigurationProvider::getConfiguration();
if ($options['u']) {
$conn_user = $options['u'];
$conn_pass = $options['p'];
} else {
$conn_user = $conf->getUser();
$conn_pass = $conf->getPassword();
}
$conn_host = $conf->getHost();
// Split out port information, since the command-line client requires a
// separate flag for the port.
$uri = new PhutilURI('mysql://'.$conn_host);
if ($uri->getPort()) {
$conn_port = $uri->getPort();
$conn_bare_hostname = $uri->getDomain();
} else {
$conn_port = null;
$conn_bare_hostname = $conn_host;
}
$conn = new AphrontMySQLDatabaseConnection(
array(
'user' => $conn_user,
'pass' => $conn_pass,
'host' => $conn_host,
'database' => null,
));
try {
$create_sql = <<<END
CREATE DATABASE IF NOT EXISTS `phabricator_meta_data`;
END;
queryfx($conn, $create_sql);
$create_sql = <<<END
CREATE TABLE IF NOT EXISTS phabricator_meta_data.`schema_version` (
`version` INTEGER not null
);
END;
queryfx($conn, $create_sql);
// Get the version only if commandline argument wasn't given
if ($next_version === null) {
$version = queryfx_one(
$conn,
'SELECT * FROM phabricator_meta_data.%T',
SCHEMA_VERSION_TABLE_NAME);
if (!$version) {
print "*** No version information in the database ***\n";
print "*** Give the first patch version which to ***\n";
print "*** apply as the command line argument ***\n";
exit(-1);
}
$next_version = $version['version'] + 1;
}
$patches = PhabricatorSQLPatchList::getPatchList();
$patch_applied = false;
foreach ($patches as $patch) {
if ($patch['version'] < $next_version) {
continue;
}
$short_name = basename($patch['path']);
print "Applying patch {$short_name}...\n";
if ($conn_port) {
$port = '--port='.(int)$conn_port;
} else {
$port = null;
}
if (preg_match('/\.php$/', $patch['path'])) {
$schema_conn = $conn;
require_once $patch['path'];
} else {
list($stdout, $stderr) = execx(
"mysql --user=%s --password=%s --host=%s {$port} < %s",
$conn_user,
$conn_pass,
$conn_bare_hostname,
$patch['path']);
if ($stderr) {
print $stderr;
exit(-1);
}
}
// Patch was successful, update the db with the latest applied patch version
// 'DELETE' and 'INSERT' instead of update, because the table might be empty
queryfx(
$conn,
'DELETE FROM phabricator_meta_data.%T',
SCHEMA_VERSION_TABLE_NAME);
queryfx(
$conn,
'INSERT INTO phabricator_meta_data.%T VALUES (%d)',
SCHEMA_VERSION_TABLE_NAME,
$patch['version']);
$patch_applied = true;
}
if (!$patch_applied) {
print "Your database is already up-to-date.\n";
}
} catch (AphrontQueryAccessDeniedException $ex) {
echo
"ACCESS DENIED\n".
"The user '{$conn_user}' does not have sufficient MySQL privileges to\n".
"execute the schema upgrade. Use the -u and -p flags to run as a user\n".
"with more privileges (e.g., root).".
"\n\n".
"EXCEPTION:\n".
$ex->getMessage().
"\n\n";
exit(1);
}
function usage() {
echo
"usage: upgrade_schema.php [-v version] [-u user -p pass] [-f] [-h]".
"\n\n".
"Run 'upgrade_schema.php -u root -p hunter2' to override the configured ".
"default user.\n".
"Run 'upgrade_schema.php -v 12' to apply all patches starting from ".
"version 12. It is very unlikely you need to do this.\n".
"Use the -f flag to upgrade noninteractively, without prompting.\n".
"Use the -h flag to show this help.\n";
exit(1);
}
diff --git a/scripts/user/account_admin.php b/scripts/user/account_admin.php
index 7ceeff230b..cadab1db62 100755
--- a/scripts/user/account_admin.php
+++ b/scripts/user/account_admin.php
@@ -1,150 +1,149 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');
echo "Enter a username to create a new account or edit an existing account.";
$username = phutil_console_prompt("Enter a username:");
if (!strlen($username)) {
echo "Cancelled.\n";
exit(1);
}
$user = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$username);
if (!$user) {
$original = new PhabricatorUser();
echo "There is no existing user account '{$username}'.\n";
$ok = phutil_console_confirm(
"Do you want to create a new '{$username}' account?",
$default_no = false);
if (!$ok) {
echo "Cancelled.\n";
exit(1);
}
$user = new PhabricatorUser();
$user->setUsername($username);
} else {
$original = clone $user;
echo "There is an existing user account '{$username}'.\n";
$ok = phutil_console_confirm(
"Do you want to edit the existing '{$username}' account?",
$default_no = false);
if (!$ok) {
echo "Cancelled.\n";
exit(1);
}
}
$user_realname = $user->getRealName();
if (strlen($user_realname)) {
$realname_prompt = ' ['.$user_realname.']';
} else {
$realname_prompt = '';
}
$realname = nonempty(
phutil_console_prompt("Enter user real name{$realname_prompt}:"),
$user_realname);
$user->setRealName($realname);
$user_email = $user->getEmail();
if (strlen($user_email)) {
$email_prompt = ' ['.$user_email.']';
} else {
$email_prompt = '';
}
do {
$email = nonempty(
phutil_console_prompt("Enter user email address{$email_prompt}:"),
$user_email);
$duplicate = id(new PhabricatorUser())->loadOneWhere(
'email = %s',
$email);
if ($duplicate && $duplicate->getID() != $user->getID()) {
$duplicate_username = $duplicate->getUsername();
echo "ERROR: There is already a user with that email address ".
"({$duplicate_username}). Each user must have a unique email ".
"address.\n";
} else {
break;
}
} while (true);
$user->setEmail($email);
$changed_pass = false;
// This disables local echo, so the user's password is not shown as they type
// it.
phutil_passthru('stty -echo');
$password = phutil_console_prompt(
"Enter a password for this user [blank to leave unchanged]:");
phutil_passthru('stty echo');
if (strlen($password)) {
$changed_pass = $password;
}
$is_admin = $user->getIsAdmin();
$set_admin = phutil_console_confirm(
'Should this user be an administrator?',
$default_no = !$is_admin);
$user->setIsAdmin($set_admin);
echo "\n\nACCOUNT SUMMARY\n\n";
$tpl = "%12s %-30s %-30s\n";
printf($tpl, null, 'OLD VALUE', 'NEW VALUE');
printf($tpl, 'Username', $original->getUsername(), $user->getUsername());
printf($tpl, 'Real Name', $original->getRealName(), $user->getRealName());
printf($tpl, 'Email', $original->getEmail(), $user->getEmail());
printf($tpl, 'Password', null,
($changed_pass !== false)
? 'Updated'
: 'Unchanged');
printf(
$tpl,
'Admin',
$original->getIsAdmin() ? 'Y' : 'N',
$user->getIsAdmin() ? 'Y' : 'N');
echo "\n";
if (!phutil_console_confirm("Save these changes?", $default_no = false)) {
echo "Cancelled.\n";
exit(1);
}
$user->save();
if ($changed_pass !== false) {
// This must happen after saving the user because we use their PHID as a
// component of the password hash.
$user->setPassword($changed_pass);
$user->save();
}
echo "Saved changes.\n";
diff --git a/src/infrastructure/daemon/base/PhabricatorDaemon.php b/src/infrastructure/daemon/base/PhabricatorDaemon.php
index 0f6d56e14f..a53257bc6a 100644
--- a/src/infrastructure/daemon/base/PhabricatorDaemon.php
+++ b/src/infrastructure/daemon/base/PhabricatorDaemon.php
@@ -1,38 +1,35 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
abstract class PhabricatorDaemon extends PhutilDaemon {
protected function willRun() {
parent::willRun();
// This stores unbounded amounts of log data; make it discard instead so
// that daemons do not require unbounded amounts of memory.
DarkConsoleErrorLogPluginAPI::enableDiscardMode();
// Also accumulates potentially unlimited amounts of data.
DarkConsoleEventPluginAPI::enableDiscardMode();
$phabricator = phutil_get_library_root('phabricator');
$root = dirname($phabricator);
- require_once $root.'/scripts/__init_env__.php';
-
- // Daemons may perform writes.
- AphrontWriteGuard::allowDangerousUnguardedWrites(true);
+ require_once $root.'/scripts/__init_script__.php';
}
}
diff --git a/src/infrastructure/daemon/base/__init__.php b/src/infrastructure/daemon/base/__init__.php
index 8f22a77cd7..561cdb4337 100644
--- a/src/infrastructure/daemon/base/__init__.php
+++ b/src/infrastructure/daemon/base/__init__.php
@@ -1,17 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
phutil_require_module('phabricator', 'aphront/console/plugin/event/api');
-phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phutil', 'daemon/base');
phutil_require_module('phutil', 'moduleutils');
phutil_require_source('PhabricatorDaemon.php');
diff --git a/src/infrastructure/testing/testcase/PhabricatorTestCase.php b/src/infrastructure/testing/testcase/PhabricatorTestCase.php
index 67dc5a205c..6b4d274195 100644
--- a/src/infrastructure/testing/testcase/PhabricatorTestCase.php
+++ b/src/infrastructure/testing/testcase/PhabricatorTestCase.php
@@ -1,64 +1,64 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
abstract class PhabricatorTestCase extends ArcanistPhutilTestCase {
/**
* If true, put Lisk in process-isolated mode for the duration of the tests so
* that it will establish only isolated, side-effect-free database
* connections. Defaults to true.
*
* NOTE: You should disable this only in rare circumstances. Unit tests should
* not rely on external resources like databases, and should not produce
* side effects.
*/
const PHABRICATOR_TESTCONFIG_ISOLATE_LISK = 'isolate-lisk';
private $configuration;
protected function getPhabricatorTestCaseConfiguration() {
return array();
}
private function getComputedConfiguration() {
return $this->getPhabricatorTestCaseConfiguration() + array(
self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => true,
);
}
protected function willRunTests() {
$root = dirname(phutil_get_library_root('phabricator'));
- require_once $root.'/scripts/__init_env__.php';
+ require_once $root.'/scripts/__init_script__.php';
$config = $this->getComputedConfiguration();
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
}
}
protected function didRunTests() {
$config = $this->getComputedConfiguration();
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
LiskDAO::endIsolateAllLiskEffectsToCurrentProcess();
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 1:25 AM (2 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
165199
Default Alt Text
(60 KB)

Event Timeline