1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Depend on class autoloading

Test Plan:
Run setup.
/differential/

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2612
This commit is contained in:
vrana 2012-05-30 16:38:53 -07:00
parent 09c8af4de0
commit 1ebf9186b4
32 changed files with 46 additions and 138 deletions

View file

@ -42,7 +42,6 @@ $env = isset($_SERVER['PHABRICATOR_ENV'])
? $_SERVER['PHABRICATOR_ENV']
: getenv('PHABRICATOR_ENV');
if (!$env) {
phutil_require_module('phutil', 'console');
echo phutil_console_wrap(
phutil_console_format(
"**ERROR**: PHABRICATOR_ENV Not Set\n\n".
@ -59,7 +58,6 @@ if (!$env) {
$conf = phabricator_read_config_file($env);
$conf['phabricator.env'] = $env;
phutil_require_module('phabricator', 'infrastructure/env');
PhabricatorEnv::setEnvConfig($conf);
phutil_load_library('arcanist/src');

View file

@ -155,11 +155,6 @@ if ($argc != 2) {
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]);
$resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash');

View file

@ -20,8 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
$time_start = microtime(true);
if ($argc !== 3) {

View file

@ -20,7 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phabricator', 'infrastructure/daemon/control');
$control = new PhabricatorDaemonControl();
must_have_extension('pcntl');
@ -208,10 +207,6 @@ switch ($command) {
}
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()) {

View file

@ -20,8 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
$revision = new DifferentialRevision();
$empty_revisions = queryfx_all(

View file

@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');
PhutilServiceProfiler::installEchoListener();
$allocator = new DrydockAllocator();

View file

@ -2,7 +2,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,13 +25,6 @@ $root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.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'));

View file

@ -2,7 +2,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,10 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'symbols');
PhutilSymbolLoader::loadClass('PhabricatorRepository');
PhutilSymbolLoader::loadClass('PhabricatorRepositoryCommit');
$commit = new PhabricatorRepositoryCommit();
$conn_w = id(new PhabricatorRepository())->establishConnection('w');

View file

@ -20,8 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
$is_all = false;
$reparse_message = false;
$reparse_change = false;

View file

@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.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);

View file

@ -20,8 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
if (ctags_check_executable() == false) {
echo phutil_console_format(
"Could not find Exuberant ctags. Make sure it is installed and\n".

View file

@ -2,7 +2,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'parser/xhpast/bin');
if ($argc !== 1 || posix_isatty(STDIN)) {
echo phutil_console_format(
"usage: find . -type f -name '*.php' | ./generate_php_symbols.php\n");

View file

@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.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:");

View file

@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');
if ($argc !== 5) {
echo "usage: add_user.php <username> <email> <realname> <admin_user>\n";
exit(1);

View file

@ -20,9 +20,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phabricator', 'storage/queryfx');
$purge_changesets = false;
$purge_differential = false;
$purge_maniphest = false;

View file

@ -74,7 +74,6 @@ abstract class AphrontApplicationConfiguration {
return $this->build404Controller();
}
PhutilSymbolLoader::loadClass($controller_class);
$controller = newv($controller_class, array($request));
return array($controller, $uri_data);

View file

@ -70,7 +70,6 @@ final class DarkConsoleXHProfPluginAPI {
$data = xhprof_disable();
$data = serialize($data);
$file_class = 'PhabricatorFile';
PhutilSymbolLoader::loadClass($file_class);
// Since these happen on GET we can't do guarded writes.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();

View file

@ -155,7 +155,6 @@ abstract class PhabricatorOAuthProvider {
default:
throw new Exception('Unknown OAuth provider.');
}
PhutilSymbolLoader::loadClass($class);
return newv($class, array());
}

View file

@ -63,9 +63,8 @@ abstract class PhabricatorController extends AphrontController {
$request->setUser($user);
if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
$disabled_user_controller = newv(
'PhabricatorDisabledUserController',
array($request));
$disabled_user_controller = new PhabricatorDisabledUserController(
$request);
return $this->delegateToController($disabled_user_controller);
}
@ -78,7 +77,7 @@ abstract class PhabricatorController extends AphrontController {
}
if ($this->shouldRequireLogin() && !$user->getPHID()) {
$login_controller = newv('PhabricatorLoginController', array($request));
$login_controller = new PhabricatorLoginController($request);
return $this->delegateToController($login_controller);
}
@ -89,9 +88,7 @@ abstract class PhabricatorController extends AphrontController {
"No primary email address associated with this account!");
}
if (!$email->getIsVerified()) {
$verify_controller = newv(
'PhabricatorMustVerifyEmailController',
array($request));
$verify_controller = new PhabricatorMustVerifyEmailController($request);
return $this->delegateToController($verify_controller);
}
}

View file

@ -227,7 +227,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
// TODO: build a better version of the action links and deprecate the
// whole DifferentialRevisionDetailRenderer class.
PhutilSymbolLoader::loadClass($custom_renderer_class);
$custom_renderer =
newv($custom_renderer_class, array());
$actions = array_merge(

View file

@ -51,18 +51,15 @@ abstract class DiffusionBranchQuery {
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$class = 'DiffusionGitBranchQuery';
$query = new DiffusionGitBranchQuery();
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$class = 'DiffusionMercurialBranchQuery';
$query = new DiffusionMercurialBranchQuery();
break;
default:
throw new Exception("Unsupported VCS!");
}
PhutilSymbolLoader::loadClass($class);
$query = new $class();
$query->request = $request;
return $query;

View file

@ -44,21 +44,18 @@ abstract class DiffusionBrowseQuery {
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
// TODO: Verify local-path?
$class = 'DiffusionGitBrowseQuery';
$query = new DiffusionGitBrowseQuery();
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$class = 'DiffusionMercurialBrowseQuery';
$query = new DiffusionMercurialBrowseQuery();
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$class = 'DiffusionSvnBrowseQuery';
$query = new DiffusionSvnBrowseQuery();
break;
default:
throw new Exception("Unsupported VCS!");
}
PhutilSymbolLoader::loadClass($class);
$query = new $class();
$query->request = $request;
return $query;

View file

@ -106,6 +106,7 @@ final class PhabricatorS3FileStorageEngine
* Create a new S3 API object.
*
* @task internal
* @phutil-external-symbol class S3
*/
private function newS3API() {
$libroot = dirname(phutil_get_library_root('phabricator'));
@ -119,13 +120,7 @@ final class PhabricatorS3FileStorageEngine
"Specify 'amazon-s3.access-key' and 'amazon-s3.secret-key'!");
}
$s3 = newv(
'S3',
array(
$access_key,
$secret_key,
$use_ssl = true,
));
$s3 = new S3($access_key, $secret_key, $use_ssl = true);
$s3->setExceptions(true);

View file

@ -118,7 +118,6 @@ class PhabricatorMarkupEngine {
$custom_rule_classes = $options['custom-inline'];
if ($custom_rule_classes) {
foreach ($custom_rule_classes as $custom_rule_class) {
PhutilSymbolLoader::loadClass($custom_rule_class);
$rules[] = newv($custom_rule_class, array());
}
}
@ -167,7 +166,6 @@ class PhabricatorMarkupEngine {
$custom_block_rule_classes = $options['custom-block'];
if ($custom_block_rule_classes) {
foreach ($custom_block_rule_classes as $custom_block_rule_class) {
PhutilSymbolLoader::loadClass($custom_block_rule_class);
$blocks[] = newv($custom_block_rule_class, array());
}
}

View file

@ -33,6 +33,9 @@ final class PhabricatorMailImplementationAmazonSESAdapter
return false;
}
/**
* @phutil-external-symbol class SimpleEmailService
*/
public function executeSend($body) {
$key = PhabricatorEnv::getEnvConfig('amazon-ses.access-key');
$secret = PhabricatorEnv::getEnvConfig('amazon-ses.secret-key');
@ -41,7 +44,7 @@ final class PhabricatorMailImplementationAmazonSESAdapter
$root = dirname($root);
require_once $root.'/externals/amazon-ses/ses.php';
$service = newv('SimpleEmailService', array($key, $secret));
$service = new SimpleEmailService($key, $secret);
$service->enableUseExceptions(true);
return $service->sendRawEmail($body);
}

View file

@ -22,11 +22,14 @@
class PhabricatorMailImplementationPHPMailerLiteAdapter
extends PhabricatorMailImplementationAdapter {
/**
* @phutil-external-symbol class PHPMailerLite
*/
public function __construct() {
$root = phutil_get_library_root('phabricator');
$root = dirname($root);
require_once $root.'/externals/phpmailer/class.phpmailer-lite.php';
$this->mailer = newv('PHPMailerLite', array($use_exceptions = true));
$this->mailer = new PHPMailerLite($use_exceptions = true);
$this->mailer->CharSet = 'utf-8';
}

View file

@ -233,13 +233,13 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
$class_obj = null;
switch ($receiver_type) {
case 'T':
$class_obj = newv('ManiphestTask', array());
$class_obj = new ManiphestTask();
break;
case 'D':
$class_obj = newv('DifferentialRevision', array());
$class_obj = new DifferentialRevision();
break;
case 'C':
$class_obj = newv('PhabricatorRepositoryCommit', array());
$class_obj = new PhabricatorRepositoryCommit();
break;
default:
return null;

View file

@ -40,7 +40,7 @@ final class PhabricatorObjectHandleData {
foreach ($types as $type => $phids) {
switch ($type) {
case PhabricatorPHIDConstants::PHID_TYPE_USER:
$user_dao = newv('PhabricatorUser', array());
$user_dao = new PhabricatorUser();
$users = $user_dao->loadAllWhere(
'phid in (%Ls)',
$phids);
@ -49,13 +49,13 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_CMIT:
$commit_dao = newv('PhabricatorRepositoryCommit', array());
$commit_dao = new PhabricatorRepositoryCommit();
$commits = $commit_dao->loadAllWhere(
'phid IN (%Ls)',
$phids);
$commit_data = array();
if ($commits) {
$data_dao = newv('PhabricatorRepositoryCommitData', array());
$data_dao = new PhabricatorRepositoryCommitData();
$commit_data = $data_dao->loadAllWhere(
'commitID IN (%Ld)',
mpull($commits, 'getID'));
@ -73,7 +73,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_TASK:
$task_dao = newv('ManiphestTask', array());
$task_dao = new ManiphestTask();
$tasks = $task_dao->loadAllWhere(
'phid IN (%Ls)',
$phids);
@ -82,7 +82,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_DREV:
$revision_dao = newv('DifferentialRevision', array());
$revision_dao = new DifferentialRevision();
$revisions = $revision_dao->loadAllWhere(
'phid IN (%Ls)',
$phids);
@ -131,9 +131,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_USER:
$class = 'PhabricatorUser';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorUser();
$users = $object->loadAllWhere('phid IN (%Ls)', $phids);
$users = mpull($users, null, 'getPHID');
@ -183,10 +181,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_MLST:
$class = 'PhabricatorMetaMTAMailingList';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorMetaMTAMailingList();
$lists = $object->loadAllWhere('phid IN (%Ls)', $phids);
$lists = mpull($lists, null, 'getPHID');
@ -208,9 +203,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_DREV:
$class = 'DifferentialRevision';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new DifferentialRevision();
$revs = $object->loadAllWhere('phid in (%Ls)', $phids);
$revs = mpull($revs, null, 'getPHID');
@ -240,9 +233,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_CMIT:
$class = 'PhabricatorRepositoryCommit';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorRepositoryCommit();
$commits = $object->loadAllWhere('phid in (%Ls)', $phids);
$commits = mpull($commits, null, 'getPHID');
@ -287,9 +278,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_TASK:
$class = 'ManiphestTask';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new ManiphestTask();
$tasks = $object->loadAllWhere('phid in (%Ls)', $phids);
$tasks = mpull($tasks, null, 'getPHID');
@ -316,9 +305,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_FILE:
$class = 'PhabricatorFile';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorFile();
$files = $object->loadAllWhere('phid IN (%Ls)', $phids);
$files = mpull($files, null, 'getPHID');
@ -339,9 +326,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_PROJ:
$class = 'PhabricatorProject';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorProject();
$projects = $object->loadAllWhere('phid IN (%Ls)', $phids);
$projects = mpull($projects, null, 'getPHID');
@ -362,9 +347,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_REPO:
$class = 'PhabricatorRepository';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorRepository();
$repositories = $object->loadAllWhere('phid in (%Ls)', $phids);
$repositories = mpull($repositories, null, 'getPHID');
@ -385,9 +368,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_OPKG:
$class = 'PhabricatorOwnersPackage';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$object = new PhabricatorOwnersPackage();
$packages = $object->loadAllWhere('phid in (%Ls)', $phids);
$packages = mpull($packages, null, 'getPHID');
@ -408,7 +389,7 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_APRJ:
$project_dao = newv('PhabricatorRepositoryArcanistProject', array());
$project_dao = new PhabricatorRepositoryArcanistProject();
$projects = $project_dao->loadAllWhere(
'phid IN (%Ls)',
@ -429,8 +410,8 @@ final class PhabricatorObjectHandleData {
}
break;
case PhabricatorPHIDConstants::PHID_TYPE_WIKI:
$document_dao = newv('PhrictionDocument', array());
$content_dao = newv('PhrictionContent', array());
$document_dao = new PhrictionDocument();
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');
$documents = queryfx_all(
@ -467,7 +448,6 @@ final class PhabricatorObjectHandleData {
}
if ($loader) {
PhutilSymbolLoader::loadClass($loader);
$object = newv($loader, array());
$handles += $object->loadHandles($phids);
break;

View file

@ -48,7 +48,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
'PhabricatorRepositoryDefaultCommitMessageDetailParser');
if ($detail_parser) {
PhutilSymbolLoader::loadClass($detail_parser);
$parser_obj = newv($detail_parser, array($commit, $data));
$parser_obj->parseCommitDetails();
}

View file

@ -79,8 +79,8 @@ final class PhabricatorTaskmasterDaemon extends PhabricatorDaemon {
$data = idx($task_data, $task->getID());
$class = $task->getTaskClass();
try {
PhutilSymbolLoader::loadClass($class);
if (!is_subclass_of($class, 'PhabricatorWorker')) {
if (!class_exists($class) ||
!is_subclass_of($class, 'PhabricatorWorker')) {
throw new Exception(
"Task class '{$class}' does not extend PhabricatorWorker.");
}

View file

@ -58,8 +58,7 @@ final class PhabricatorSetup {
// of security so warn even if things look OK.
try {
phutil_require_module('phutil', 'utils');
$open_libphutil = true;
$open_libphutil = class_exists('Future');
} catch (Exception $ex) {
$message = $ex->getMessage();
self::write("Unable to load modules from libphutil: {$message}\n");
@ -67,8 +66,7 @@ final class PhabricatorSetup {
}
try {
phutil_require_module('arcanist', 'workflow/base');
$open_arcanist = true;
$open_arcanist = class_exists('ArcanistDiffParser');
} catch (Exception $ex) {
$message = $ex->getMessage();
self::write("Unable to load modules from Arcanist: {$message}\n");

View file

@ -76,7 +76,6 @@ try {
$conf = phabricator_read_config_file($env);
$conf['phabricator.env'] = $env;
phutil_require_module('phabricator', 'infrastructure/env');
PhabricatorEnv::setEnvConfig($conf);
// This is the earliest we can get away with this, we need env config first.
@ -91,11 +90,8 @@ try {
));
}
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
DarkConsoleXHProfPluginAPI::hookProfiler();
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
PhutilErrorHandler::initialize();
} catch (Exception $ex) {
@ -106,8 +102,6 @@ $tz = PhabricatorEnv::getEnvConfig('phabricator.timezone');
if ($tz) {
date_default_timezone_set($tz);
}
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
phutil_require_module('phutil', 'error');
PhutilErrorHandler::setErrorListener(
array('DarkConsoleErrorLogPluginAPI', 'handleErrors'));