From 1e181f0781ca3d603ae0691d90afd2edd47d380b Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 4 Apr 2017 14:34:24 -0700 Subject: [PATCH] Deprecate "file.uploadhash" Summary: Ref T12464. This is a very old method which let you create a file on the server by referring to data which already existed in another file. Basically, long ago, `arc` could say "Do you already have a file with hash X?" and just skip some work if the server did. `arc` has not called this method since D13017, in May 2015. Since it's easy to do so, just make this method pretend that it never has the file. Very old clients will continue to work, since they would expect this response in the common case and continue by uploading data. Test Plan: - Grepped for `uploadhash` in Phabricator and Arcanist. - Called the method with the console, verified it returned `null`. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12464 Differential Revision: https://secure.phabricator.com/D17618 --- .../FileUploadHashConduitAPIMethod.php | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/applications/files/conduit/FileUploadHashConduitAPIMethod.php b/src/applications/files/conduit/FileUploadHashConduitAPIMethod.php index 135e018a2f..db7a6acecb 100644 --- a/src/applications/files/conduit/FileUploadHashConduitAPIMethod.php +++ b/src/applications/files/conduit/FileUploadHashConduitAPIMethod.php @@ -3,12 +3,21 @@ final class FileUploadHashConduitAPIMethod extends FileConduitAPIMethod { public function getAPIMethodName() { - // TODO: Deprecate this in favor of `file.allocate`. return 'file.uploadhash'; } + public function getMethodStatus() { + return self::METHOD_STATUS_DEPRECATED; + } + + public function getMethodStatusDescription() { + return pht( + 'This method is deprecated. Callers should use "file.allocate" '. + 'instead.'); + } + public function getMethodDescription() { - return pht('Upload a file to the server using content hash.'); + return pht('Obsolete. Has no effect.'); } protected function defineParamTypes() { @@ -19,25 +28,11 @@ final class FileUploadHashConduitAPIMethod extends FileConduitAPIMethod { } protected function defineReturnType() { - return 'phid or null'; + return 'null'; } protected function execute(ConduitAPIRequest $request) { - $hash = $request->getValue('hash'); - $name = $request->getValue('name'); - $user = $request->getUser(); - - $file = PhabricatorFile::newFileFromContentHash( - $hash, - array( - 'name' => $name, - 'authorPHID' => $user->getPHID(), - )); - - if ($file) { - return $file->getPHID(); - } - return $file; + return null; } }