Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2618967
D25097.1731627228.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
7 KB
Referenced Files
None
Subscribers
None
D25097.1731627228.diff
View Options
diff --git a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php
--- a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php
+++ b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php
@@ -25,17 +25,17 @@
}
public function canWriteFiles() {
- $bucket = PhabricatorEnv::getEnvConfig('storage.s3.bucket');
- $access_key = PhabricatorEnv::getEnvConfig('amazon-s3.access-key');
- $secret_key = PhabricatorEnv::getEnvConfig('amazon-s3.secret-key');
- $endpoint = PhabricatorEnv::getEnvConfig('amazon-s3.endpoint');
- $region = PhabricatorEnv::getEnvConfig('amazon-s3.region');
-
- return (strlen($bucket) &&
- strlen($access_key) &&
- strlen($secret_key) &&
- strlen($endpoint) &&
- strlen($region));
+ $bucket = PhabricatorEnv::getEnvConfigStr('storage.s3.bucket');
+ $access_key = PhabricatorEnv::getEnvConfigStr('amazon-s3.access-key');
+ $secret_key = PhabricatorEnv::getEnvConfigStr('amazon-s3.secret-key');
+ $endpoint = PhabricatorEnv::getEnvConfigStr('amazon-s3.endpoint');
+ $region = PhabricatorEnv::getEnvConfigStr('amazon-s3.region');
+
+ return $bucket !== '' &&
+ $access_key !== '' &&
+ $secret_key !== '' &&
+ $endpoint !== '' &&
+ $region !== '';
}
@@ -56,8 +56,8 @@
$parts = array();
$parts[] = 'phabricator';
- $instance_name = PhabricatorEnv::getEnvConfig('cluster.instance');
- if (strlen($instance_name)) {
+ $instance_name = PhabricatorEnv::getEnvConfigStr('cluster.instance');
+ if ($instance_name !== '') {
$parts[] = $instance_name;
}
@@ -139,7 +139,7 @@
* @task internal
*/
private function getBucketName() {
- $bucket = PhabricatorEnv::getEnvConfig('storage.s3.bucket');
+ $bucket = PhabricatorEnv::getEnvConfigStr('storage.s3.bucket');
if (!$bucket) {
throw new PhabricatorFileStorageConfigurationException(
pht(
@@ -155,10 +155,10 @@
* @task internal
*/
private function newS3API() {
- $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');
+ $access_key = PhabricatorEnv::getEnvConfigStr('amazon-s3.access-key');
+ $secret_key = PhabricatorEnv::getEnvConfigStr('amazon-s3.secret-key');
+ $region = PhabricatorEnv::getEnvConfigStr('amazon-s3.region');
+ $endpoint = PhabricatorEnv::getEnvConfigStr('amazon-s3.endpoint');
return id(new PhutilAWSS3Future())
->setAccessKey($access_key)
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -855,8 +855,8 @@
// request domain used by the CDN (as with AWS CloudFront). Embedding the
// instance identity in the path allows us to distinguish between requests
// originating from different instances but served through the same CDN.
- $instance = PhabricatorEnv::getEnvConfig('cluster.instance');
- if (strlen($instance)) {
+ $instance = PhabricatorEnv::getEnvConfigStr('cluster.instance');
+ if ($instance !== '') {
$parts[] = '@'.$instance;
}
@@ -902,8 +902,8 @@
$parts[] = 'file';
$parts[] = 'xform';
- $instance = PhabricatorEnv::getEnvConfig('cluster.instance');
- if (strlen($instance)) {
+ $instance = PhabricatorEnv::getEnvConfigStr('cluster.instance');
+ if ($instance !== '') {
$parts[] = '@'.$instance;
}
diff --git a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php
--- a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php
+++ b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php
@@ -505,9 +505,8 @@
}
public function newDefaultEmailAddress() {
- $raw_address = PhabricatorEnv::getEnvConfig('metamta.default-address');
-
- if (!strlen($raw_address)) {
+ $raw_address = PhabricatorEnv::getEnvConfigStr('metamta.default-address');
+ if (!$raw_address) {
$domain = $this->newMailDomain();
$raw_address = "noreply@{$domain}";
}
@@ -526,8 +525,8 @@
}
private function newMailDomain() {
- $domain = PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain');
- if (strlen($domain)) {
+ $domain = PhabricatorEnv::getEnvConfigStr('metamta.reply-handler-domain');
+ if ($domain) {
return $domain;
}
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -2480,7 +2480,7 @@
$has_https = false;
}
- $has_ssh = (bool)strlen(PhabricatorEnv::getEnvConfig('phd.user'));
+ $has_ssh = PhabricatorEnv::getEnvConfigStr('phd.user') !== '';
$protocol_map = array(
PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH => $has_ssh,
diff --git a/src/infrastructure/cluster/PhabricatorDatabaseRef.php b/src/infrastructure/cluster/PhabricatorDatabaseRef.php
--- a/src/infrastructure/cluster/PhabricatorDatabaseRef.php
+++ b/src/infrastructure/cluster/PhabricatorDatabaseRef.php
@@ -229,7 +229,7 @@
$host = $this->getHost();
$port = $this->getPort();
- if (strlen($port)) {
+ if ($port) {
return "{$host}:{$port}";
}
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -124,8 +124,8 @@
// If an instance identifier is defined, write it into the environment so
// it's available to subprocesses.
- $instance = self::getEnvConfig('cluster.instance');
- if (strlen($instance)) {
+ $instance = self::getEnvConfigStr('cluster.instance');
+ if ($instance !== '') {
putenv('PHABRICATOR_INSTANCE='.$instance);
$_ENV['PHABRICATOR_INSTANCE'] = $instance;
}
@@ -344,11 +344,13 @@
/**
- * Get the current configuration setting for a given key.
+ * Get the current configuration setting for a given key of a generic value.
*
* If the key is not found, then throw an Exception.
*
+ * @param string $key Configuration codename. Example: 'phabricator.base-uri'
* @task read
+ * @return mixed
*/
public static function getEnvConfig($key) {
if (!self::$sourceStack) {
@@ -379,6 +381,21 @@
}
}
+
+ /**
+ * Get the current configuration setting for a given key with a string value.
+ *
+ * If the key is not found, then throw an Exception.
+ *
+ * @param string $key Configuration codename. Example: 'phabricator.base-uri'
+ * @task read
+ * @return string
+ */
+ public static function getEnvConfigStr($key) {
+ return (string)self::getEnvConfig($key);
+ }
+
+
/**
* Get the current configuration setting for a given key. If the key
* does not exist, return a default value instead of throwing. This is
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 14, 23:33 (6 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
970720
Default Alt Text
D25097.1731627228.diff (7 KB)
Attached To
Mode
D25097: PHP 8.2: fixes for strlen() not accepting NULL anymore
Attached
Detach File
Event Timeline
Log In to Comment