diff options
author | Gary Kim <gary@garykim.dev> | 2021-06-29 19:20:33 -0400 |
---|---|---|
committer | Gary Kim <gary@garykim.dev> | 2021-06-30 15:28:02 -0400 |
commit | b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0 (patch) | |
tree | c2051ba8b5b03b8e4152e7597a8a3ac4457980c6 /lib/private | |
parent | 6da9ccc9ee1e37932c6580e9831c74bbeeac741b (diff) | |
download | nextcloud-server-b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0.tar.gz nextcloud-server-b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0.zip |
Migrate HintException to OCP
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AppFramework/App.php | 3 | ||||
-rw-r--r-- | lib/private/Config.php | 2 | ||||
-rw-r--r-- | lib/private/DatabaseSetupException.php | 2 | ||||
-rw-r--r-- | lib/private/HintException.php | 71 | ||||
-rw-r--r-- | lib/private/Installer.php | 1 | ||||
-rw-r--r-- | lib/private/Log/ExceptionSerializer.php | 2 | ||||
-rw-r--r-- | lib/private/Log/Systemdlog.php | 2 | ||||
-rw-r--r-- | lib/private/Memcache/Factory.php | 4 | ||||
-rw-r--r-- | lib/private/Memcache/Memcached.php | 2 | ||||
-rw-r--r-- | lib/private/Setup.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Updater.php | 1 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_Hook.php | 4 | ||||
-rw-r--r-- | lib/private/legacy/OC_Util.php | 12 |
15 files changed, 40 insertions, 72 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index 37cc0b71e3f..6c2f905afa5 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -34,11 +34,11 @@ namespace OC\AppFramework; use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Http\Dispatcher; use OC\AppFramework\Http\Request; -use OC\HintException; use OCP\AppFramework\Http; use OCP\AppFramework\Http\ICallbackResponse; use OCP\AppFramework\Http\IOutput; use OCP\AppFramework\QueryException; +use OCP\HintException; use OCP\IRequest; /** @@ -105,6 +105,7 @@ class App { /** * Shortcut for calling a controller method and printing the result + * * @param string $controllerName the name of the controller under which it is * stored in the DI container * @param string $methodName the method that you want to call diff --git a/lib/private/Config.php b/lib/private/Config.php index e3ace96c359..2a83d2300dc 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -38,6 +38,8 @@ */ namespace OC; +use OCP\HintException; + /** * This class is responsible for reading and writing config.php, the very basic * configuration file of Nextcloud. diff --git a/lib/private/DatabaseSetupException.php b/lib/private/DatabaseSetupException.php index b1b4956db41..44583416dbc 100644 --- a/lib/private/DatabaseSetupException.php +++ b/lib/private/DatabaseSetupException.php @@ -22,5 +22,7 @@ */ namespace OC; +use OCP\HintException; + class DatabaseSetupException extends HintException { } diff --git a/lib/private/HintException.php b/lib/private/HintException.php index e3173ba79fd..735832266cf 100644 --- a/lib/private/HintException.php +++ b/lib/private/HintException.php @@ -1,28 +1,28 @@ <?php + +declare(strict_types=1); /** - * @copyright Copyright (c) 2016, ownCloud, Inc. + * @copyright Copyright (c) 2021 Gary Kim <gary@garykim.dev> * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Bart Visscher <bartv@thisnet.nl> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Michael Gapczynski <GapczynskiM@gmail.com> - * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Gary Kim <gary@garykim.dev> * - * @license AGPL-3.0 + * @license GNU AGPL version 3 or any later version * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. + * 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 + * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> + * 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; /** @@ -31,48 +31,7 @@ namespace OC; * An Exception class with the intention to be presented to the end user * * @package OC + * @depreacted 23.0.0 Use \OCP\HintException */ -class HintException extends \Exception { - private $hint; - - /** - * HintException constructor. - * - * @param string $message The error message. It will be not revealed to the - * the user (unless the hint is empty) and thus - * should be not translated. - * @param string $hint A useful message that is presented to the end - * user. It should be translated, but must not - * contain sensitive data. - * @param int $code - * @param \Exception|null $previous - */ - public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { - $this->hint = $hint; - parent::__construct($message, $code, $previous); - } - - /** - * Returns a string representation of this Exception that includes the error - * code, the message and the hint. - * - * @return string - */ - public function __toString() { - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; - } - - /** - * Returns the hint with the intention to be presented to the end user. If - * an empty hint was specified upon instatiation, the message is returned - * instead. - * - * @return string - */ - public function getHint() { - if (empty($this->hint)) { - return $this->message; - } - return $this->hint; - } +class HintException extends \OCP\HintException { } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index d1e903424ed..19e70aad147 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -48,6 +48,7 @@ use OC\DB\Connection; use OC\DB\MigrationService; use OC_App; use OC_Helper; +use OCP\HintException; use OCP\Http\Client\IClientService; use OCP\IConfig; use OCP\ILogger; diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php index aba5586297a..bab22ab4aac 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -29,10 +29,10 @@ namespace OC\Log; use OC\Core\Controller\SetupController; -use OC\HintException; use OC\Security\IdentityProof\Key; use OC\Setup; use OC\SystemConfig; +use OCP\HintException; class ExceptionSerializer { public const methodsWithSensitiveParameters = [ diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php index 17778891efe..a01826c0b05 100644 --- a/lib/private/Log/Systemdlog.php +++ b/lib/private/Log/Systemdlog.php @@ -25,8 +25,8 @@ */ namespace OC\Log; -use OC\HintException; use OC\SystemConfig; +use OCP\HintException; use OCP\ILogger; use OCP\Log\IWriter; diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 9810f068148..28a84308edc 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -86,12 +86,12 @@ class Factory implements ICacheFactory { $missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheHint = 'Is the matching PHP module installed and enabled?'; if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) { - throw new \OC\HintException(strtr($missingCacheMessage, [ + throw new \OCP\HintException(strtr($missingCacheMessage, [ '{class}' => $localCacheClass, '{use}' => 'local' ]), $missingCacheHint); } if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) { - throw new \OC\HintException(strtr($missingCacheMessage, [ + throw new \OCP\HintException(strtr($missingCacheMessage, [ '{class}' => $distributedCacheClass, '{use}' => 'distributed' ]), $missingCacheHint); } diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index cd1af031d8a..b3414a7d290 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -31,7 +31,7 @@ */ namespace OC\Memcache; -use OC\HintException; +use OCP\HintException; use OCP\IMemcache; class Memcached extends Cache implements IMemcache { diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 8e7e6ae6aea..d39fa069286 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -224,7 +224,7 @@ class Setup { try { $util = new \OC_Util(); $htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig()); - } catch (\OC\HintException $e) { + } catch (\OCP\HintException $e) { $errors[] = [ 'error' => $e->getMessage(), 'exception' => $e, diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index b5e1b944bc5..7047c32e339 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -43,7 +43,6 @@ namespace OC\Share20; use OC\Cache\CappedMemoryCache; use OC\Files\Mount\MoveableMount; -use OC\HintException; use OC\Share20\Exception\ProviderException; use OCA\Files_Sharing\ISharedStorage; use OCP\EventDispatcher\IEventDispatcher; @@ -52,6 +51,7 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\Node; +use OCP\HintException; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 5fa41e48c0c..cffdac310cb 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -45,6 +45,7 @@ use OC\DB\MigrationService; use OC\Hooks\BasicEmitter; use OC\IntegrityCheck\Checker; use OC_App; +use OCP\HintException; use OCP\IConfig; use OCP\ILogger; use OCP\Util; diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 07a599cf017..12c615d500b 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -33,10 +33,10 @@ */ namespace OC\User; -use OC\HintException; use OC\Hooks\PublicEmitter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; +use OCP\HintException; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; diff --git a/lib/private/legacy/OC_Hook.php b/lib/private/legacy/OC_Hook.php index d9e4c99e498..b223b0fa6d6 100644 --- a/lib/private/legacy/OC_Hook.php +++ b/lib/private/legacy/OC_Hook.php @@ -81,7 +81,7 @@ class OC_Hook { * @param string $signalName name of signal * @param mixed $params default: array() array with additional data * @return bool true if slots exists or false if not - * @throws \OC\HintException + * @throws \OCP\HintException * @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references! * * TODO: write example @@ -107,7 +107,7 @@ class OC_Hook { } catch (Exception $e) { self::$thrownExceptions[] = $e; \OC::$server->getLogger()->logException($e); - if ($e instanceof \OC\HintException) { + if ($e instanceof \OCP\HintException) { throw $e; } if ($e instanceof \OC\ServerNotAvailableException) { diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 87964f98374..333b621e359 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -63,6 +63,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + use bantu\IniGetWrapper\IniGetWrapper; use OC\AppFramework\Http\Request; use OC\Files\Storage\LocalRootStorage; @@ -1214,7 +1215,7 @@ class OC_Util { $fp = @fopen($testFile, 'w'); if (!$fp) { - throw new OC\HintException('Can\'t create test file to check for working .htaccess file.', + throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.', 'Make sure it is possible for the webserver to write to ' . $testFile); } fwrite($fp, $testContent); @@ -1225,10 +1226,11 @@ class OC_Util { /** * Check if the .htaccess file is working + * * @param \OCP\IConfig $config * @return bool * @throws Exception - * @throws \OC\HintException If the test file can't get written. + * @throws \OCP\HintException If the test file can't get written. */ public function isHtaccessWorking(\OCP\IConfig $config) { if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) { @@ -1422,7 +1424,7 @@ class OC_Util { * * @param \OC\SystemConfig $config * @return bool whether the core or any app needs an upgrade - * @throws \OC\HintException When the upgrade from the given version is not allowed + * @throws \OCP\HintException When the upgrade from the given version is not allowed */ public static function needUpgrade(\OC\SystemConfig $config) { if ($config->getValue('installed', false)) { @@ -1442,11 +1444,11 @@ class OC_Util { return true; } else { // downgrade attempt, throw exception - throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); + throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); } } elseif ($versionDiff < 0) { // downgrade attempt, throw exception - throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); + throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); } // also check for upgrades for apps (independently from the user) |