Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/check/PhabricatorStorageSetupCheck.php
| <?php | <?php | ||||
| final class PhabricatorStorageSetupCheck extends PhabricatorSetupCheck { | final class PhabricatorStorageSetupCheck extends PhabricatorSetupCheck { | ||||
| public function getDefaultGroup() { | public function getDefaultGroup() { | ||||
| return self::GROUP_OTHER; | return self::GROUP_OTHER; | ||||
| } | } | ||||
| /** | /** | ||||
| * @phutil-external-symbol class PhabricatorStartup | * @phutil-external-symbol class PhabricatorStartup | ||||
| */ | */ | ||||
| protected function executeChecks() { | protected function executeChecks() { | ||||
| $engines = PhabricatorFileStorageEngine::loadWritableChunkEngines(); | $engines = PhabricatorFileStorageEngine::loadWritableChunkEngines(); | ||||
| $chunk_engine_active = (bool)$engines; | $chunk_engine_active = (bool)$engines; | ||||
| $this->checkS3(); | |||||
| if (!$chunk_engine_active) { | if (!$chunk_engine_active) { | ||||
| $doc_href = PhabricatorEnv::getDocLink('Configuring File Storage'); | $doc_href = PhabricatorEnv::getDocLink('Configuring File Storage'); | ||||
| $message = pht( | $message = pht( | ||||
| 'Large file storage has not been configured, which will limit '. | 'Large file storage has not been configured, which will limit '. | ||||
| 'the maximum size of file uploads. See %s for '. | 'the maximum size of file uploads. See %s for '. | ||||
| 'instructions on configuring uploads and storage.', | 'instructions on configuring uploads and storage.', | ||||
| phutil_tag( | phutil_tag( | ||||
| ▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | if (!Filesystem::pathExists($local_path) || | ||||
| $this | $this | ||||
| ->newIssue('config.storage.local-disk.path') | ->newIssue('config.storage.local-disk.path') | ||||
| ->setShortName(pht('Local Disk Storage')) | ->setShortName(pht('Local Disk Storage')) | ||||
| ->setName(pht('Local Disk Storage Not Readable/Writable')) | ->setName(pht('Local Disk Storage Not Readable/Writable')) | ||||
| ->setMessage($message) | ->setMessage($message) | ||||
| ->addPhabricatorConfig('storage.local-disk.path'); | ->addPhabricatorConfig('storage.local-disk.path'); | ||||
| } | } | ||||
| } | } | ||||
| private function checkS3() { | |||||
| $access_key = PhabricatorEnv::getEnvConfig('amazon-s3.access-key'); | |||||
| $secret_key = PhabricatorEnv::getEnvConfig('amazon-s3.secret-key'); | |||||
| $region = PhabricatorEnv::getEnvConfig('amazon-s3.region'); | |||||
| $endpoint = PhabricatorEnv::getEnvConfig('amazon-s3.endpoint'); | |||||
| $how_many = 0; | |||||
| if (strlen($access_key)) { | |||||
| $how_many++; | |||||
| } | |||||
| if (strlen($secret_key)) { | |||||
| $how_many++; | |||||
| } | |||||
| if (strlen($region)) { | |||||
| $how_many++; | |||||
| } | |||||
| if (strlen($endpoint)) { | |||||
| $how_many++; | |||||
| } | |||||
| // Nothing configured, no issues here. | |||||
| if ($how_many === 0) { | |||||
| return; | |||||
| } | |||||
| // Everything configured, no issues here. | |||||
| if ($how_many === 4) { | |||||
| return; | |||||
| } | |||||
| $message = pht( | |||||
| 'File storage in Amazon S3 has been partially configured, but you are '. | |||||
| 'missing some required settings. S3 will not be available to store '. | |||||
| 'files until you complete the configuration. Either configure S3 fully '. | |||||
| 'or remove the partial configuration.'); | |||||
| $this->newIssue('storage.s3.partial-config') | |||||
| ->setShortName(pht('S3 Partially Configured')) | |||||
| ->setName(pht('Amazon S3 is Only Partially Configured')) | |||||
| ->setMessage($message) | |||||
| ->addPhabricatorConfig('amazon-s3.access-key') | |||||
| ->addPhabricatorConfig('amazon-s3.secret-key') | |||||
| ->addPhabricatorConfig('amazon-s3.region') | |||||
| ->addPhabricatorConfig('amazon-s3.endpoint'); | |||||
| } | |||||
| } | } | ||||