aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-04-01 15:36:38 +0200
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2025-04-07 17:05:54 +0200
commitfd59e02a24ebd547d30319e4ee09c8c83bc7b7b8 (patch)
tree30aa2751ebac007c7afb5a7efbf20d0929e4939a /lib
parent39dc22b9dd7f6b7c44e98470055d8d2be877a702 (diff)
downloadnextcloud-server-fd59e02a24ebd547d30319e4ee09c8c83bc7b7b8.tar.gz
nextcloud-server-fd59e02a24ebd547d30319e4ee09c8c83bc7b7b8.zip
chore(legacy): Officially deprecate OC_Util and remove non-static methods
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/legacy/OC_Util.php87
1 files changed, 3 insertions, 84 deletions
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index b2950275e41..4e6e1773291 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -9,7 +9,6 @@ use bantu\IniGetWrapper\IniGetWrapper;
use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
use OC\Files\SetupManager;
use OCP\Files\Template\ITemplateManager;
-use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
@@ -19,13 +18,13 @@ use OCP\Security\ISecureRandom;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;
+/**
+ * @deprecated 32.0.0 Use \OCP\Util or any appropriate official API instead
+ */
class OC_Util {
public static $styles = [];
public static $headers = [];
- /** @var array Local cache of version.php */
- private static $versionCache = null;
-
protected static function getAppManager() {
return \OC::$server->getAppManager();
}
@@ -692,86 +691,6 @@ class OC_Util {
return $encoded;
}
-
- public function createHtaccessTestFile(\OCP\IConfig $config) {
- // php dev server does not support htaccess
- if (php_sapi_name() === 'cli-server') {
- return false;
- }
-
- // testdata
- $fileName = '/htaccesstest.txt';
- $testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.';
-
- // creating a test file
- $testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
-
- if (file_exists($testFile)) {// already running this test, possible recursive call
- return false;
- }
-
- $fp = @fopen($testFile, 'w');
- if (!$fp) {
- throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.',
- 'Make sure it is possible for the web server to write to ' . $testFile);
- }
- fwrite($fp, $testContent);
- fclose($fp);
-
- return $testContent;
- }
-
- /**
- * Check if the .htaccess file is working
- *
- * @param \OCP\IConfig $config
- * @return bool
- * @throws Exception
- * @throws \OCP\HintException If the test file can't get written.
- */
- public function isHtaccessWorking(\OCP\IConfig $config) {
- if (\OC::$CLI || !$config->getSystemValueBool('check_for_working_htaccess', true)) {
- return true;
- }
-
- $testContent = $this->createHtaccessTestFile($config);
- if ($testContent === false) {
- return false;
- }
-
- $fileName = '/htaccesstest.txt';
- $testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
-
- // accessing the file via http
- $url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName);
- try {
- $content = \OC::$server->get(IClientService::class)->newClient()->get($url)->getBody();
- } catch (\Exception $e) {
- $content = false;
- }
-
- if (str_starts_with($url, 'https:')) {
- $url = 'http:' . substr($url, 6);
- } else {
- $url = 'https:' . substr($url, 5);
- }
-
- try {
- $fallbackContent = \OC::$server->get(IClientService::class)->newClient()->get($url)->getBody();
- } catch (\Exception $e) {
- $fallbackContent = false;
- }
-
- // cleanup
- @unlink($testFile);
-
- /*
- * If the content is not equal to test content our .htaccess
- * is working as required
- */
- return $content !== $testContent && $fallbackContent !== $testContent;
- }
-
/**
* Check if current locale is non-UTF8
*