summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--apps/admin_audit/composer/composer/installed.php6
-rw-r--r--apps/cloud_federation_api/composer/composer/installed.php6
-rw-r--r--apps/comments/composer/composer/installed.php6
-rw-r--r--apps/contactsinteraction/composer/composer/installed.php6
-rw-r--r--apps/dav/composer/composer/installed.php6
-rw-r--r--apps/encryption/composer/composer/installed.php6
-rw-r--r--apps/federatedfilesharing/composer/composer/installed.php6
-rw-r--r--apps/federation/composer/composer/installed.php6
-rw-r--r--apps/files/composer/composer/installed.php6
-rw-r--r--apps/files_sharing/composer/composer/installed.php6
-rw-r--r--apps/files_trashbin/composer/composer/installed.php6
-rw-r--r--apps/files_versions/composer/composer/installed.php6
-rw-r--r--apps/lookup_server_connector/composer/composer/installed.php6
-rw-r--r--apps/oauth2/composer/composer/installed.php6
-rw-r--r--apps/provisioning_api/composer/composer/installed.php6
-rw-r--r--apps/settings/composer/composer/installed.php6
-rw-r--r--apps/sharebymail/composer/composer/installed.php6
-rw-r--r--apps/systemtags/composer/composer/installed.php6
-rw-r--r--apps/testing/composer/composer/installed.php6
-rw-r--r--apps/twofactor_backupcodes/composer/composer/installed.php6
-rw-r--r--apps/updatenotification/composer/composer/installed.php6
-rw-r--r--apps/user_ldap/composer/composer/installed.php6
-rw-r--r--apps/user_status/composer/composer/installed.php6
-rw-r--r--apps/workflowengine/composer/composer/installed.php6
-rw-r--r--lib/composer/composer/autoload_classmap.php2
-rw-r--r--lib/composer/composer/autoload_static.php2
-rw-r--r--lib/private/App/Platform.php6
-rw-r--r--lib/private/BinaryFinder.php71
-rwxr-xr-xlib/private/LargeFileHelper.php4
-rw-r--r--lib/private/Mail/Mailer.php18
-rw-r--r--lib/private/PreviewManager.php113
-rw-r--r--lib/private/Server.php6
-rw-r--r--lib/private/legacy/OC_Helper.php44
-rw-r--r--lib/public/IBinaryFinder.php41
-rw-r--r--lib/public/Util.php24
-rw-r--r--tests/lib/LargeFileHelperGetFileSizeTest.php2
-rw-r--r--tests/lib/Mail/MailerTest.php2
37 files changed, 278 insertions, 201 deletions
diff --git a/apps/admin_audit/composer/composer/installed.php b/apps/admin_audit/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/admin_audit/composer/composer/installed.php
+++ b/apps/admin_audit/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/cloud_federation_api/composer/composer/installed.php b/apps/cloud_federation_api/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/cloud_federation_api/composer/composer/installed.php
+++ b/apps/cloud_federation_api/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/comments/composer/composer/installed.php b/apps/comments/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/comments/composer/composer/installed.php
+++ b/apps/comments/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/contactsinteraction/composer/composer/installed.php b/apps/contactsinteraction/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/contactsinteraction/composer/composer/installed.php
+++ b/apps/contactsinteraction/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/dav/composer/composer/installed.php b/apps/dav/composer/composer/installed.php
index 628db5d793b..c54b7ff5437 100644
--- a/apps/dav/composer/composer/installed.php
+++ b/apps/dav/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/encryption/composer/composer/installed.php b/apps/encryption/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/encryption/composer/composer/installed.php
+++ b/apps/encryption/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/federatedfilesharing/composer/composer/installed.php b/apps/federatedfilesharing/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/federatedfilesharing/composer/composer/installed.php
+++ b/apps/federatedfilesharing/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/federation/composer/composer/installed.php b/apps/federation/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/federation/composer/composer/installed.php
+++ b/apps/federation/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/files/composer/composer/installed.php b/apps/files/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/files/composer/composer/installed.php
+++ b/apps/files/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/files_sharing/composer/composer/installed.php b/apps/files_sharing/composer/composer/installed.php
index 1d332e29100..c54b7ff5437 100644
--- a/apps/files_sharing/composer/composer/installed.php
+++ b/apps/files_sharing/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/files_trashbin/composer/composer/installed.php b/apps/files_trashbin/composer/composer/installed.php
index 914fa1a857f..c54b7ff5437 100644
--- a/apps/files_trashbin/composer/composer/installed.php
+++ b/apps/files_trashbin/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/files_versions/composer/composer/installed.php b/apps/files_versions/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/files_versions/composer/composer/installed.php
+++ b/apps/files_versions/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/lookup_server_connector/composer/composer/installed.php b/apps/lookup_server_connector/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/lookup_server_connector/composer/composer/installed.php
+++ b/apps/lookup_server_connector/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/oauth2/composer/composer/installed.php b/apps/oauth2/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/oauth2/composer/composer/installed.php
+++ b/apps/oauth2/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/provisioning_api/composer/composer/installed.php b/apps/provisioning_api/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/provisioning_api/composer/composer/installed.php
+++ b/apps/provisioning_api/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/settings/composer/composer/installed.php b/apps/settings/composer/composer/installed.php
index 6e11f678155..c54b7ff5437 100644
--- a/apps/settings/composer/composer/installed.php
+++ b/apps/settings/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/sharebymail/composer/composer/installed.php b/apps/sharebymail/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/sharebymail/composer/composer/installed.php
+++ b/apps/sharebymail/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/systemtags/composer/composer/installed.php b/apps/systemtags/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/systemtags/composer/composer/installed.php
+++ b/apps/systemtags/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/testing/composer/composer/installed.php b/apps/testing/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/testing/composer/composer/installed.php
+++ b/apps/testing/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/twofactor_backupcodes/composer/composer/installed.php b/apps/twofactor_backupcodes/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/twofactor_backupcodes/composer/composer/installed.php
+++ b/apps/twofactor_backupcodes/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/updatenotification/composer/composer/installed.php b/apps/updatenotification/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/updatenotification/composer/composer/installed.php
+++ b/apps/updatenotification/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/user_ldap/composer/composer/installed.php b/apps/user_ldap/composer/composer/installed.php
index 5e942064485..c54b7ff5437 100644
--- a/apps/user_ldap/composer/composer/installed.php
+++ b/apps/user_ldap/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/user_status/composer/composer/installed.php b/apps/user_status/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/user_status/composer/composer/installed.php
+++ b/apps/user_status/composer/composer/installed.php
@@ -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,
),
),
diff --git a/apps/workflowengine/composer/composer/installed.php b/apps/workflowengine/composer/composer/installed.php
index 5440719fa40..c54b7ff5437 100644
--- a/apps/workflowengine/composer/composer/installed.php
+++ b/apps/workflowengine/composer/composer/installed.php
@@ -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,
),
),
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 004c569d21b..c4dcd502333 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -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',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 8c13e047b3e..50deac9d656 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -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',
diff --git a/lib/private/App/Platform.php b/lib/private/App/Platform.php
index 15966d85c34..01bf6748654 100644
--- a/lib/private/App/Platform.php
+++ b/lib/private/App/Platform.php
@@ -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 {
diff --git a/lib/private/BinaryFinder.php b/lib/private/BinaryFinder.php
new file mode 100644
index 00000000000..a7ef55237db
--- /dev/null
+++ b/lib/private/BinaryFinder.php
@@ -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;
+ }
+}
diff --git a/lib/private/LargeFileHelper.php b/lib/private/LargeFileHelper.php
index e2984b4bacf..82b3c5ae760 100755
--- a/lib/private/LargeFileHelper.php
+++ b/lib/private/LargeFileHelper.php
@@ -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));
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 991d1b202ec..d0c3b04eacb 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -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';
}
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php
index 6c17dd58b4b..e78bdefda8d 100644
--- a/lib/private/PreviewManager.php
+++ b/lib/private/PreviewManager.php
@@ -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 = [];
-
- /** @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) {
+ private array $loadedBootstrapProviders = [];
+ private IServerContainer $container;
+ private IBinaryFinder $binaryFinder;
+
+ 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;
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 7223c3b8ae3..1770aca26dd 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -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();
}
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;
}
/**
diff --git a/lib/public/IBinaryFinder.php b/lib/public/IBinaryFinder.php
new file mode 100644
index 00000000000..028c1f4d0a7
--- /dev/null
+++ b/lib/public/IBinaryFinder.php
@@ -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);
+}
diff --git a/lib/public/Util.php b/lib/public/Util.php
index e5bb2a955ae..6cd3eaa7f85 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -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;
+ }
}
diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php
index 3066d48792b..6fa2555b6d0 100644
--- a/tests/lib/LargeFileHelperGetFileSizeTest.php
+++ b/tests/lib/LargeFileHelperGetFileSizeTest.php
@@ -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.'
);
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index e96cda26398..4b15a4233fd 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -87,7 +87,7 @@ class MailerTest extends TestCase {
]);
$path = \OC_Helper::findBinaryPath('sendmail');
- if ($path === null) {
+ if ($path === false) {
$path = '/usr/sbin/sendmail';
}