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>
This commit is contained in:
Carl Schwan 2022-08-18 10:47:49 +02:00
parent 604c175284
commit 9b8ca9ad1f
No known key found for this signature in database
GPG Key ID: C3AA6B3A5EFA7AC5
37 changed files with 277 additions and 200 deletions

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '9586920c0ec4016864a2219e838fb272127822d8',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '9586920c0ec4016864a2219e838fb272127822d8',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'ea4531aaaa6eb9fb3859e05b69ab773bfbfe7437',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'ea4531aaaa6eb9fb3859e05b69ab773bfbfe7437',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'ff67123569a861301d14f83f7b2310e9a518c46d',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'ff67123569a861301d14f83f7b2310e9a518c46d',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '3c77e489a6bb2541cd5d0c92b5498e71ec1a873f',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '3c77e489a6bb2541cd5d0c92b5498e71ec1a873f',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '9915dc6785d1660068a51604f9379e8b1dc1418c',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => '9915dc6785d1660068a51604f9379e8b1dc1418c',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -1,22 +1,22 @@
<?php return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'name' => '__root__',
'dev' => false,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7669331be09dd3cb848182ae8edc2408802a4fb4',
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'c6429e6cd19c57582364338362e543580821cf99',
'dev_requirement' => false,
),
),

View File

