@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide a modern ("v3") API for querying files ("file.search")

Summary: Ref T11357. Implements a modern `file.search` for files, and freezes `file.info`.

Test Plan: Ran `file.search` from the Conduit console.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11357

Differential Revision: https://secure.phabricator.com/D17612

+66 -1
+3
src/__phutil_library_map__.php
··· 2770 2770 'PhabricatorFileROT13StorageFormat' => 'applications/files/format/PhabricatorFileROT13StorageFormat.php', 2771 2771 'PhabricatorFileRawStorageFormat' => 'applications/files/format/PhabricatorFileRawStorageFormat.php', 2772 2772 'PhabricatorFileSchemaSpec' => 'applications/files/storage/PhabricatorFileSchemaSpec.php', 2773 + 'PhabricatorFileSearchConduitAPIMethod' => 'applications/files/conduit/PhabricatorFileSearchConduitAPIMethod.php', 2773 2774 'PhabricatorFileSearchEngine' => 'applications/files/query/PhabricatorFileSearchEngine.php', 2774 2775 'PhabricatorFileStorageBlob' => 'applications/files/storage/PhabricatorFileStorageBlob.php', 2775 2776 'PhabricatorFileStorageConfigurationException' => 'applications/files/exception/PhabricatorFileStorageConfigurationException.php', ··· 7847 7848 'PhabricatorFlaggableInterface', 7848 7849 'PhabricatorPolicyInterface', 7849 7850 'PhabricatorDestructibleInterface', 7851 + 'PhabricatorConduitResultInterface', 7850 7852 ), 7851 7853 'PhabricatorFileAES256StorageFormat' => 'PhabricatorFileStorageFormat', 7852 7854 'PhabricatorFileBundleLoader' => 'Phobject', ··· 7897 7899 'PhabricatorFileROT13StorageFormat' => 'PhabricatorFileStorageFormat', 7898 7900 'PhabricatorFileRawStorageFormat' => 'PhabricatorFileStorageFormat', 7899 7901 'PhabricatorFileSchemaSpec' => 'PhabricatorConfigSchemaSpec', 7902 + 'PhabricatorFileSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 7900 7903 'PhabricatorFileSearchEngine' => 'PhabricatorApplicationSearchEngine', 7901 7904 'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO', 7902 7905 'PhabricatorFileStorageConfigurationException' => 'Exception',
+10
src/applications/files/conduit/FileInfoConduitAPIMethod.php
··· 10 10 return pht('Get information about a file.'); 11 11 } 12 12 13 + public function getMethodStatus() { 14 + return self::METHOD_STATUS_FROZEN; 15 + } 16 + 17 + public function getMethodStatusDescription() { 18 + return pht( 19 + 'This method is frozen and will eventually be deprecated. New code '. 20 + 'should use "file.search" instead.'); 21 + } 22 + 13 23 protected function defineParamTypes() { 14 24 return array( 15 25 'phid' => 'optional phid',
+18
src/applications/files/conduit/PhabricatorFileSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class PhabricatorFileSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'file.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new PhabricatorFileSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Read information about files.'); 16 + } 17 + 18 + }
+35 -1
src/applications/files/storage/PhabricatorFile.php
··· 24 24 PhabricatorSubscribableInterface, 25 25 PhabricatorFlaggableInterface, 26 26 PhabricatorPolicyInterface, 27 - PhabricatorDestructibleInterface { 27 + PhabricatorDestructibleInterface, 28 + PhabricatorConduitResultInterface { 28 29 29 30 const METADATA_IMAGE_WIDTH = 'width'; 30 31 const METADATA_IMAGE_HEIGHT = 'height'; ··· 1466 1467 $this->openTransaction(); 1467 1468 $this->delete(); 1468 1469 $this->saveTransaction(); 1470 + } 1471 + 1472 + 1473 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 1474 + 1475 + 1476 + public function getFieldSpecificationsForConduit() { 1477 + return array( 1478 + id(new PhabricatorConduitSearchFieldSpecification()) 1479 + ->setKey('name') 1480 + ->setType('string') 1481 + ->setDescription(pht('The name of the file.')), 1482 + id(new PhabricatorConduitSearchFieldSpecification()) 1483 + ->setKey('dataURI') 1484 + ->setType('string') 1485 + ->setDescription(pht('Download URI for the file data.')), 1486 + id(new PhabricatorConduitSearchFieldSpecification()) 1487 + ->setKey('size') 1488 + ->setType('int') 1489 + ->setDescription(pht('File size, in bytes.')), 1490 + ); 1491 + } 1492 + 1493 + public function getFieldValuesForConduit() { 1494 + return array( 1495 + 'name' => $this->getName(), 1496 + 'dataURI' => $this->getCDNURI(), 1497 + 'size' => (int)$this->getByteSize(), 1498 + ); 1499 + } 1500 + 1501 + public function getConduitSearchAttachments() { 1502 + return array(); 1469 1503 } 1470 1504 1471 1505 }