diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f5eab22184..6f784b2a3e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/audit/conduit/ConduitAPI_audit_Method.php b/src/applications/audit/conduit/ConduitAPI_audit_Method.php index 8faccd83b5..1fe6c9fcc9 100644 --- a/src/applications/audit/conduit/ConduitAPI_audit_Method.php +++ b/src/applications/audit/conduit/ConduitAPI_audit_Method.php @@ -5,5 +5,8 @@ */ abstract class ConduitAPI_audit_Method extends ConduitAPIMethod { + public function getApplication() { + return PhabricatorApplication::getByClass('PhabricatorApplicationAudit'); + } } diff --git a/src/applications/base/PhabricatorApplication.php b/src/applications/base/PhabricatorApplication.php index daa9e67cfd..7624d51f12 100644 --- a/src/applications/base/PhabricatorApplication.php +++ b/src/applications/base/PhabricatorApplication.php @@ -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(); diff --git a/src/applications/chatlog/conduit/ConduitAPI_chatlog_Method.php b/src/applications/chatlog/conduit/ConduitAPI_chatlog_Method.php index c50a4aba26..2d86a0ca24 100644 --- a/src/applications/chatlog/conduit/ConduitAPI_chatlog_Method.php +++ b/src/applications/chatlog/conduit/ConduitAPI_chatlog_Method.php @@ -5,4 +5,8 @@ */ abstract class ConduitAPI_chatlog_Method extends ConduitAPIMethod { + public function getApplication() { + return PhabricatorApplication::getByClass('PhabricatorApplicationChatlog'); + } + } diff --git a/src/applications/conduit/call/ConduitCall.php b/src/applications/conduit/call/ConduitCall.php index ddd3de8ee6..29172c53e3 100644 --- a/src/applications/conduit/call/ConduitCall.php +++ b/src/applications/conduit/call/ConduitCall.php @@ -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; } diff --git a/src/applications/conduit/controller/PhabricatorConduitController.php b/src/applications/conduit/controller/PhabricatorConduitController.php index c76114d47d..a4d61e05bb 100644 --- a/src/applications/conduit/controller/PhabricatorConduitController.php +++ b/src/applications/conduit/controller/PhabricatorConduitController.php @@ -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( diff --git a/src/applications/conduit/method/ConduitAPIMethod.php b/src/applications/conduit/method/ConduitAPIMethod.php index 96ccd22fe4..452717d34d 100644 --- a/src/applications/conduit/method/ConduitAPIMethod.php +++ b/src/applications/conduit/method/ConduitAPIMethod.php @@ -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( diff --git a/src/applications/differential/conduit/ConduitAPI_differential_Method.php b/src/applications/differential/conduit/ConduitAPI_differential_Method.php index a75b80b3f7..589d86092d 100644 --- a/src/applications/differential/conduit/ConduitAPI_differential_Method.php +++ b/src/applications/differential/conduit/ConduitAPI_differential_Method.php @@ -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) { diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_Method.php new file mode 100644 index 0000000000..cdae68c5d6 --- /dev/null +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_Method.php @@ -0,0 +1,14 @@ +attachHandle( PhabricatorObjectHandleData::loadOneHandle( diff --git a/src/applications/macro/conduit/ConduitAPI_macro_Method.php b/src/applications/macro/conduit/ConduitAPI_macro_Method.php index c79d05c755..d3cb77c122 100644 --- a/src/applications/macro/conduit/ConduitAPI_macro_Method.php +++ b/src/applications/macro/conduit/ConduitAPI_macro_Method.php @@ -5,5 +5,10 @@ */ abstract class ConduitAPI_macro_Method extends ConduitAPIMethod { + public function getApplication() { + return PhabricatorApplication::getByClass( + 'PhabricatorApplicationMacro'); + } + } diff --git a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php index 65e8d0f1b3..ce40e62d74 100644 --- a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php +++ b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php @@ -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.' diff --git a/src/applications/owners/conduit/ConduitAPI_owners_Method.php b/src/applications/owners/conduit/ConduitAPI_owners_Method.php new file mode 100644 index 0000000000..b24d89c316 --- /dev/null +++ b/src/applications/owners/conduit/ConduitAPI_owners_Method.php @@ -0,0 +1,11 @@ + $paste->getID(), diff --git a/src/applications/people/conduit/ConduitAPI_user_Method.php b/src/applications/people/conduit/ConduitAPI_user_Method.php index a073726645..a8207f4174 100644 --- a/src/applications/people/conduit/ConduitAPI_user_Method.php +++ b/src/applications/people/conduit/ConduitAPI_user_Method.php @@ -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) { diff --git a/src/applications/phid/conduit/ConduitAPI_phid_Method.php b/src/applications/phid/conduit/ConduitAPI_phid_Method.php index fc32bebf16..bbb2a02b8c 100644 --- a/src/applications/phid/conduit/ConduitAPI_phid_Method.php +++ b/src/applications/phid/conduit/ConduitAPI_phid_Method.php @@ -5,6 +5,11 @@ */ abstract class ConduitAPI_phid_Method extends ConduitAPIMethod { + public function getApplication() { + return PhabricatorApplication::getByClass( + 'PhabricatorApplicationPHID'); + } + protected function buildHandleInformationDictionary( PhabricatorObjectHandle $handle) { diff --git a/src/applications/phpast/conduit/ConduitAPI_phpast_Method.php b/src/applications/phpast/conduit/ConduitAPI_phpast_Method.php new file mode 100644 index 0000000000..4b2bef965c --- /dev/null +++ b/src/applications/phpast/conduit/ConduitAPI_phpast_Method.php @@ -0,0 +1,13 @@ +getContent(); return $this->buildDocumentContentDictionary($doc, $content); diff --git a/src/applications/project/conduit/ConduitAPI_project_Method.php b/src/applications/project/conduit/ConduitAPI_project_Method.php index 44f75069a6..1cc89e6d5f 100644 --- a/src/applications/project/conduit/ConduitAPI_project_Method.php +++ b/src/applications/project/conduit/ConduitAPI_project_Method.php @@ -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()); diff --git a/src/applications/repository/conduit/ConduitAPI_repository_Method.php b/src/applications/repository/conduit/ConduitAPI_repository_Method.php index 7e220a8843..d60edcbced 100644 --- a/src/applications/repository/conduit/ConduitAPI_repository_Method.php +++ b/src/applications/repository/conduit/ConduitAPI_repository_Method.php @@ -5,4 +5,9 @@ */ abstract class ConduitAPI_repository_Method extends ConduitAPIMethod { + public function getApplication() { + return PhabricatorApplication::getByClass( + 'PhabricatorApplicationRepository'); + } + } diff --git a/src/applications/slowvote/conduit/ConduitAPI_slowvote_Method.php b/src/applications/slowvote/conduit/ConduitAPI_slowvote_Method.php new file mode 100644 index 0000000000..3302de75a2 --- /dev/null +++ b/src/applications/slowvote/conduit/ConduitAPI_slowvote_Method.php @@ -0,0 +1,13 @@ +