@ -410,6 +410,7 @@ return array(
'OCP\\IAppConfig' => $baseDir . '/lib/public/IAppConfig.php',
'OCP\\IAvatar' => $baseDir . '/lib/public/IAvatar.php',
'OCP\\IAvatarManager' => $baseDir . '/lib/public/IAvatarManager.php',
'OCP\\IBinaryFinder' => $baseDir . '/lib/public/IBinaryFinder.php',
'OCP\\ICache' => $baseDir . '/lib/public/ICache.php',
'OCP\\ICacheFactory' => $baseDir . '/lib/public/ICacheFactory.php',
'OCP\\ICertificate' => $baseDir . '/lib/public/ICertificate.php',
@ -803,6 +804,7 @@ return array(
'OC\\BackgroundJob\\Legacy\\RegularJob' => $baseDir . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
'OC\\BackgroundJob\\QueuedJob' => $baseDir . '/lib/private/BackgroundJob/QueuedJob.php',
'OC\\BackgroundJob\\TimedJob' => $baseDir . '/lib/private/BackgroundJob/TimedJob.php',
'OC\\BinaryFinder' => $baseDir . '/lib/private/BinaryFinder.php',
'OC\\Broadcast\\Events\\BroadcastEvent' => $baseDir . '/lib/private/Broadcast/Events/BroadcastEvent.php',
'OC\\Cache\\CappedMemoryCache' => $baseDir . '/lib/private/Cache/CappedMemoryCache.php',
'OC\\Cache\\File' => $baseDir . '/lib/private/Cache/File.php',

View File

@ -443,6 +443,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\IAppConfig' => __DIR__ . '/../../..' . '/lib/public/IAppConfig.php',
'OCP\\IAvatar' => __DIR__ . '/../../..' . '/lib/public/IAvatar.php',
'OCP\\IAvatarManager' => __DIR__ . '/../../..' . '/lib/public/IAvatarManager.php',
'OCP\\IBinaryFinder' => __DIR__ . '/../../..' . '/lib/public/IBinaryFinder.php',
'OCP\\ICache' => __DIR__ . '/../../..' . '/lib/public/ICache.php',
'OCP\\ICacheFactory' => __DIR__ . '/../../..' . '/lib/public/ICacheFactory.php',
'OCP\\ICertificate' => __DIR__ . '/../../..' . '/lib/public/ICertificate.php',
@ -836,6 +837,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\BackgroundJob\\Legacy\\RegularJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/Legacy/RegularJob.php',
'OC\\BackgroundJob\\QueuedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/QueuedJob.php',
'OC\\BackgroundJob\\TimedJob' => __DIR__ . '/../../..' . '/lib/private/BackgroundJob/TimedJob.php',
'OC\\BinaryFinder' => __DIR__ . '/../../..' . '/lib/private/BinaryFinder.php',
'OC\\Broadcast\\Events\\BroadcastEvent' => __DIR__ . '/../../..' . '/lib/private/Broadcast/Events/BroadcastEvent.php',
'OC\\Cache\\CappedMemoryCache' => __DIR__ . '/../../..' . '/lib/private/Cache/CappedMemoryCache.php',
'OC\\Cache\\File' => __DIR__ . '/../../..' . '/lib/private/Cache/File.php',

View File

@ -26,6 +26,7 @@
namespace OC\App;
use OCP\IConfig;
use OCP\IBinaryFinder;
/**
* Class Platform
@ -70,9 +71,8 @@ class Platform {
/**
* @param $command
*/
public function isCommandKnown($command): bool {
$path = \OC_Helper::findBinaryPath($command);
return ($path !== null);
public function isCommandKnown(string $command): bool {
return \OCP\Server::get(IBinaryFinder::class)->findBinaryPath($command) !== false;
}
public function getLibraryVersion(string $name): ?string {

View File

@ -0,0 +1,71 @@
<?php
declare(strict_types = 1);
/**
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IBinaryFinder;
use Symfony\Component\Process\ExecutableFinder;
/**
* Service that find the binary path for a program
*/
class BinaryFinder implements IBinaryFinder {
private ICache $cache;
public function __construct(ICacheFactory $cacheFactory) {
$this->cache = $cacheFactory->createLocal('findBinaryPath');
}
/**
* Try to find a program
*
* @return false|string
*/
public function findBinaryPath(string $program) {
$result = $this->cache->get($program);
if ($result !== null) {
return $result;
}
$result = false;
if (\OCP\Util::isFunctionEnabled('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',
]);
if ($result === null) {
$result = false;
}
}
// store the value for 5 minutes
$this->cache->set($program, $result, 300);
return $result;
}
}

View File

@ -147,7 +147,7 @@ class LargeFileHelper {
* null on failure.
*/
public function getFileSizeViaExec($filename) {
if (\OC_Helper::is_function_enabled('exec')) {
if (\OCP\Util::isFunctionEnabled('exec')) {
$os = strtolower(php_uname('s'));
$arg = escapeshellarg($filename);
$result = null;
@ -195,7 +195,7 @@ class LargeFileHelper {
$result = - 1;
}
if ($result < 0) {
if (\OC_Helper::is_function_enabled('exec')) {
if (\OCP\Util::isFunctionEnabled('exec')) {
$os = strtolower(php_uname('s'));
if (strpos($os, 'linux') !== false) {
return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));

View File

@ -39,6 +39,7 @@ use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\RFCValidation;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@ -71,19 +72,14 @@ use Psr\Log\LoggerInterface;
class Mailer implements IMailer {
/** @var \Swift_Mailer Cached mailer */
private $instance = null;
/** @var IConfig */
private $config;
private IConfig $config;
private LoggerInterface $logger;
/** @var Defaults */
private $defaults;
/** @var IURLGenerator */
private $urlGenerator;
/** @var IL10N */
private $l10n;
/** @var IEventDispatcher */
private $dispatcher;
/** @var IFactory */
private $l10nFactory;
private IURLGenerator $urlGenerator;
private IL10N $l10n;
private IEventDispatcher $dispatcher;
private IFactory $l10nFactory;
public function __construct(IConfig $config,
LoggerInterface $logger,
@ -309,7 +305,7 @@ class Mailer implements IMailer {
$binaryPath = '/var/qmail/bin/sendmail';
break;
default:
$sendmail = \OC_Helper::findBinaryPath('sendmail');
$sendmail = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail');
if ($sendmail === null) {
$sendmail = '/usr/sbin/sendmail';
}

View File

@ -39,6 +39,7 @@ use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IBinaryFinder;
use OCP\IConfig;
use OCP\IPreview;
use OCP\IServerContainer;
@ -47,73 +48,41 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function array_key_exists;
class PreviewManager implements IPreview {
/** @var IConfig */
protected $config;
/** @var IRootFolder */
protected $rootFolder;
/** @var IAppData */
protected $appData;
/** @var EventDispatcherInterface */
protected $eventDispatcher;
/** @var Generator */
private $generator;
/** @var GeneratorHelper */
private $helper;
/** @var bool */
protected $providerListDirty = false;
/** @var bool */
protected $registeredCoreProviders = false;
/** @var array */
protected $providers = [];
protected IConfig $config;
protected IRootFolder $rootFolder;
protected IAppData $appData;
protected EventDispatcherInterface $eventDispatcher;
private ?Generator $generator = null;
private GeneratorHelper $helper;
protected bool $providerListDirty = false;
protected bool $registeredCoreProviders = false;
protected array $providers = [];
/** @var array mime type => support status */
protected $mimeTypeSupportMap = [];
/** @var array */
protected $defaultProviders;
/** @var string */
protected $userId;
/** @var Coordinator */
private $bootstrapCoordinator;
protected array $mimeTypeSupportMap = [];
protected ?array $defaultProviders = null;
protected ?string $userId;
private Coordinator $bootstrapCoordinator;
/**
* Hash map (without value) of loaded bootstrap providers
*
* @var null[]
* @psalm-var array<string, null>
*/
private $loadedBootstrapProviders = [];
private array $loadedBootstrapProviders = [];
private IServerContainer $container;
private IBinaryFinder $binaryFinder;
/** @var IServerContainer */
private $container;
/**
* PreviewManager constructor.
*
* @param IConfig $config
* @param IRootFolder $rootFolder
* @param IAppData $appData
* @param EventDispatcherInterface $eventDispatcher
* @param string $userId
*/
public function __construct(IConfig $config,
IRootFolder $rootFolder,
IAppData $appData,
EventDispatcherInterface $eventDispatcher,
GeneratorHelper $helper,
$userId,
Coordinator $bootstrapCoordinator,
IServerContainer $container) {
public function __construct(
IConfig $config,
IRootFolder $rootFolder,
IAppData $appData,
EventDispatcherInterface $eventDispatcher,
GeneratorHelper $helper,
?string $userId,
Coordinator $bootstrapCoordinator,
IServerContainer $container,
IBinaryFinder $binaryFinder
) {
$this->config = $config;
$this->rootFolder = $rootFolder;
$this->appData = $appData;
@ -122,6 +91,7 @@ class PreviewManager implements IPreview {
$this->userId = $userId;
$this->bootstrapCoordinator = $bootstrapCoordinator;
$this->container = $container;
$this->binaryFinder = $binaryFinder;
}
/**
@ -134,7 +104,7 @@ class PreviewManager implements IPreview {
* @param \Closure $callable
* @return void
*/
public function registerProvider($mimeTypeRegex, \Closure $callable) {
public function registerProvider($mimeTypeRegex, \Closure $callable): void {
if (!$this->config->getSystemValue('enable_previews', true)) {
return;
}
@ -148,9 +118,8 @@ class PreviewManager implements IPreview {
/**
* Get all providers
* @return array
*/
public function getProviders() {
public function getProviders(): array {
if (!$this->config->getSystemValue('enable_previews', true)) {
return [];
}
@ -168,9 +137,8 @@ class PreviewManager implements IPreview {
/**
* Does the manager have any providers
* @return bool
*/
public function hasProviders() {
public function hasProviders(): bool {
$this->registerCoreProviders();
return !empty($this->providers);
}
@ -257,11 +225,8 @@ class PreviewManager implements IPreview {
/**
* Check if a preview can be generated for a file
*
* @param \OCP\Files\FileInfo $file
* @return bool
*/
public function isAvailable(\OCP\Files\FileInfo $file) {
public function isAvailable(\OCP\Files\FileInfo $file): bool {
if (!$this->config->getSystemValue('enable_previews', true)) {
return false;
}
@ -421,10 +386,10 @@ class PreviewManager implements IPreview {
// Office requires openoffice or libreoffice
$officeBinary = $this->config->getSystemValue('preview_libreoffice_path', null);
if (is_null($officeBinary)) {
$officeBinary = \OC_Helper::findBinaryPath('libreoffice');
$officeBinary = $this->binaryFinder->findBinaryPath('libreoffice');
}
if (is_null($officeBinary)) {
$officeBinary = \OC_Helper::findBinaryPath('openoffice');
$officeBinary = $this->binaryFinder->findBinaryPath('openoffice');
}
if (is_string($officeBinary)) {
@ -439,9 +404,9 @@ class PreviewManager implements IPreview {
// Video requires avconv or ffmpeg
if (in_array(Preview\Movie::class, $this->getEnabledDefaultProvider())) {
$movieBinary = \OC_Helper::findBinaryPath('avconv');
$movieBinary = $this->binaryFinder->findBinaryPath('avconv');
if (is_null($movieBinary)) {
$movieBinary = \OC_Helper::findBinaryPath('ffmpeg');
$movieBinary = $this->binaryFinder->findBinaryPath('ffmpeg');
}
if (is_string($movieBinary)) {
@ -469,7 +434,7 @@ class PreviewManager implements IPreview {
$this->registerProvider($provider->getMimeTypeRegex(), function () use ($provider) {
try {
return $this->container->query($provider->getService());
return $this->container->get($provider->getService());
} catch (QueryException $e) {
return null;
}

View File

@ -202,6 +202,7 @@ use OCP\IAvatarManager;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\ICertificateManager;
use OCP\IBinaryFinder;
use OCP\IDateTimeFormatter;
use OCP\IDateTimeZone;
use OCP\IDBConnection;
@ -335,7 +336,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(GeneratorHelper::class),
$c->get(ISession::class)->get('user_id'),
$c->get(Coordinator::class),
$c->get(IServerContainer::class)
$c->get(IServerContainer::class),
$c->get(IBinaryFinder::class)
);
});
/** @deprecated 19.0.0 */
@ -1448,6 +1450,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
$this->connectDispatcher();
}

View File

@ -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;
}
/**

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types = 1);
/**
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP;
/**
* Service that find the binary path for a program.
*
* This interface should be injected via depency injection and must
* not be implemented in applications.
*
* @since 25.0.0
*/
interface IBinaryFinder {
/**
* Try to find a program
*
* @return false|string
* @since 25.0.0
*/
public function findBinaryPath(string $program);
}

View File

@ -48,6 +48,7 @@ namespace OCP;
use OC\AppScriptDependency;
use OC\AppScriptSort;
use bantu\IniGetWrapper\IniGetWrapper;
/**
* This class provides different helper functions to make the life of a developer easier
@ -604,4 +605,27 @@ class Util {
}
return $temp;
}
/**
* Check if a function is enabled in the php configuration
*
* @since 25.0.0
*/
public static function isFunctionEnabled(string $functionName): bool {
if (!function_exists($functionName)) {
return false;
}
$ini = \OCP\Server::get(IniGetWrapper::class);
$disabled = explode(',', $ini->get('disable_functions') ?: '');
$disabled = array_map('trim', $disabled);
if (in_array($functionName, $disabled)) {
return false;
}
$disabled = explode(',', $ini->get('suhosin.executor.func.blacklist') ?: '');
$disabled = array_map('trim', $disabled);
if (in_array($functionName, $disabled)) {
return false;
}
return true;
}
}

View File

@ -63,7 +63,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
if (escapeshellarg('strängé') !== '\'strängé\'') {
$this->markTestSkipped('Your escapeshell args removes accents');
}
if (!\OC_Helper::is_function_enabled('exec')) {
if (!\OCP\Util::isFunctionEnabled('exec')) {
$this->markTestSkipped(
'The exec() function needs to be enabled for this test.'
);

View File

@ -87,7 +87,7 @@ class MailerTest extends TestCase {
]);
$path = \OC_Helper::findBinaryPath('sendmail');
if ($path === null) {
if ($path === false) {
$path = '/usr/sbin/sendmail';
}