Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
Show All 32 Lines | /* -( Configuring Storage )------------------------------------------------ */ | ||||
public static function getDefaultStorageNamespace() { | public static function getDefaultStorageNamespace() { | ||||
return PhabricatorEnv::getEnvConfig('storage.default-namespace'); | return PhabricatorEnv::getEnvConfig('storage.default-namespace'); | ||||
} | } | ||||
/** | /** | ||||
* @task config | * @task config | ||||
*/ | */ | ||||
public static function getStorageNamespace() { | public static function getStorageNamespace() { | ||||
// Do not use phutil_nonempty_string() in the first check, | |||||
// since $namespace can be false, and we should not spawn an exception | |||||
$namespace = end(self::$namespaceStack); | $namespace = end(self::$namespaceStack); | ||||
if (!strlen($namespace)) { | if (!is_string($namespace) || $namespace === '') { | ||||
$namespace = self::getDefaultStorageNamespace(); | $namespace = self::getDefaultStorageNamespace(); | ||||
} | } | ||||
if (!strlen($namespace)) { | if (!phutil_nonempty_string($namespace)) { | ||||
throw new Exception(pht('No storage namespace configured!')); | throw new Exception(pht('No storage namespace configured!')); | ||||
} | } | ||||
return $namespace; | return $namespace; | ||||
} | } | ||||
public function setForcedStorageNamespace($namespace) { | public function setForcedStorageNamespace($namespace) { | ||||
$this->forcedNamespace = $namespace; | $this->forcedNamespace = $namespace; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | public function getTableName() { | ||||
if (!strncmp($class, $str, $len)) { | if (!strncmp($class, $str, $len)) { | ||||
$class = substr($class, $len); | $class = substr($class, $len); | ||||
} | } | ||||
$app = $this->getApplicationName(); | $app = $this->getApplicationName(); | ||||
if (!strncmp($class, $app, strlen($app))) { | if (!strncmp($class, $app, strlen($app))) { | ||||
$class = substr($class, strlen($app)); | $class = substr($class, strlen($app)); | ||||
} | } | ||||
if (strlen($class)) { | if (phutil_nonempty_string($class)) { | ||||
return $app.'_'.$class; | return $app.'_'.$class; | ||||
} else { | } else { | ||||
return $app; | return $app; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @task config | * @task config | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | /* -( Configuring Storage )------------------------------------------------ */ | ||||
} | } | ||||
protected function getUTF8StringFromStorage($string, $encoding) { | protected function getUTF8StringFromStorage($string, $encoding) { | ||||
if ($encoding == 'utf8') { | if ($encoding == 'utf8') { | ||||
return $string; | return $string; | ||||
} | } | ||||
if (function_exists('mb_detect_encoding')) { | if (function_exists('mb_detect_encoding')) { | ||||
if (strlen($encoding)) { | if (phutil_nonempty_string($encoding)) { | ||||
$try_encodings = array( | $try_encodings = array( | ||||
$encoding, | $encoding, | ||||
); | ); | ||||
} else { | } else { | ||||
// TODO: This is pretty much a guess, and probably needs to be | // TODO: This is pretty much a guess, and probably needs to be | ||||
// configurable in the long run. | // configurable in the long run. | ||||
$try_encodings = array( | $try_encodings = array( | ||||
'JIS', | 'JIS', | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0