1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

Uninstall Conduit calls when uninstalling applications

Summary: Fixes T2698. When applications are installed, their Conduit calls should drop out. This will also let us land Releeph without exposing Conduit calls.

Test Plan:
  - Viewed Conduit console; uninstalled some applications and verified their calls dropped out.
  - Tried to make an uninstalled call; got an appropriate error.

Reviewers: edward, btrahan

Reviewed By: edward

CC: aran

Maniphest Tasks: T2698

Differential Revision: https://secure.phabricator.com/D5302
This commit is contained in:
epriestley 2013-03-13 07:09:05 -07:00
parent 1341c8a6c1
commit 855e085c6f
38 changed files with 215 additions and 43 deletions

View file

@ -143,12 +143,15 @@ phutil_register_library_map(array(
'ConduitAPI_differential_setdiffproperty_Method' => 'applications/differential/conduit/ConduitAPI_differential_setdiffproperty_Method.php',
'ConduitAPI_differential_updaterevision_Method' => 'applications/differential/conduit/ConduitAPI_differential_updaterevision_Method.php',
'ConduitAPI_differential_updateunitresults_Method' => 'applications/differential/conduit/ConduitAPI_differential_updateunitresults_Method.php',
'ConduitAPI_diffusion_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_Method.php',
'ConduitAPI_diffusion_findsymbols_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_findsymbols_Method.php',
'ConduitAPI_diffusion_getcommits_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php',
'ConduitAPI_diffusion_getlintmessages_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_getlintmessages_Method.php',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php',
'ConduitAPI_feed_Method' => 'applications/feed/conduit/ConduitAPI_feed_Method.php',
'ConduitAPI_feed_publish_Method' => 'applications/feed/conduit/ConduitAPI_feed_publish_Method.php',
'ConduitAPI_feed_query_Method' => 'applications/feed/conduit/ConduitAPI_feed_query_Method.php',
'ConduitAPI_file_Method' => 'applications/files/conduit/ConduitAPI_file_Method.php',
'ConduitAPI_file_download_Method' => 'applications/files/conduit/ConduitAPI_file_download_Method.php',
'ConduitAPI_file_info_Method' => 'applications/files/conduit/ConduitAPI_file_info_Method.php',
'ConduitAPI_file_upload_Method' => 'applications/files/conduit/ConduitAPI_file_upload_Method.php',
@ -166,6 +169,7 @@ phutil_register_library_map(array(
'ConduitAPI_maniphest_info_Method' => 'applications/maniphest/conduit/ConduitAPI_maniphest_info_Method.php',
'ConduitAPI_maniphest_query_Method' => 'applications/maniphest/conduit/ConduitAPI_maniphest_query_Method.php',
'ConduitAPI_maniphest_update_Method' => 'applications/maniphest/conduit/ConduitAPI_maniphest_update_Method.php',
'ConduitAPI_owners_Method' => 'applications/owners/conduit/ConduitAPI_owners_Method.php',
'ConduitAPI_owners_query_Method' => 'applications/owners/conduit/ConduitAPI_owners_query_Method.php',
'ConduitAPI_paste_Method' => 'applications/paste/conduit/ConduitAPI_paste_Method.php',
'ConduitAPI_paste_create_Method' => 'applications/paste/conduit/ConduitAPI_paste_create_Method.php',
@ -175,6 +179,7 @@ phutil_register_library_map(array(
'ConduitAPI_phid_info_Method' => 'applications/phid/conduit/ConduitAPI_phid_info_Method.php',
'ConduitAPI_phid_lookup_Method' => 'applications/phid/conduit/ConduitAPI_phid_lookup_Method.php',
'ConduitAPI_phid_query_Method' => 'applications/phid/conduit/ConduitAPI_phid_query_Method.php',
'ConduitAPI_phpast_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_Method.php',
'ConduitAPI_phpast_getast_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_getast_Method.php',
'ConduitAPI_phpast_version_Method' => 'applications/phpast/conduit/ConduitAPI_phpast_version_Method.php',
'ConduitAPI_phriction_Method' => 'applications/phriction/conduit/ConduitAPI_phriction_Method.php',
@ -187,6 +192,7 @@ phutil_register_library_map(array(
'ConduitAPI_repository_Method' => 'applications/repository/conduit/ConduitAPI_repository_Method.php',
'ConduitAPI_repository_create_Method' => 'applications/repository/conduit/ConduitAPI_repository_create_Method.php',
'ConduitAPI_repository_query_Method' => 'applications/repository/conduit/ConduitAPI_repository_query_Method.php',
'ConduitAPI_slowvote_Method' => 'applications/slowvote/conduit/ConduitAPI_slowvote_Method.php',
'ConduitAPI_slowvote_info_Method' => 'applications/slowvote/conduit/ConduitAPI_slowvote_info_Method.php',
'ConduitAPI_token_Method' => 'applications/tokens/conduit/ConduitAPI_token_Method.php',
'ConduitAPI_token_give_Method' => 'applications/tokens/conduit/ConduitAPI_token_give_Method.php',
@ -1709,16 +1715,19 @@ phutil_register_library_map(array(
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_findsymbols_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getlintmessages_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod',
'ConduitAPI_feed_publish_Method' => 'ConduitAPIMethod',
'ConduitAPI_feed_query_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_download_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_info_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_uploadhash_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_findsymbols_Method' => 'ConduitAPI_diffusion_Method',
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPI_diffusion_Method',
'ConduitAPI_diffusion_getlintmessages_Method' => 'ConduitAPI_diffusion_Method',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPI_diffusion_Method',
'ConduitAPI_feed_Method' => 'ConduitAPIMethod',
'ConduitAPI_feed_publish_Method' => 'ConduitAPI_feed_Method',
'ConduitAPI_feed_query_Method' => 'ConduitAPI_feed_Method',
'ConduitAPI_file_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_download_Method' => 'ConduitAPI_file_Method',
'ConduitAPI_file_info_Method' => 'ConduitAPI_file_Method',
'ConduitAPI_file_upload_Method' => 'ConduitAPI_file_Method',
'ConduitAPI_file_uploadhash_Method' => 'ConduitAPI_file_Method',
'ConduitAPI_flag_Method' => 'ConduitAPIMethod',
'ConduitAPI_flag_delete_Method' => 'ConduitAPI_flag_Method',
'ConduitAPI_flag_edit_Method' => 'ConduitAPI_flag_Method',
@ -1732,7 +1741,8 @@ phutil_register_library_map(array(
'ConduitAPI_maniphest_info_Method' => 'ConduitAPI_maniphest_Method',
'ConduitAPI_maniphest_query_Method' => 'ConduitAPI_maniphest_Method',
'ConduitAPI_maniphest_update_Method' => 'ConduitAPI_maniphest_Method',
'ConduitAPI_owners_query_Method' => 'ConduitAPIMethod',
'ConduitAPI_owners_Method' => 'ConduitAPIMethod',
'ConduitAPI_owners_query_Method' => 'ConduitAPI_owners_Method',
'ConduitAPI_paste_Method' => 'ConduitAPIMethod',
'ConduitAPI_paste_create_Method' => 'ConduitAPI_paste_Method',
'ConduitAPI_paste_info_Method' => 'ConduitAPI_paste_Method',
@ -1741,6 +1751,7 @@ phutil_register_library_map(array(
'ConduitAPI_phid_info_Method' => 'ConduitAPI_phid_Method',
'ConduitAPI_phid_lookup_Method' => 'ConduitAPI_phid_Method',
'ConduitAPI_phid_query_Method' => 'ConduitAPI_phid_Method',
'ConduitAPI_phpast_Method' => 'ConduitAPIMethod',
'ConduitAPI_phpast_getast_Method' => 'ConduitAPIMethod',
'ConduitAPI_phpast_version_Method' => 'ConduitAPIMethod',
'ConduitAPI_phriction_Method' => 'ConduitAPIMethod',
@ -1753,7 +1764,8 @@ phutil_register_library_map(array(
'ConduitAPI_repository_Method' => 'ConduitAPIMethod',
'ConduitAPI_repository_create_Method' => 'ConduitAPI_repository_Method',
'ConduitAPI_repository_query_Method' => 'ConduitAPI_repository_Method',
'ConduitAPI_slowvote_info_Method' => 'ConduitAPIMethod',
'ConduitAPI_slowvote_Method' => 'ConduitAPIMethod',
'ConduitAPI_slowvote_info_Method' => 'ConduitAPI_slowvote_Method',
'ConduitAPI_token_Method' => 'ConduitAPIMethod',
'ConduitAPI_token_give_Method' => 'ConduitAPI_token_Method',
'ConduitAPI_token_given_Method' => 'ConduitAPI_token_Method',

View file

@ -5,5 +5,8 @@
*/
abstract class ConduitAPI_audit_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorApplicationAudit');
}
}

View file

@ -63,16 +63,14 @@ abstract class PhabricatorApplication {
}
public function isInstalled() {
$uninstalled =
PhabricatorEnv::getEnvConfig('phabricator.uninstalled-applications');
$uninstalled = PhabricatorEnv::getEnvConfig(
'phabricator.uninstalled-applications');
if (!$this->canUninstall()) {
return true;
} else if (isset($uninstalled[get_class($this)])) {
return false;
} else {
return true;
}
if (!$this->canUninstall()) {
return true;
}
return empty($uninstalled[get_class($this)]);
}
public function isBeta() {
@ -234,7 +232,6 @@ abstract class PhabricatorApplication {
/* -( Application Management )--------------------------------------------- */
public static function getByClass($class_name) {
$selected = null;
$applications = PhabricatorApplication::getAllApplications();
@ -273,12 +270,11 @@ abstract class PhabricatorApplication {
public static function getAllInstalledApplications() {
static $applications;
$show_beta =
PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
$uninstalled =
PhabricatorEnv::getEnvConfig('phabricator.uninstalled-applications');
$show_beta = PhabricatorEnv::getEnvConfig(
'phabricator.show-beta-applications');
$uninstalled = PhabricatorEnv::getEnvConfig(
'phabricator.uninstalled-applications');
if (empty($applications)) {
$all_applications = self::getAllApplications();

View file

@ -5,4 +5,8 @@
*/
abstract class ConduitAPI_chatlog_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorApplicationChatlog');
}
}

View file

@ -93,10 +93,18 @@ final class ConduitCall {
if (!($method instanceof ConduitAPIMethod)) {
throw new ConduitException(
"Method '{$method}' is not valid; the implementation must be ".
"Method '{$method_class}' is not valid; the implementation must be ".
"a subclass of ConduitAPIMethod.");
}
$application = $method->getApplication();
if ($application && !$application->isInstalled()) {
$app_name = $application->getName();
throw new ConduitException(
"Method '{$method_class}' belongs to application '{$app_name}', ".
"which is not installed.");
}
return $method;
}

View file

@ -86,6 +86,12 @@ abstract class PhabricatorConduitController extends PhabricatorController {
$group_name = head(explode('.', $method_name));
$method_object = newv($method_class, array());
$application = $method_object->getApplication();
if ($application && !$application->isInstalled()) {
continue;
}
$status = $method_object->getMethodStatus();
$key = sprintf(

View file

@ -75,6 +75,17 @@ abstract class ConduitAPIMethod {
return false;
}
/**
* Optionally, return a @{class:PhabricatorApplication} which this call is
* part of. The call will be disabled when the application is uninstalled.
*
* @return PhabricatorApplication|null Related application.
*/
public function getApplication() {
return null;
}
public static function getAPIMethodNameFromClassName($class_name) {
$match = null;
$is_valid = preg_match(

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_differential_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationDifferential');
}
protected function buildDiffInfoDictionary(DifferentialDiff $diff) {
$uri = '/differential/diff/'.$diff->getID().'/';
$uri = PhabricatorEnv::getProductionURI($uri);
@ -15,7 +20,6 @@ abstract class ConduitAPI_differential_Method extends ConduitAPIMethod {
);
}
protected function buildInlineInfoDictionary(
DifferentialInlineComment $inline,
DifferentialChangeset $changeset = null) {

View file

@ -0,0 +1,14 @@
<?php
/**
* @group conduit
*/
abstract class ConduitAPI_diffusion_Method
extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationDiffusion');
}
}

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_diffusion_findsymbols_Method
extends ConduitAPIMethod {
extends ConduitAPI_diffusion_Method {
public function getMethodDescription() {
return "Retrieve Diffusion symbol information.";

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_diffusion_getcommits_Method
extends ConduitAPIMethod {
extends ConduitAPI_diffusion_Method {
public function getMethodDescription() {
return "Retrieve Diffusion commit information.";

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_diffusion_getlintmessages_Method
extends ConduitAPIMethod {
extends ConduitAPI_diffusion_Method {
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_diffusion_getrecentcommitsbypath_Method
extends ConduitAPIMethod {
extends ConduitAPI_diffusion_Method {
const DEFAULT_LIMIT = 10;

View file

@ -0,0 +1,13 @@
<?php
/**
* @group conduit
*/
abstract class ConduitAPI_feed_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationFeed');
}
}

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_feed_publish_Method
extends ConduitAPIMethod {
extends ConduitAPI_feed_Method {
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;

View file

@ -3,7 +3,8 @@
/**
* @group conduit
*/
final class ConduitAPI_feed_query_Method extends ConduitAPIMethod {
final class ConduitAPI_feed_query_Method
extends ConduitAPI_feed_Method {
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;

View file

@ -0,0 +1,10 @@
<?php
abstract class ConduitAPI_file_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationFiles');
}
}

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_file_download_Method
extends ConduitAPIMethod {
extends ConduitAPI_file_Method {
public function getMethodDescription() {
return "Download a file from the server.";

View file

@ -3,7 +3,7 @@
/**
* @group conduit
*/
final class ConduitAPI_file_info_Method extends ConduitAPIMethod {
final class ConduitAPI_file_info_Method extends ConduitAPI_file_Method {
public function getMethodDescription() {
return "Get information about a file.";

View file

@ -3,7 +3,7 @@
/**
* @group conduit
*/
final class ConduitAPI_file_upload_Method extends ConduitAPIMethod {
final class ConduitAPI_file_upload_Method extends ConduitAPI_file_Method {
public function getMethodDescription() {
return "Upload a file to the server.";

View file

@ -3,7 +3,7 @@
/**
* @group conduit
*/
final class ConduitAPI_file_uploadhash_Method extends ConduitAPIMethod {
final class ConduitAPI_file_uploadhash_Method extends ConduitAPI_file_Method {
public function getMethodDescription() {
return "Upload a file to the server using content hash.";

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_flag_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationFlag');
}
protected function attachHandleToFlag($flag, PhabricatorUser $user) {
$flag->attachHandle(
PhabricatorObjectHandleData::loadOneHandle(

View file

@ -5,5 +5,10 @@
*/
abstract class ConduitAPI_macro_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationMacro');
}
}

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationManiphest');
}
public function defineErrorTypes() {
return array(
'ERR-INVALID-PARAMETER' => 'Missing or malformed parameter.'

View file

@ -0,0 +1,11 @@
<?php
abstract class ConduitAPI_owners_Method
extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationOwners');
}
}

View file

@ -4,7 +4,7 @@
* @group conduit
*/
final class ConduitAPI_owners_query_Method
extends ConduitAPIMethod {
extends ConduitAPI_owners_Method {
public function getMethodDescription() {
return 'Query for packages by one of the following: repository/path, ' .

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_paste_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationPaste');
}
protected function buildPasteInfoDictionary(PhabricatorPaste $paste) {
return array(
'id' => $paste->getID(),

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_user_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationPeople');
}
protected function buildUserInformationDictionary(
PhabricatorUser $user,
PhabricatorUserStatus $current_status = null) {

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_phid_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationPHID');
}
protected function buildHandleInformationDictionary(
PhabricatorObjectHandle $handle) {

View file

@ -0,0 +1,13 @@
<?php
/**
* @group conduit
*/
abstract class ConduitAPI_phpast_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationPHPAST');
}
}

View file

@ -3,7 +3,8 @@
/**
* @group conduit
*/
final class ConduitAPI_phpast_getast_Method extends ConduitAPIMethod {
final class ConduitAPI_phpast_getast_Method
extends ConduitAPI_phpast_Method {
public function getMethodDescription() {
return "Parse a piece of PHP code.";

View file

@ -3,7 +3,8 @@
/**
* @group conduit
*/
final class ConduitAPI_phpast_version_Method extends ConduitAPIMethod {
final class ConduitAPI_phpast_version_Method
extends ConduitAPI_phpast_Method {
public function getMethodDescription() {
return "Get server xhpast version.";

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_phriction_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationPhriction');
}
final protected function buildDocumentInfoDictionary(PhrictionDocument $doc) {
$content = $doc->getContent();
return $this->buildDocumentContentDictionary($doc, $content);

View file

@ -5,6 +5,11 @@
*/
abstract class ConduitAPI_project_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationProject');
}
protected function buildProjectInfoDictionary(PhabricatorProject $project) {
$results = $this->buildProjectInfoDictionaries(array($project));
return idx($results, $project->getPHID());

View file

@ -5,4 +5,9 @@
*/
abstract class ConduitAPI_repository_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationRepository');
}
}

View file

@ -0,0 +1,13 @@
<?php
/**
* @group conduit
*/
abstract class ConduitAPI_slowvote_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationSlowvote');
}
}

View file

@ -3,7 +3,8 @@
/**
* @group conduit
*/
final class ConduitAPI_slowvote_info_Method extends ConduitAPIMethod {
final class ConduitAPI_slowvote_info_Method
extends ConduitAPI_slowvote_Method {
public function getMethodDescription() {
return "Retrieve an array of information about a poll.";

View file

@ -2,6 +2,11 @@
abstract class ConduitAPI_token_Method extends ConduitAPIMethod {
public function getApplication() {
return PhabricatorApplication::getByClass(
'PhabricatorApplicationTokens');
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}