diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-04-01 16:25:35 +0200 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2025-04-07 17:05:54 +0200 |
commit | b2100484c00d3ff42a77be8c8e2a0d0371415c79 (patch) | |
tree | ad884dd605fdb5e7fbb6ac8f1ac952adce79502f | |
parent | b20f74a95b16af7d81c53182253ef6b6cba8ecaf (diff) | |
download | nextcloud-server-b2100484c00d3ff42a77be8c8e2a0d0371415c79.tar.gz nextcloud-server-b2100484c00d3ff42a77be8c8e2a0d0371415c79.zip |
fix: Remove some call and references to deprecated OC_Util class
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | apps/settings/templates/help.php | 2 | ||||
-rw-r--r-- | core/Listener/BeforeTemplateRenderedListener.php | 2 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 2 | ||||
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/private/Image.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 9 | ||||
-rw-r--r-- | lib/private/Template/functions.php | 5 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 3 | ||||
-rw-r--r-- | lib/public/Util.php | 12 | ||||
-rw-r--r-- | tests/lib/UtilTest.php | 20 |
10 files changed, 28 insertions, 31 deletions
diff --git a/apps/settings/templates/help.php b/apps/settings/templates/help.php index 14883996791..17356e6ccdf 100644 --- a/apps/settings/templates/help.php +++ b/apps/settings/templates/help.php @@ -3,7 +3,7 @@ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -\OC_Util::addStyle('settings', 'help'); +\OCP\Util::addStyle('settings', 'help'); ?> <?php if ($_['knowledgebaseEmbedded'] === true) : ?> <div id="app-navigation" role="navigation" tabindex="0"> diff --git a/core/Listener/BeforeTemplateRenderedListener.php b/core/Listener/BeforeTemplateRenderedListener.php index 4ce892664e9..cc1dee91cfe 100644 --- a/core/Listener/BeforeTemplateRenderedListener.php +++ b/core/Listener/BeforeTemplateRenderedListener.php @@ -37,7 +37,7 @@ class BeforeTemplateRenderedListener implements IEventListener { Util::addScript('core', 'public'); } - \OC_Util::addStyle('server', null, true); + Util::addStyle('server', null, true); if ($event instanceof BeforeLoginTemplateRenderedEvent) { // todo: make login work without these diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index a36d8320227..195b6dca99a 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -359,7 +359,7 @@ describe('Core base tests', function() { // to make sure they run. var cit = window.isPhantom?xit:it; - // must provide the same results as \OC_Util::naturalSortCompare + // must provide the same results as \OCP\Util::naturalSortCompare it('sorts alphabetically', function() { var a = [ 'def', diff --git a/lib/base.php b/lib/base.php index bda6b6e01a1..c1182e47d61 100644 --- a/lib/base.php +++ b/lib/base.php @@ -704,7 +704,7 @@ class OC { if (count($errors) > 0) { if (!self::$CLI) { http_response_code(503); - OC_Util::addStyle('guest'); + Util::addStyle('guest'); try { Server::get(ITemplateManager::class)->printGuestPage('', 'error', ['errors' => $errors]); exit; diff --git a/lib/private/Image.php b/lib/private/Image.php index 3dd0bc49662..96699a0046b 100644 --- a/lib/private/Image.php +++ b/lib/private/Image.php @@ -56,7 +56,7 @@ class Image implements IImage { $this->appConfig = $appConfig ?? Server::get(IAppConfig::class); $this->config = $config ?? Server::get(IConfig::class); - if (\OC_Util::fileInfoLoaded()) { + if (class_exists(finfo::class)) { $this->fileInfo = new finfo(FILEINFO_MIME_TYPE); } } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 1749783bc51..c2b8621ff1e 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1965,14 +1965,9 @@ class Manager implements IManager { } /** - * Copied from \OC_Util::isSharingDisabledForUser - * - * TODO: Deprecate function from OC_Util - * - * @param string $userId - * @return bool + * Check if sharing is disabled for the current user */ - public function sharingDisabledForUser($userId) { + public function sharingDisabledForUser(string $userId): bool { return $this->shareDisableChecker->sharingDisabledForUser($userId); } diff --git a/lib/private/Template/functions.php b/lib/private/Template/functions.php index 77a1e831008..402a7491e03 100644 --- a/lib/private/Template/functions.php +++ b/lib/private/Template/functions.php @@ -131,10 +131,10 @@ function script($app, $file = null): void { function style($app, $file = null): void { if (is_array($file)) { foreach ($file as $f) { - OC_Util::addStyle($app, $f); + Util::addStyle($app, $f); } } else { - OC_Util::addStyle($app, $file); + Util::addStyle($app, $file); } } @@ -143,6 +143,7 @@ function style($app, $file = null): void { * @param string $app the appname * @param string|string[] $file the filename, * if an array is given it will add all styles + * @deprecated 32.0.0 */ function vendor_style($app, $file = null): void { if (is_array($file)) { diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 23713f2e462..3cfbb6ea073 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -485,11 +485,10 @@ interface IManager { /** * Check if sharing is disabled for the given user * - * @param string $userId * @return bool * @since 9.0.0 */ - public function sharingDisabledForUser($userId); + public function sharingDisabledForUser(string $userId); /** * Check if outgoing server2server shares are allowed diff --git a/lib/public/Util.php b/lib/public/Util.php index 65776bd15a7..3e122464225 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -102,13 +102,15 @@ class Util { } /** - * add a css file - * @param string $application - * @param string $file + * Add a css file + * + * @param string $application application id + * @param ?string $file filename + * @param bool $prepend prepend the style to the beginning of the list * @since 4.0.0 */ - public static function addStyle($application, $file = null): void { - \OC_Util::addStyle($application, $file); + public static function addStyle(string $application, ?string $file = null, bool $prepend = false): void { + \OC_Util::addStyle($application, $file, $prepend); } /** diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index fcb77332fcc..0063a991e48 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -42,25 +42,25 @@ class UtilTest extends \Test\TestCase { 'And It Even May <strong>Nest</strong>' ], ]; - $result = OC_Util::sanitizeHTML($badArray); + $result = Util::sanitizeHTML($badArray); $this->assertEquals($goodArray, $result); $badString = '<img onload="alert(1)" />'; - $result = OC_Util::sanitizeHTML($badString); + $result = Util::sanitizeHTML($badString); $this->assertEquals('<img onload="alert(1)" />', $result); $badString = "<script>alert('Hacked!');</script>"; - $result = OC_Util::sanitizeHTML($badString); + $result = Util::sanitizeHTML($badString); $this->assertEquals('<script>alert('Hacked!');</script>', $result); $goodString = 'This is a good string without HTML.'; - $result = OC_Util::sanitizeHTML($goodString); + $result = Util::sanitizeHTML($goodString); $this->assertEquals('This is a good string without HTML.', $result); } public function testEncodePath(): void { $component = '/§#@test%&^ä/-child'; - $result = OC_Util::encodePath($component); + $result = Util::encodePath($component); $this->assertEquals('/%C2%A7%23%40test%25%26%5E%C3%A4/-child', $result); } @@ -295,12 +295,12 @@ class UtilTest extends \Test\TestCase { } public function testAddStyle(): void { - \OC_Util::addStyle('core', 'myFancyCSSFile1'); - \OC_Util::addStyle('myApp', 'myFancyCSSFile2'); - \OC_Util::addStyle('core', 'myFancyCSSFile0', true); - \OC_Util::addStyle('core', 'myFancyCSSFile10', true); + Util::addStyle('core', 'myFancyCSSFile1'); + Util::addStyle('myApp', 'myFancyCSSFile2'); + Util::addStyle('core', 'myFancyCSSFile0', true); + Util::addStyle('core', 'myFancyCSSFile10', true); // add duplicate - \OC_Util::addStyle('core', 'myFancyCSSFile1'); + Util::addStyle('core', 'myFancyCSSFile1'); $this->assertEquals([], Util::getScripts()); $this->assertEquals([ |