diff options
Diffstat (limited to 'lib')
29 files changed, 238 insertions, 55 deletions
diff --git a/lib/base.php b/lib/base.php index 82dcd5965aa..814f30b5af3 100644 --- a/lib/base.php +++ b/lib/base.php @@ -143,7 +143,7 @@ class OC { public static function initPaths() { if (defined('PHPUNIT_CONFIG_DIR')) { self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; - } elseif (defined('PHPUNIT_RUN') && PHPUNIT_RUN && is_dir(OC::$SERVERROOT . '/tests/config/')) { + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { self::$configDir = OC::$SERVERROOT . '/tests/config/'; } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { self::$configDir = rtrim($dir, '/') . '/'; @@ -465,6 +465,14 @@ class OC { } /** + * Try to set some values to the required Nextcloud default + */ + public static function setRequiredIniValues() { + @ini_set('default_charset', 'UTF-8'); + @ini_set('gd.jpeg_ignore_warning', '1'); + } + + /** * Send the same site cookies */ private static function sendSameSiteCookies() { @@ -630,6 +638,7 @@ class OC { @set_time_limit(max(intval(@ini_get('max_execution_time')), intval(@ini_get('max_input_time')))); } + self::setRequiredIniValues(); self::handleAuthHeaders(); $systemConfig = \OC::$server->get(\OC\SystemConfig::class); self::registerAutoloaderCache($systemConfig); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index d2eb52ac5e8..1edc39c52f2 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -981,6 +981,8 @@ return array( 'OC\\Core\\Db\\LoginFlowV2Mapper' => $baseDir . '/core/Db/LoginFlowV2Mapper.php', 'OC\\Core\\Db\\ProfileConfig' => $baseDir . '/core/Db/ProfileConfig.php', 'OC\\Core\\Db\\ProfileConfigMapper' => $baseDir . '/core/Db/ProfileConfigMapper.php', + 'OC\\Core\\Events\\BeforePasswordResetEvent' => $baseDir . '/core/Events/BeforePasswordResetEvent.php', + 'OC\\Core\\Events\\PasswordResetEvent' => $baseDir . '/core/Events/PasswordResetEvent.php', 'OC\\Core\\Exception\\LoginFlowV2NotFoundException' => $baseDir . '/core/Exception/LoginFlowV2NotFoundException.php', 'OC\\Core\\Exception\\ResetPasswordException' => $baseDir . '/core/Exception/ResetPasswordException.php', 'OC\\Core\\Middleware\\TwoFactorMiddleware' => $baseDir . '/core/Middleware/TwoFactorMiddleware.php', @@ -1033,6 +1035,7 @@ return array( 'OC\\Core\\Migrations\\Version24000Date20220202150027' => $baseDir . '/core/Migrations/Version24000Date20220202150027.php', 'OC\\Core\\Migrations\\Version24000Date20220404230027' => $baseDir . '/core/Migrations/Version24000Date20220404230027.php', 'OC\\Core\\Migrations\\Version24000Date20220425072957' => $baseDir . '/core/Migrations/Version24000Date20220425072957.php', + 'OC\\Core\\Migrations\\Version25000Date20220515204012' => $baseDir . '/core/Migrations/Version25000Date20220515204012.php', 'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php', diff --git a/lib/composer/composer/autoload_files.php b/lib/composer/composer/autoload_files.php new file mode 100644 index 00000000000..16e661d85de --- /dev/null +++ b/lib/composer/composer/autoload_files.php @@ -0,0 +1,10 @@ +<?php + +// autoload_files.php @generated by Composer + +$vendorDir = dirname(__DIR__); +$baseDir = dirname(dirname($vendorDir)); + +return array( + '03ae51fe9694f2f597f918142c49ff7a' => $baseDir . '/lib/public/Log/functions.php', +); diff --git a/lib/composer/composer/autoload_real.php b/lib/composer/composer/autoload_real.php index 27e0b34bf5b..6b98041770d 100644 --- a/lib/composer/composer/autoload_real.php +++ b/lib/composer/composer/autoload_real.php @@ -31,6 +31,25 @@ class ComposerAutoloaderInit749170dad3f5e7f9ca158f5a9f04f6a2 $loader->register(true); + $includeFiles = \Composer\Autoload\ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2::$files; + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequire749170dad3f5e7f9ca158f5a9f04f6a2($fileIdentifier, $file); + } + return $loader; } } + +/** + * @param string $fileIdentifier + * @param string $file + * @return void + */ +function composerRequire749170dad3f5e7f9ca158f5a9f04f6a2($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } +} diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index a208f213de8..2efd6effc91 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -6,6 +6,10 @@ namespace Composer\Autoload; class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 { + public static $files = array ( + '03ae51fe9694f2f597f918142c49ff7a' => __DIR__ . '/../../..' . '/lib/public/Log/functions.php', + ); + public static $prefixLengthsPsr4 = array ( 'O' => array ( @@ -1010,6 +1014,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Db\\LoginFlowV2Mapper' => __DIR__ . '/../../..' . '/core/Db/LoginFlowV2Mapper.php', 'OC\\Core\\Db\\ProfileConfig' => __DIR__ . '/../../..' . '/core/Db/ProfileConfig.php', 'OC\\Core\\Db\\ProfileConfigMapper' => __DIR__ . '/../../..' . '/core/Db/ProfileConfigMapper.php', + 'OC\\Core\\Events\\BeforePasswordResetEvent' => __DIR__ . '/../../..' . '/core/Events/BeforePasswordResetEvent.php', + 'OC\\Core\\Events\\PasswordResetEvent' => __DIR__ . '/../../..' . '/core/Events/PasswordResetEvent.php', 'OC\\Core\\Exception\\LoginFlowV2NotFoundException' => __DIR__ . '/../../..' . '/core/Exception/LoginFlowV2NotFoundException.php', 'OC\\Core\\Exception\\ResetPasswordException' => __DIR__ . '/../../..' . '/core/Exception/ResetPasswordException.php', 'OC\\Core\\Middleware\\TwoFactorMiddleware' => __DIR__ . '/../../..' . '/core/Middleware/TwoFactorMiddleware.php', @@ -1062,6 +1068,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Migrations\\Version24000Date20220202150027' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20220202150027.php', 'OC\\Core\\Migrations\\Version24000Date20220404230027' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20220404230027.php', 'OC\\Core\\Migrations\\Version24000Date20220425072957' => __DIR__ . '/../../..' . '/core/Migrations/Version24000Date20220425072957.php', + 'OC\\Core\\Migrations\\Version25000Date20220515204012' => __DIR__ . '/../../..' . '/core/Migrations/Version25000Date20220515204012.php', 'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php', diff --git a/lib/l10n/an.js b/lib/l10n/an.js new file mode 100644 index 00000000000..8ddba74c09f --- /dev/null +++ b/lib/l10n/an.js @@ -0,0 +1,6 @@ +OC.L10N.register( + "lib", + { + "Settings" : "Configurazión" +}, +"nplurals=2; plural=(n != 1);"); diff --git a/lib/l10n/an.json b/lib/l10n/an.json new file mode 100644 index 00000000000..08fd0a1abf7 --- /dev/null +++ b/lib/l10n/an.json @@ -0,0 +1,4 @@ +{ "translations": { + "Settings" : "Configurazión" +},"pluralForm" :"nplurals=2; plural=(n != 1);" +}
\ No newline at end of file diff --git a/lib/l10n/ca.js b/lib/l10n/ca.js index ac957865e6c..9ac9151fb6d 100644 --- a/lib/l10n/ca.js +++ b/lib/l10n/ca.js @@ -46,6 +46,7 @@ OC.L10N.register( "Unknown filetype" : "Tipus de fitxer desconegut", "Invalid image" : "Imatge no vàlida", "Avatar image is not square" : "La imatge de perfil no és quadrada", + "View profile" : "Visualitza el perfil", "today" : "avui", "tomorrow" : "demà", "yesterday" : "ahir", diff --git a/lib/l10n/ca.json b/lib/l10n/ca.json index 97f3a6df60b..dc152ed98a9 100644 --- a/lib/l10n/ca.json +++ b/lib/l10n/ca.json @@ -44,6 +44,7 @@ "Unknown filetype" : "Tipus de fitxer desconegut", "Invalid image" : "Imatge no vàlida", "Avatar image is not square" : "La imatge de perfil no és quadrada", + "View profile" : "Visualitza el perfil", "today" : "avui", "tomorrow" : "demà", "yesterday" : "ahir", diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js index fbe047df50d..38c6547a63c 100644 --- a/lib/l10n/ja.js +++ b/lib/l10n/ja.js @@ -238,6 +238,7 @@ OC.L10N.register( "The required %s config variable is not configured in the config.php file." : "必要な %s 構成変数が config.php ファイルに設定されていません。", "Please ask your server administrator to check the Nextcloud configuration." : "サーバー管理者にNextcloud構成を確認するように依頼してください。", "PostgreSQL >= 9 required." : "PostgreSQL 9以上が必要です", + "Please upgrade your database version." : "新しいバージョンのデータベースにアップグレードしてください。", "Your data directory is readable by other users." : "データディレクトリは他のユーザーからも読み取ることができます", "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "ディレクトリが他のユーザーから見えないように、パーミッションを 0770 に変更してください。", "Your data directory must be an absolute path." : "データディレクトリは、絶対パスにする必要があります", diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json index 5d53a53454e..878f4fbdd13 100644 --- a/lib/l10n/ja.json +++ b/lib/l10n/ja.json @@ -236,6 +236,7 @@ "The required %s config variable is not configured in the config.php file." : "必要な %s 構成変数が config.php ファイルに設定されていません。", "Please ask your server administrator to check the Nextcloud configuration." : "サーバー管理者にNextcloud構成を確認するように依頼してください。", "PostgreSQL >= 9 required." : "PostgreSQL 9以上が必要です", + "Please upgrade your database version." : "新しいバージョンのデータベースにアップグレードしてください。", "Your data directory is readable by other users." : "データディレクトリは他のユーザーからも読み取ることができます", "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "ディレクトリが他のユーザーから見えないように、パーミッションを 0770 に変更してください。", "Your data directory must be an absolute path." : "データディレクトリは、絶対パスにする必要があります", diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index b80c7887591..bdf33d73c29 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -220,7 +220,7 @@ class AccountManager implements IAccountManager { foreach ($properties as $property) { if (strlen($property->getValue()) > 2048) { if ($throwOnData) { - throw new InvalidArgumentException(); + throw new InvalidArgumentException($property->getName()); } else { $property->setValue(''); } diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php index 0ab4c9a37cc..d3db0444664 100644 --- a/lib/private/Authentication/LoginCredentials/Store.php +++ b/lib/private/Authentication/LoginCredentials/Store.php @@ -100,7 +100,7 @@ class Store implements IStore { } catch (SessionNotAvailableException $ex) { $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core', 'exception' => $ex]); } catch (InvalidTokenException $ex) { - $this->logger->debug('could not get login credentials because the token is invalid: ' . $ex->getMessage(), ['app' => 'core', 'exception' => $ex]); + $this->logger->debug('could not get login credentials because the token is invalid: ' . $ex->getMessage(), ['app' => 'core']); $trySession = true; } catch (PasswordlessTokenException $ex) { $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core', 'exception' => $ex]); diff --git a/lib/private/Avatar/AvatarManager.php b/lib/private/Avatar/AvatarManager.php index 77138085dc9..ec9bed40850 100644 --- a/lib/private/Avatar/AvatarManager.php +++ b/lib/private/Avatar/AvatarManager.php @@ -136,20 +136,23 @@ class AvatarManager implements IAvatarManager { $avatarScope = ''; } - if ( + switch ($avatarScope) { // v2-private scope hides the avatar from public access and from unknown users - $avatarScope === IAccountManager::SCOPE_PRIVATE - && ( - // accessing from public link - $requestingUser === null - // logged in, but unknown to user - || !$this->knownUserService->isKnownToUser($requestingUser->getUID(), $userId) - )) { - // use a placeholder avatar which caches the generated images - return new PlaceholderAvatar($folder, $user, $this->logger); + case IAccountManager::SCOPE_PRIVATE: + if ($requestingUser !== null && $this->knownUserService->isKnownToUser($requestingUser->getUID(), $userId)) { + return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config); + } + break; + case IAccountManager::SCOPE_LOCAL: + case IAccountManager::SCOPE_FEDERATED: + case IAccountManager::SCOPE_PUBLISHED: + return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config); + default: + // use a placeholder avatar which caches the generated images + return new PlaceholderAvatar($folder, $user, $this->logger); } - return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config); + return new PlaceholderAvatar($folder, $user, $this->logger); } /** diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 4a06ac62f1e..b7532222c33 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -1258,8 +1258,6 @@ class Manager implements ICommentsManager { } private function sumReactions(string $parentId): void { - $qb = $this->dbConn->getQueryBuilder(); - $totalQuery = $this->dbConn->getQueryBuilder(); $totalQuery ->selectAlias( @@ -1273,7 +1271,7 @@ class Manager implements ICommentsManager { ) ->selectAlias($totalQuery->func()->count('id'), 'total') ->from('reactions', 'r') - ->where($totalQuery->expr()->eq('r.parent_id', $qb->createNamedParameter($parentId))) + ->where($totalQuery->expr()->eq('r.parent_id', $totalQuery->createNamedParameter($parentId))) ->groupBy('r.reaction') ->orderBy('total', 'DESC') ->addOrderBy('r.reaction', 'ASC') @@ -1291,9 +1289,10 @@ class Manager implements ICommentsManager { ) ->from($jsonQuery->createFunction('(' . $totalQuery->getSQL() . ')'), 'json'); + $qb = $this->dbConn->getQueryBuilder(); $qb ->update('comments') - ->set('reactions', $jsonQuery->createFunction('(' . $jsonQuery->getSQL() . ')')) + ->set('reactions', $qb->createFunction('(' . $jsonQuery->getSQL() . ')')) ->where($qb->expr()->eq('id', $qb->createNamedParameter($parentId))) ->executeStatement(); } diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php index 937fb94a09a..68783e3f79b 100644 --- a/lib/private/ContactsManager.php +++ b/lib/private/ContactsManager.php @@ -6,6 +6,7 @@ * @author Joas Schilling <coding@schilljs.com> * @author John Molakvoæ <skjnldsv@protonmail.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Thomas Citharel <nextcloud@tcit.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tobia De Koninck <tobia@ledfan.be> * @@ -85,7 +86,7 @@ class ContactsManager implements IManager { /** * This function can be used to delete the contact identified by the given id * - * @param object $id the unique identifier to a contact + * @param int $id the unique identifier to a contact * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not */ diff --git a/lib/private/Encryption/HookManager.php b/lib/private/Encryption/HookManager.php index a2d6b990a88..5081bcccf94 100644 --- a/lib/private/Encryption/HookManager.php +++ b/lib/private/Encryption/HookManager.php @@ -25,39 +25,51 @@ namespace OC\Encryption; use OC\Files\Filesystem; use OC\Files\View; +use OC\Files\SetupManager; use Psr\Log\LoggerInterface; class HookManager { - /** - * @var Update - */ - private static $updater; + private static ?Update $updater = null; - public static function postShared($params) { + public static function postShared($params): void { self::getUpdate()->postShared($params); } - public static function postUnshared($params) { - self::getUpdate()->postUnshared($params); + public static function postUnshared($params): void { + // In case the unsharing happens in a background job, we don't have + // a session and we load instead the user from the UserManager + $path = Filesystem::getPath($params['fileSource']); + $owner = Filesystem::getOwner($path); + self::getUpdate($owner)->postUnshared($params); } - public static function postRename($params) { + public static function postRename($params): void { self::getUpdate()->postRename($params); } - public static function postRestore($params) { + public static function postRestore($params): void { self::getUpdate()->postRestore($params); } - /** - * @return Update - */ - private static function getUpdate() { + private static function getUpdate(?string $owner = null): Update { if (is_null(self::$updater)) { $user = \OC::$server->getUserSession()->getUser(); + if (!$user && $owner) { + $user = \OC::$server->getUserManager()->get($owner); + } + if (!$user) { + throw new \Exception("Inconsistent data, File unshared, but owner not found. Should not happen"); + } + $uid = ''; if ($user) { $uid = $user->getUID(); } + + $setupManager = \OC::$server->get(SetupManager::class); + if (!$setupManager->isSetupComplete($user)) { + $setupManager->setupForUser($user); + } + self::$updater = new Update( new View(), new Util( diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index c25d4a40363..f077e36d97d 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -150,11 +150,12 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager return (is_array($result)) ? $result : []; } } catch (\Exception $e) { + $this->logger->debug($e->getMessage(), ['exception' => $e]); + // if flat re-sharing is not supported by the remote server // we re-throw the exception and fall back to the old behaviour. // (flat re-shares has been introduced in Nextcloud 9.1) if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { - $this->logger->debug($e->getMessage(), ['exception' => $e]); throw $e; } } diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index adb3928b28a..898f64d97c2 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -335,6 +335,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { $handle = fopen($tmpFile, $mode); return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { $this->writeBack($tmpFile, $path); + unlink($tmpFile); }); case 'a': case 'ab': @@ -352,6 +353,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { $handle = fopen($tmpFile, $mode); return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { $this->writeBack($tmpFile, $path); + unlink($tmpFile); }); } return false; diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index 040ba6b898f..876514b473c 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -380,13 +380,9 @@ class SetupManager { return; } - // for the user's home folder, it's always the home mount - if (rtrim($path) === "/" . $user->getUID() . "/files") { - if ($includeChildren) { - $this->setupForUser($user); - } else { - $this->oneTimeUserSetup($user); - } + // for the user's home folder, and includes children we need everything always + if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) { + $this->setupForUser($user); return; } @@ -403,6 +399,10 @@ class SetupManager { return; } + if (!$this->isSetupStarted($user)) { + $this->oneTimeUserSetup($user); + } + $mounts = []; if (!in_array($cachedMount->getMountProvider(), $setupProviders)) { $setupProviders[] = $cachedMount->getMountProvider(); diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index ee8a8c7d161..4996572a40e 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -15,6 +15,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Klaas Freitag <freitag@owncloud.com> * @author Lukas Reschke <lukas@statuscode.ch> + * @author Martin Brugnara <martin@0x6d62.eu> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> @@ -66,6 +67,8 @@ class Local extends \OC\Files\Storage\Common { private IMimeTypeDetector $mimeTypeDetector; + private $defUMask; + public function __construct($arguments) { if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { throw new \InvalidArgumentException('No data directory set for local storage'); @@ -84,6 +87,7 @@ class Local extends \OC\Files\Storage\Common { $this->dataDirLength = strlen($this->realDataDir); $this->config = \OC::$server->get(IConfig::class); $this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class); + $this->defUMask = $this->config->getSystemValue('localstorage.umask', 0022); } public function __destruct() { @@ -95,7 +99,7 @@ class Local extends \OC\Files\Storage\Common { public function mkdir($path) { $sourcePath = $this->getSourcePath($path); - $oldMask = umask(022); + $oldMask = umask($this->defUMask); $result = @mkdir($sourcePath, 0777, true); umask($oldMask); return $result; @@ -273,7 +277,7 @@ class Local extends \OC\Files\Storage\Common { if ($this->file_exists($path) and !$this->isUpdatable($path)) { return false; } - $oldMask = umask(022); + $oldMask = umask($this->defUMask); if (!is_null($mtime)) { $result = @touch($this->getSourcePath($path), $mtime); } else { @@ -292,7 +296,7 @@ class Local extends \OC\Files\Storage\Common { } public function file_put_contents($path, $data) { - $oldMask = umask(022); + $oldMask = umask($this->defUMask); $result = file_put_contents($this->getSourcePath($path), $data); umask($oldMask); return $result; @@ -365,7 +369,7 @@ class Local extends \OC\Files\Storage\Common { if ($this->is_dir($path1)) { return parent::copy($path1, $path2); } else { - $oldMask = umask(022); + $oldMask = umask($this->defUMask); $result = copy($this->getSourcePath($path1), $this->getSourcePath($path2)); umask($oldMask); return $result; @@ -373,7 +377,7 @@ class Local extends \OC\Files\Storage\Common { } public function fopen($path, $mode) { - $oldMask = umask(022); + $oldMask = umask($this->defUMask); $result = fopen($this->getSourcePath($path), $mode); umask($oldMask); return $result; diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index af797c7720d..820a681bd07 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -24,6 +24,7 @@ namespace OC\Files\Stream; use Icewind\Streams\File; +use Icewind\Streams\Wrapper; /** * A stream wrapper that uses http range requests to provide a seekable stream for http reading @@ -92,6 +93,18 @@ class SeekableHttpStream implements File { } $responseHead = stream_get_meta_data($this->current)['wrapper_data']; + + while ($responseHead instanceof Wrapper) { + $wrapperOptions = stream_context_get_options($responseHead->context); + foreach ($wrapperOptions as $options) { + if (isset($options['source']) && is_resource($options['source'])) { + $responseHead = stream_get_meta_data($options['source'])['wrapper_data']; + continue 2; + } + } + throw new \Exception("Failed to get source stream from stream wrapper of " . get_class($responseHead)); + } + $rangeHeaders = array_values(array_filter($responseHead, function ($v) { return preg_match('#^content-range:#i', $v) === 1; })); diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index 273eba35446..ba555cff438 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -201,7 +201,8 @@ class Checker { if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') { $oldMimetypeList = new GenerateMimetypeFileBuilder(); $newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases()); - if ($newFile === file_get_contents($filename)) { + $oldFile = $this->fileAccessHelper->file_get_contents($filename); + if ($newFile === $oldFile) { $hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases())); continue; } diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index 61512627258..5b216331dc7 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -211,6 +211,15 @@ class RepairMimeTypes implements IRepairStep { return $this->updateMimetypes($updatedMimetypes); } + private function introduceOnlyofficeFormType() { + $updatedMimetypes = [ + "oform" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", + "docxf" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", + ]; + + return $this->updateMimetypes($updatedMimetypes); + } + /** * Fix mime types @@ -260,5 +269,9 @@ class RepairMimeTypes implements IRepairStep { if (version_compare($ocVersionFromBeforeUpdate, '23.0.0.2', '<') && $this->introduceFlatOpenDocumentType()) { $out->info('Fixed Flat OpenDocument mime types'); } + + if (version_compare($ocVersionFromBeforeUpdate, '25.0.0.2', '<') && $this->introduceOnlyofficeFormType()) { + $out->info('Fixed ONLYOFFICE Forms OpenXML mime types'); + } } } diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index a7b9fd35fd8..5f23b471837 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -47,6 +47,7 @@ use OCP\IInitialStateService; use OCP\IL10N; use OCP\ISession; use OCP\IURLGenerator; +use OCP\ILogger; use OCP\IUser; use OCP\User\Backend\IPasswordConfirmationBackend; use OCP\Util; @@ -176,6 +177,9 @@ class JSConfigHelper { 'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)), 'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0), 'blacklist_files_regex' => FileInfo::BLACKLIST_FILES_REGEX, + 'loglevel' => $this->config->getSystemValue('loglevel_frontend', + $this->config->getSystemValue('loglevel', ILogger::WARN) + ), ]; $array = [ diff --git a/lib/private/User/User.php b/lib/private/User/User.php index de9af35f541..c5306d1df27 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -555,15 +555,9 @@ class User implements IUser { return $uid . '@' . $server; } - /** - * @param string $url - * @return string - */ - private function removeProtocolFromUrl($url) { + private function removeProtocolFromUrl(string $url): string { if (strpos($url, 'https://') === 0) { return substr($url, strlen('https://')); - } elseif (strpos($url, 'http://') === 0) { - return substr($url, strlen('http://')); } return $url; diff --git a/lib/public/Contacts/IManager.php b/lib/public/Contacts/IManager.php index e9bdc01c060..65be12c4c39 100644 --- a/lib/public/Contacts/IManager.php +++ b/lib/public/Contacts/IManager.php @@ -105,7 +105,7 @@ interface IManager { /** * This function can be used to delete the contact identified by the given id * - * @param object $id the unique identifier to a contact + * @param int $id the unique identifier to a contact * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not * @since 6.0.0 diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index ee57dbceb71..8df9a0c007d 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -10,6 +10,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <robin@mccorkell.me.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Thomas Citharel <nextcloud@tcit.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 @@ -97,7 +98,7 @@ namespace OCP { public function getPermissions(); /** - * @param object $id the unique identifier to a contact + * @param int $id the unique identifier to a contact * @return bool successful or not * @since 5.0.0 */ diff --git a/lib/public/Log/functions.php b/lib/public/Log/functions.php new file mode 100644 index 00000000000..cc6961d8fba --- /dev/null +++ b/lib/public/Log/functions.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +/* + * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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\Log; + +use OC; +use OCP\AppFramework\QueryException; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; +use function class_exists; + +/** + * Get a PSR logger + * + * Whenever possible, inject a logger into your classes instead of relying on + * this helper function. + * + * @warning the returned logger implementation is not guaranteed to be the same + * between two function calls. During early stages of the process you + * might in fact get a noop implementation when Nextcloud isn't ready + * to log. Therefore you MUST NOT cache the result of this function but + * fetch a new logger for every log line you want to write. + * + * @param string|null $appId optional parameter to acquire the app-specific logger + * + * @return LoggerInterface + * @since 24.0.0 + */ +function logger(string $appId = null): LoggerInterface { + if (!class_exists(OC::class) || OC::$server === null) { + // If someone calls this log before Nextcloud is initialized, there is + // no logging available. In that case we return a noop implementation + // TODO: evaluate whether logging to error_log could be an alternative + return new NullLogger(); + } + + if ($appId !== null) { + try { + $appContainer = OC::$server->getRegisteredAppContainer($appId); + return $appContainer->get(LoggerInterface::class); + } catch (QueryException $e) { + // Ignore and return the server logger below + } + } + + try { + return OC::$server->get(LoggerInterface::class); + } catch (QueryException $e) { + return new NullLogger(); + } +} |