aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-18 10:47:49 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-08-23 19:44:04 +0200
commit9b8ca9ad1f3df5d32df241d8848c8dc92c9a1fc2 (patch)
tree72aa5edaaa4b3c3ded5931c6914988ac9dce9467 /lib/private/legacy
parent604c1752845df068a7dd5d168abfbfc04065ac3f (diff)
downloadnextcloud-server-9b8ca9ad1f3df5d32df241d8848c8dc92c9a1fc2.tar.gz
nextcloud-server-9b8ca9ad1f3df5d32df241d8848c8dc92c9a1fc2.zip
Move findBinaryFinder and isFunctionEnabled away from OC_Helper
findBinaryFinder is now a service that is still private but with some minor optimization (remove the hasKey check). isFunctionEnabled is now in OCP\Util Both function are still keep but all internal usage in nextcloud/server were migrated to the new usage, so that we can remove it in 26 Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_Helper.php44
1 files changed, 8 insertions, 36 deletions
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 226f73a0711..710225c7474 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -47,9 +47,9 @@ use bantu\IniGetWrapper\IniGetWrapper;
use OC\Files\Filesystem;
use OCP\Files\Mount\IMountPoint;
use OCP\ICacheFactory;
+use OCP\IBinaryFinder;
use OCP\IUser;
use Psr\Log\LoggerInterface;
-use Symfony\Component\Process\ExecutableFinder;
/**
* Collection of useful functions
@@ -434,47 +434,19 @@ class OC_Helper {
/**
* Checks if a function is available
*
- * @param string $function_name
- * @return bool
+ * @deprecated Since 25.0.0 use \OCP\Util::isFunctionEnabled instead
*/
- public static function is_function_enabled($function_name) {
- if (!function_exists($function_name)) {
- return false;
- }
- $ini = \OC::$server->get(IniGetWrapper::class);
- $disabled = explode(',', $ini->get('disable_functions') ?: '');
- $disabled = array_map('trim', $disabled);
- if (in_array($function_name, $disabled)) {
- return false;
- }
- $disabled = explode(',', $ini->get('suhosin.executor.func.blacklist') ?: '');
- $disabled = array_map('trim', $disabled);
- if (in_array($function_name, $disabled)) {
- return false;
- }
- return true;
+ public static function is_function_enabled(string $function_name): bool {
+ return \OCP\Util::isFunctionEnabled($function_name);
}
/**
* Try to find a program
- *
- * @param string $program
- * @return null|string
+ * @deprecated Since 25.0.0 Use \OC\BinaryFinder directly
*/
- public static function findBinaryPath($program) {
- $memcache = \OC::$server->getMemCacheFactory()->createDistributed('findBinaryPath');
- if ($memcache->hasKey($program)) {
- return $memcache->get($program);
- }
- $result = null;
- if (self::is_function_enabled('exec')) {
- $exeSniffer = new ExecutableFinder();
- // Returns null if nothing is found
- $result = $exeSniffer->find($program, null, ['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/opt/bin']);
- }
- // store the value for 5 minutes
- $memcache->set($program, $result, 300);
- return $result;
+ public static function findBinaryPath(string $program): ?string {
+ $result = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath($program);
+ return $result !== false ? $result : null;
}
/**