diff options
Diffstat (limited to 'lib')
63 files changed, 337 insertions, 448 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 69cd3b1116e..4dbb3cc0d05 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/lib/composer/composer/autoload_namespaces.php b/lib/composer/composer/autoload_namespaces.php index 4a9c20beed0..f1ae7a0ffec 100644 --- a/lib/composer/composer/autoload_namespaces.php +++ b/lib/composer/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/lib/composer/composer/autoload_psr4.php b/lib/composer/composer/autoload_psr4.php index b641d9c6a03..74e48cf69ae 100644 --- a/lib/composer/composer/autoload_psr4.php +++ b/lib/composer/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname(dirname($vendorDir)); return array( diff --git a/lib/composer/composer/autoload_real.php b/lib/composer/composer/autoload_real.php index a5748c7a891..4b1ab7678ec 100644 --- a/lib/composer/composer/autoload_real.php +++ b/lib/composer/composer/autoload_real.php @@ -23,30 +23,11 @@ class ComposerAutoloaderInit53792487c5a8370acc0b06b1a864ff4c } spl_autoload_register(array('ComposerAutoloaderInit53792487c5a8370acc0b06b1a864ff4c', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit53792487c5a8370acc0b06b1a864ff4c', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + \Composer\Autoload\ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::getInitializer($loader)(); $loader->register(true); diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index fbf1281cdf8..0b64f70f6fd 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -7,7 +7,7 @@ namespace Composer\Autoload; class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c { public static $prefixLengthsPsr4 = array ( - 'O' => + 'O' => array ( 'OC\\Core\\' => 8, 'OC\\' => 3, @@ -16,15 +16,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c ); public static $prefixDirsPsr4 = array ( - 'OC\\Core\\' => + 'OC\\Core\\' => array ( 0 => __DIR__ . '/../../..' . '/core', ), - 'OC\\' => + 'OC\\' => array ( 0 => __DIR__ . '/../../..' . '/lib/private', ), - 'OCP\\' => + 'OCP\\' => array ( 0 => __DIR__ . '/../../..' . '/lib/public', ), diff --git a/lib/l10n/ar.js b/lib/l10n/ar.js index 8a986850199..853182c5df0 100644 --- a/lib/l10n/ar.js +++ b/lib/l10n/ar.js @@ -118,6 +118,7 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "يمكن حل هذا عادة بإعطاء خادم الوب صلاحية الكتابة في مجلد config", "Can't create or write into the data directory %s" : "لا يمكن الإنشاء أو الكتابة في مجلد البيانات %s", "Can't read file" : "لا يمكن قراءة الملف", - "This can usually be fixed by giving the webserver write access to the config directory. See %s" : "يمكن إصلاح هذا الخطا بإعطاء مخدّم الموقع صلاحيات التعديل على مجلد الإعدادات. أنظر %s" + "This can usually be fixed by giving the webserver write access to the config directory. See %s" : "يمكن إصلاح هذا الخطا بإعطاء مخدّم الموقع صلاحيات التعديل على مجلد الإعدادات. أنظر %s", + "Please upgrade your database version" : "فضلًا قم بتحديث إصدار قاعدة بياناتك" }, "nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;"); diff --git a/lib/l10n/ar.json b/lib/l10n/ar.json index 2b4bdc5bd6b..ce726d3b323 100644 --- a/lib/l10n/ar.json +++ b/lib/l10n/ar.json @@ -116,6 +116,7 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "يمكن حل هذا عادة بإعطاء خادم الوب صلاحية الكتابة في مجلد config", "Can't create or write into the data directory %s" : "لا يمكن الإنشاء أو الكتابة في مجلد البيانات %s", "Can't read file" : "لا يمكن قراءة الملف", - "This can usually be fixed by giving the webserver write access to the config directory. See %s" : "يمكن إصلاح هذا الخطا بإعطاء مخدّم الموقع صلاحيات التعديل على مجلد الإعدادات. أنظر %s" + "This can usually be fixed by giving the webserver write access to the config directory. See %s" : "يمكن إصلاح هذا الخطا بإعطاء مخدّم الموقع صلاحيات التعديل على مجلد الإعدادات. أنظر %s", + "Please upgrade your database version" : "فضلًا قم بتحديث إصدار قاعدة بياناتك" },"pluralForm" :"nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;" }
\ No newline at end of file diff --git a/lib/l10n/sv.js b/lib/l10n/sv.js index ef690b97a68..d698b06e082 100644 --- a/lib/l10n/sv.js +++ b/lib/l10n/sv.js @@ -6,7 +6,7 @@ OC.L10N.register( "See %s" : "Se %s", "The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server." : "Filerna i appen %1$s ersattes inte korrekt. Kontrollera att det är en version som är kompatibel med servern.", "Sample configuration detected" : "Exempel-konfiguration detekterad", - "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Det har upptäckts att provkonfigurationen har kopierats. Detta kan bryta din installation och stöds inte. Vänligen läs dokumentationen innan du utför ändringar på config.php", + "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Det har upptäckts att provkonfigurationen har kopierats. Detta kan bryta din installation och stöds inte. Läs dokumentationen innan du utför ändringar på config.php", "%s email verification" : "%s e-postverifikation", "Email verification" : "E-postverifikation", "Click the following button to confirm your email." : "Klicka på följande knapp för att verifiera din e-postadress.", @@ -120,9 +120,9 @@ OC.L10N.register( "Oracle username and/or password not valid" : "Oracle-användarnamnet och/eller lösenordet är felaktigt", "PostgreSQL username and/or password not valid" : "PostgreSQL-användarnamnet och/eller lösenordet är felaktigt", "Mac OS X is not supported and %s will not work properly on this platform. Use it at your own risk! " : "Mac OS X stöds inte och %s kommer inte att fungera korrekt på denna plattform. Använd på egen risk!", - "For the best results, please consider using a GNU/Linux server instead." : "För bästa resultat, vänligen överväg att använda en GNU/Linux-server istället.", + "For the best results, please consider using a GNU/Linux server instead." : "För bästa resultat, överväg att använda en GNU/Linux-server istället.", "It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. This will lead to problems with files over 4 GB and is highly discouraged." : "Det verkar som om denna %s instans körs på en 32-bitars PHP miljö och open_basedir har konfigurerats i php.ini. Detta kommer att leda till problem med filer över 4 GB och är verkligen inte rekommenderat!", - "Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP." : "Vänligen ta bort open_basedir-inställningen i din php.ini eller växla till 64-bitars PHP.", + "Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP." : "Ta bort open_basedir-inställningen i din php.ini eller växla till 64-bitars PHP.", "Set an admin username." : "Ange ett användarnamn för administratören.", "Set an admin password." : "Ange ett administratörslösenord.", "Cannot create or write into the data directory %s" : "Kan inte skapa eller skriva till data-katalogen %s", @@ -205,15 +205,15 @@ OC.L10N.register( "Login canceled by app" : "Inloggningen avbruten av appen", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "Appen \"%1$s\" kan inte installeras eftersom följande beroenden inte är uppfyllda: %2$s", "a safe home for all your data" : "ett säkert hem för all din data", - "File is currently busy, please try again later" : "Filen är för tillfället upptagen, vänligen försök igen senare", + "File is currently busy, please try again later" : "Filen är för tillfället upptagen, försök igen senare", "Cannot read file" : "Kan inte läsa fil", "Application is not enabled" : "Applikationen är inte aktiverad", "Authentication error" : "Fel vid autentisering", - "Token expired. Please reload page." : "Token har löpt ut. Vänligen uppdatera sidan.", + "Token expired. Please reload page." : "Token har löpt ut. Uppdatera sidan.", "No database drivers (sqlite, mysql, or postgresql) installed." : "Inga databasdrivrutiner (sqlite, mysql, eller postgresql) installerade.", "Or, if you prefer to keep config.php file read only, set the option \"config_is_read_only\" to true in it. See %s" : "Eller, om du föredrar att behålla config.php skrivskyddad, sätt alternativet \"config_is_read_only\" till true i den. Se %s", "PHP module %s not installed." : "PHP-modulen %s är inte installerad.", - "Please ask your server administrator to install the module." : "Vänligen be serveradministratören att installera modulen.", + "Please ask your server administrator to install the module." : "Be serveradministratören att installera modulen.", "PHP setting \"%s\" is not set to \"%s\"." : "PHP-inställning \"%s\" är inte inställd på \"%s\".", "Adjusting this setting in php.ini will make Nextcloud run again" : "Att ändra denna inställning i php.ini kommer göra så att Nextcloud fungerar igen", "libxml2 2.7.0 is at least required. Currently %s is installed." : "libxml2 2.7.0 är det minsta som krävs. För närvarande är %s installerat.", @@ -221,8 +221,8 @@ OC.L10N.register( "PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible." : "PHP är tydligen inställt för att tömma \"inline doc blocks\". Detta kommer att göra flera kärnprogram otillgängliga.", "This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Detta orsakas troligtvis av en cache/accelerator som t ex Zend OPchache eller eAccelerator.", "PHP modules have been installed, but they are still listed as missing?" : "PHP-moduler har installerats, men de listas fortfarande som saknade?", - "Please ask your server administrator to restart the web server." : "Vänligen be din serveradministratör att starta om webbservern.", - "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "Vänligen ändra behörigheterna till 0770 så att katalogen inte kan listas av andra användare.", + "Please ask your server administrator to restart the web server." : "Be din serveradministratör att starta om webbservern.", + "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "Ändra behörigheterna till 0770 så att katalogen inte kan listas av andra användare.", "Ensure there is a file called \".ocdata\" in the root of the data directory." : "Säkerställ att du har filen \".ocdata\" i huvudkatalogen för din data.", "Action \"%s\" not supported or implemented." : "Åtgärd \"%s\" stöds inte eller är inte implementerad.", "Authentication failed, wrong token or provider ID given" : "Autentisering misslyckades, felaktig token eller leverantörs-ID", @@ -252,11 +252,11 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the root directory. See %s" : "Detta kan vanligtvis åtgärda genom att ge webbservern skrivåtkomst till rotkatalogen. Se %s", "Permissions can usually be fixed by giving the webserver write access to the root directory. See %s." : "Rättigheter kan vanligtvis fixas genom att ge webbservern skrivåtkomst till rotkatalogen. Se %s.", "Setting locale to %s failed" : "Sätta locale till %s misslyckades", - "Please install one of these locales on your system and restart your webserver." : "Vänligen Installera en av dessa språk på ditt system och starta om webbservern.", + "Please install one of these locales on your system and restart your webserver." : "Installera en av dessa språk på ditt system och starta om webbservern.", "mbstring.func_overload is set to \"%s\" instead of the expected value \"0\"" : "mbstring.func_overload är satt till \"%s\" istället för det förväntade värdet \"0\"", "To fix this issue set <code>mbstring.func_overload</code> to <code>0</code> in your php.ini" : "För att åtgärda detta problem sätt värdet <code> mbstring.func_overload till </ code> <code> 0 </ code> i din php.ini", "PostgreSQL >= 9 required" : "PostgreSQL >= 9 krävs", - "Please upgrade your database version" : "Vänligen uppgradera din databasversion", + "Please upgrade your database version" : "Uppgradera din databasversion", "Your data directory is readable by other users" : "Din datamapp är läsbar av andra användare", "Your data directory must be an absolute path" : "Du måste specificera en korrekt sökväg till datamappen", "Check the value of \"datadirectory\" in your configuration" : "Kontrollera värdet av \"datakatalog\" i din konfiguration", diff --git a/lib/l10n/sv.json b/lib/l10n/sv.json index 444d8d908bb..74526fac761 100644 --- a/lib/l10n/sv.json +++ b/lib/l10n/sv.json @@ -4,7 +4,7 @@ "See %s" : "Se %s", "The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server." : "Filerna i appen %1$s ersattes inte korrekt. Kontrollera att det är en version som är kompatibel med servern.", "Sample configuration detected" : "Exempel-konfiguration detekterad", - "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Det har upptäckts att provkonfigurationen har kopierats. Detta kan bryta din installation och stöds inte. Vänligen läs dokumentationen innan du utför ändringar på config.php", + "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Det har upptäckts att provkonfigurationen har kopierats. Detta kan bryta din installation och stöds inte. Läs dokumentationen innan du utför ändringar på config.php", "%s email verification" : "%s e-postverifikation", "Email verification" : "E-postverifikation", "Click the following button to confirm your email." : "Klicka på följande knapp för att verifiera din e-postadress.", @@ -118,9 +118,9 @@ "Oracle username and/or password not valid" : "Oracle-användarnamnet och/eller lösenordet är felaktigt", "PostgreSQL username and/or password not valid" : "PostgreSQL-användarnamnet och/eller lösenordet är felaktigt", "Mac OS X is not supported and %s will not work properly on this platform. Use it at your own risk! " : "Mac OS X stöds inte och %s kommer inte att fungera korrekt på denna plattform. Använd på egen risk!", - "For the best results, please consider using a GNU/Linux server instead." : "För bästa resultat, vänligen överväg att använda en GNU/Linux-server istället.", + "For the best results, please consider using a GNU/Linux server instead." : "För bästa resultat, överväg att använda en GNU/Linux-server istället.", "It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. This will lead to problems with files over 4 GB and is highly discouraged." : "Det verkar som om denna %s instans körs på en 32-bitars PHP miljö och open_basedir har konfigurerats i php.ini. Detta kommer att leda till problem med filer över 4 GB och är verkligen inte rekommenderat!", - "Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP." : "Vänligen ta bort open_basedir-inställningen i din php.ini eller växla till 64-bitars PHP.", + "Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP." : "Ta bort open_basedir-inställningen i din php.ini eller växla till 64-bitars PHP.", "Set an admin username." : "Ange ett användarnamn för administratören.", "Set an admin password." : "Ange ett administratörslösenord.", "Cannot create or write into the data directory %s" : "Kan inte skapa eller skriva till data-katalogen %s", @@ -203,15 +203,15 @@ "Login canceled by app" : "Inloggningen avbruten av appen", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "Appen \"%1$s\" kan inte installeras eftersom följande beroenden inte är uppfyllda: %2$s", "a safe home for all your data" : "ett säkert hem för all din data", - "File is currently busy, please try again later" : "Filen är för tillfället upptagen, vänligen försök igen senare", + "File is currently busy, please try again later" : "Filen är för tillfället upptagen, försök igen senare", "Cannot read file" : "Kan inte läsa fil", "Application is not enabled" : "Applikationen är inte aktiverad", "Authentication error" : "Fel vid autentisering", - "Token expired. Please reload page." : "Token har löpt ut. Vänligen uppdatera sidan.", + "Token expired. Please reload page." : "Token har löpt ut. Uppdatera sidan.", "No database drivers (sqlite, mysql, or postgresql) installed." : "Inga databasdrivrutiner (sqlite, mysql, eller postgresql) installerade.", "Or, if you prefer to keep config.php file read only, set the option \"config_is_read_only\" to true in it. See %s" : "Eller, om du föredrar att behålla config.php skrivskyddad, sätt alternativet \"config_is_read_only\" till true i den. Se %s", "PHP module %s not installed." : "PHP-modulen %s är inte installerad.", - "Please ask your server administrator to install the module." : "Vänligen be serveradministratören att installera modulen.", + "Please ask your server administrator to install the module." : "Be serveradministratören att installera modulen.", "PHP setting \"%s\" is not set to \"%s\"." : "PHP-inställning \"%s\" är inte inställd på \"%s\".", "Adjusting this setting in php.ini will make Nextcloud run again" : "Att ändra denna inställning i php.ini kommer göra så att Nextcloud fungerar igen", "libxml2 2.7.0 is at least required. Currently %s is installed." : "libxml2 2.7.0 är det minsta som krävs. För närvarande är %s installerat.", @@ -219,8 +219,8 @@ "PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible." : "PHP är tydligen inställt för att tömma \"inline doc blocks\". Detta kommer att göra flera kärnprogram otillgängliga.", "This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Detta orsakas troligtvis av en cache/accelerator som t ex Zend OPchache eller eAccelerator.", "PHP modules have been installed, but they are still listed as missing?" : "PHP-moduler har installerats, men de listas fortfarande som saknade?", - "Please ask your server administrator to restart the web server." : "Vänligen be din serveradministratör att starta om webbservern.", - "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "Vänligen ändra behörigheterna till 0770 så att katalogen inte kan listas av andra användare.", + "Please ask your server administrator to restart the web server." : "Be din serveradministratör att starta om webbservern.", + "Please change the permissions to 0770 so that the directory cannot be listed by other users." : "Ändra behörigheterna till 0770 så att katalogen inte kan listas av andra användare.", "Ensure there is a file called \".ocdata\" in the root of the data directory." : "Säkerställ att du har filen \".ocdata\" i huvudkatalogen för din data.", "Action \"%s\" not supported or implemented." : "Åtgärd \"%s\" stöds inte eller är inte implementerad.", "Authentication failed, wrong token or provider ID given" : "Autentisering misslyckades, felaktig token eller leverantörs-ID", @@ -250,11 +250,11 @@ "This can usually be fixed by giving the webserver write access to the root directory. See %s" : "Detta kan vanligtvis åtgärda genom att ge webbservern skrivåtkomst till rotkatalogen. Se %s", "Permissions can usually be fixed by giving the webserver write access to the root directory. See %s." : "Rättigheter kan vanligtvis fixas genom att ge webbservern skrivåtkomst till rotkatalogen. Se %s.", "Setting locale to %s failed" : "Sätta locale till %s misslyckades", - "Please install one of these locales on your system and restart your webserver." : "Vänligen Installera en av dessa språk på ditt system och starta om webbservern.", + "Please install one of these locales on your system and restart your webserver." : "Installera en av dessa språk på ditt system och starta om webbservern.", "mbstring.func_overload is set to \"%s\" instead of the expected value \"0\"" : "mbstring.func_overload är satt till \"%s\" istället för det förväntade värdet \"0\"", "To fix this issue set <code>mbstring.func_overload</code> to <code>0</code> in your php.ini" : "För att åtgärda detta problem sätt värdet <code> mbstring.func_overload till </ code> <code> 0 </ code> i din php.ini", "PostgreSQL >= 9 required" : "PostgreSQL >= 9 krävs", - "Please upgrade your database version" : "Vänligen uppgradera din databasversion", + "Please upgrade your database version" : "Uppgradera din databasversion", "Your data directory is readable by other users" : "Din datamapp är läsbar av andra användare", "Your data directory must be an absolute path" : "Du måste specificera en korrekt sökväg till datamappen", "Check the value of \"datadirectory\" in your configuration" : "Kontrollera värdet av \"datakatalog\" i din konfiguration", diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index fffeffd4feb..e0f36231b68 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -264,6 +264,9 @@ class SecurityMiddleware extends Middleware { if ($usernamePrefill !== '') { $params['user'] = $usernamePrefill; } + if ($this->request->getParam('direct')) { + $params['direct'] = 1; + } $url = $this->urlGenerator->linkToRoute('core.login.showLoginForm', $params); $response = new RedirectResponse($url); } else { diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 6f89ba64e80..0cd310550b6 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -49,12 +49,12 @@ use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Statement; -use OC\DB\QueryBuilder\QueryBuilder; -use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\ILogger; use OCP\IRequestId; use OCP\PreConditionNotMetException; +use OC\DB\QueryBuilder\QueryBuilder; +use OC\SystemConfig; +use Psr\Log\LoggerInterface; class Connection extends \Doctrine\DBAL\Connection { /** @var string */ @@ -66,8 +66,7 @@ class Connection extends \Doctrine\DBAL\Connection { /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; protected $lockedTable = null; @@ -78,6 +77,34 @@ class Connection extends \Doctrine\DBAL\Connection { protected $queriesExecuted = 0; /** + * Initializes a new instance of the Connection class. + * + * @throws \Exception + */ + public function __construct( + array $params, + Driver $driver, + ?Configuration $config = null, + ?EventManager $eventManager = null + ) { + if (!isset($params['adapter'])) { + throw new \Exception('adapter not set'); + } + if (!isset($params['tablePrefix'])) { + throw new \Exception('tablePrefix not set'); + } + /** + * @psalm-suppress InternalMethod + */ + parent::__construct($params, $driver, $config, $eventManager); + $this->adapter = new $params['adapter']($this); + $this->tablePrefix = $params['tablePrefix']; + + $this->systemConfig = \OC::$server->getSystemConfig(); + $this->logger = \OC::$server->get(LoggerInterface::class); + } + + /** * @throws Exception */ public function connect() { @@ -126,7 +153,7 @@ class Connection extends \Doctrine\DBAL\Connection { */ public function createQueryBuilder() { $backtrace = $this->getCallerBacktrace(); - \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); + $this->logger->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); $this->queriesBuilt++; return parent::createQueryBuilder(); } @@ -139,7 +166,7 @@ class Connection extends \Doctrine\DBAL\Connection { */ public function getExpressionBuilder() { $backtrace = $this->getCallerBacktrace(); - \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); + $this->logger->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); $this->queriesBuilt++; return parent::getExpressionBuilder(); } @@ -169,34 +196,6 @@ class Connection extends \Doctrine\DBAL\Connection { } /** - * Initializes a new instance of the Connection class. - * - * @param array $params The connection parameters. - * @param \Doctrine\DBAL\Driver $driver - * @param \Doctrine\DBAL\Configuration $config - * @param \Doctrine\Common\EventManager $eventManager - * @throws \Exception - */ - public function __construct(array $params, Driver $driver, Configuration $config = null, - EventManager $eventManager = null) { - if (!isset($params['adapter'])) { - throw new \Exception('adapter not set'); - } - if (!isset($params['tablePrefix'])) { - throw new \Exception('tablePrefix not set'); - } - /** - * @psalm-suppress InternalMethod - */ - parent::__construct($params, $driver, $config, $eventManager); - $this->adapter = new $params['adapter']($this); - $this->tablePrefix = $params['tablePrefix']; - - $this->systemConfig = \OC::$server->getSystemConfig(); - $this->logger = \OC::$server->getLogger(); - } - - /** * Prepares an SQL statement. * * @param string $statement The SQL statement to prepare. diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 5e146112120..046e3a4924b 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -43,6 +43,7 @@ use OCP\AppFramework\App; use OCP\AppFramework\QueryException; use OCP\Migration\IMigrationStep; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; class MigrationService { @@ -73,7 +74,7 @@ class MigrationService { $this->connection = $connection; $this->output = $output; if (null === $this->output) { - $this->output = new SimpleOutput(\OC::$server->getLogger(), $appName); + $this->output = new SimpleOutput(\OC::$server->get(LoggerInterface::class), $appName); } if ($appName === 'core') { @@ -594,6 +595,10 @@ class MigrationService { if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && $thing->getNotnull() && $thing->getType()->getName() === Types::BOOLEAN) { throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is type Bool and also NotNull, so it can not store "false".'); } + + if ($thing->getLength() > 4000 && $thing->getType()->getName() === Types::STRING) { + throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is type String, but exceeding the 4.000 length limit.'); + } } foreach ($table->getIndexes() as $thing) { diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php index 03630ea14a3..e0a7549a0ad 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php @@ -94,6 +94,18 @@ class FunctionBuilder implements IFunctionBuilder { return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); } + public function octetLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('OCTET_LENGTH(' . $quotedName . ')' . $alias); + } + + public function charLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('CHAR_LENGTH(' . $quotedName . ')' . $alias); + } + public function max($field): IQueryFunction { return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); } diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php index 43ecf599eba..a9844ec3373 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php @@ -91,4 +91,16 @@ class OCIFunctionBuilder extends FunctionBuilder { $separator = $this->connection->quote($separator); return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')' . $orderByClause); } + + public function octetLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias); + } + + public function charLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias); + } } diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php index fe700075a82..bb97d2e29f9 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php @@ -48,4 +48,16 @@ class SqliteFunctionBuilder extends FunctionBuilder { public function least($x, $y): IQueryFunction { return new QueryFunction('MIN(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); } + + public function octetLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('LENGTH(CAST(' . $quotedName . ' as BLOB))' . $alias); + } + + public function charLength($field, $alias = ''): IQueryFunction { + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; + $quotedName = $this->helper->quoteColumnName($field); + return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias); + } } diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index de326a2a317..4ecfd773492 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -53,7 +53,7 @@ use OCP\DB\QueryBuilder\ILiteral; use OCP\DB\QueryBuilder\IParameter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QueryBuilder implements IQueryBuilder { @@ -63,8 +63,7 @@ class QueryBuilder implements IQueryBuilder { /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \Doctrine\DBAL\Query\QueryBuilder */ private $queryBuilder; @@ -83,9 +82,8 @@ class QueryBuilder implements IQueryBuilder { * * @param ConnectionAdapter $connection * @param SystemConfig $systemConfig - * @param ILogger $logger */ - public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, LoggerInterface $logger) { $this->connection = $connection; $this->systemConfig = $systemConfig; $this->logger = $logger; @@ -229,8 +227,7 @@ class QueryBuilder implements IQueryBuilder { } } catch (\Error $e) { // likely an error during conversion of $value to string - $this->logger->debug('DB QueryBuilder: error trying to log SQL query'); - $this->logger->logException($e); + $this->logger->error('DB QueryBuilder: error trying to log SQL query', ['exception' => $e]); } } @@ -245,11 +242,10 @@ class QueryBuilder implements IQueryBuilder { if (empty($hasSelectAll) === empty($hasSelectSpecific)) { $exception = new QueryException('Query is selecting * and specific values in the same query. This is not supported in Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'Query is selecting * and specific values in the same query. This is not supported in Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } } @@ -266,21 +262,19 @@ class QueryBuilder implements IQueryBuilder { if ($hasTooLargeArrayParameter) { $exception = new QueryException('More than 1000 expressions in a list are not allowed on Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'More than 1000 expressions in a list are not allowed on Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } if ($numberOfParameters > 65535) { $exception = new QueryException('The number of parameters must not exceed 65535. Restriction by PostgreSQL.'); - $this->logger->logException($exception, [ - 'message' => 'The number of parameters must not exceed 65535. Restriction by PostgreSQL.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index e3dc539dd00..f2803fa5ff8 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -30,7 +30,6 @@ use OC\Files\View; use OC\Memcache\ArrayCache; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; use Psr\Log\LoggerInterface; /** @@ -48,19 +47,14 @@ class EncryptionWrapper { /** @var Manager */ private $manager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * EncryptionWrapper constructor. - * - * @param ArrayCache $arrayCache - * @param Manager $manager - * @param ILogger $logger */ public function __construct(ArrayCache $arrayCache, Manager $manager, - ILogger $logger + LoggerInterface $logger ) { $this->arrayCache = $arrayCache; $this->manager = $manager; @@ -101,7 +95,7 @@ class EncryptionWrapper { Filesystem::getMountManager(), $this->manager, $fileHelper, - \OC::$server->get(LoggerInterface::class), + $this->logger, $uid ); return new Encryption( diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index 55578ee25f4..5788da990d5 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -34,7 +34,7 @@ use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IManager; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Manager implements IManager { @@ -44,8 +44,7 @@ class Manager implements IManager { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var Il10n */ protected $l; @@ -59,15 +58,7 @@ class Manager implements IManager { /** @var ArrayCache */ protected $arrayCache; - /** - * @param IConfig $config - * @param ILogger $logger - * @param IL10N $l10n - * @param View $rootView - * @param Util $util - * @param ArrayCache $arrayCache - */ - public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { + public function __construct(IConfig $config, LoggerInterface $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { $this->encryptionModules = []; $this->config = $config; $this->logger = $logger; diff --git a/lib/private/EventDispatcher/GenericEventWrapper.php b/lib/private/EventDispatcher/GenericEventWrapper.php index 3574bc8bb83..b4d851d700f 100644 --- a/lib/private/EventDispatcher/GenericEventWrapper.php +++ b/lib/private/EventDispatcher/GenericEventWrapper.php @@ -26,13 +26,11 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; class GenericEventWrapper extends GenericEvent { - - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var GenericEvent */ private $event; @@ -43,7 +41,7 @@ class GenericEventWrapper extends GenericEvent { /** @var bool */ private $deprecationNoticeLogged = false; - public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) { + public function __construct(LoggerInterface $logger, string $eventName, ?GenericEvent $event) { parent::__construct($eventName); $this->logger = $logger; $this->event = $event; diff --git a/lib/private/EventDispatcher/SymfonyAdapter.php b/lib/private/EventDispatcher/SymfonyAdapter.php index 6cd636afc55..a12e932e380 100644 --- a/lib/private/EventDispatcher/SymfonyAdapter.php +++ b/lib/private/EventDispatcher/SymfonyAdapter.php @@ -27,12 +27,12 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use Symfony\Component\EventDispatcher\GenericEvent; -use function is_callable; use OCP\EventDispatcher\Event; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\GenericEvent; +use function is_callable; use function is_object; use function is_string; @@ -43,13 +43,12 @@ class SymfonyAdapter implements EventDispatcherInterface { /** @var EventDispatcher */ private $eventDispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * @deprecated 20.0.0 */ - public function __construct(EventDispatcher $eventDispatcher, ILogger $logger) { + public function __construct(EventDispatcher $eventDispatcher, LoggerInterface $logger) { $this->eventDispatcher = $eventDispatcher; $this->logger = $logger; } diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index c19ca8429ca..c25d4a40363 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -32,7 +32,7 @@ use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudFederationShare; use OCP\Federation\ICloudIdManager; use OCP\Http\Client\IClientService; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Manager @@ -55,8 +55,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** @var ICloudIdManager */ private $cloudIdManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var array cache OCM end-points */ private $ocmEndPoints = []; @@ -69,12 +68,11 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @param IAppManager $appManager * @param IClientService $httpClientService * @param ICloudIdManager $cloudIdManager - * @param ILogger $logger */ public function __construct(IAppManager $appManager, IClientService $httpClientService, ICloudIdManager $cloudIdManager, - ILogger $logger) { + LoggerInterface $logger) { $this->cloudFederationProvider = []; $this->appManager = $appManager; $this->httpClientService = $httpClientService; @@ -156,7 +154,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager // 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()); + $this->logger->debug($e->getMessage(), ['exception' => $e]); throw $e; } } @@ -190,7 +188,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager } } catch (\Exception $e) { // log the error and return false - $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); + $this->logger->error('error while sending notification for federated share: ' . $e->getMessage(), ['exception' => $e]); } return false; diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 7c2e635549a..949079dfa22 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -58,6 +58,7 @@ use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchQuery; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; +use Psr\Log\LoggerInterface; /** * Metadata cache for a storage @@ -128,7 +129,7 @@ class Cache implements ICache { return new CacheQueryBuilder( $this->connection, \OC::$server->getSystemConfig(), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); } @@ -590,7 +591,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->delete('filecache_extended') ->where($query->expr()->in('fileid', $query->createParameter('childIds'))); - + foreach (array_chunk($childIds, 1000) as $childIdChunk) { $query->setParameter('childIds', $childIdChunk, IQueryBuilder::PARAM_INT_ARRAY); $query->execute(); diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 87a1f940f20..b5a9101877c 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -29,7 +29,7 @@ use OC\DB\QueryBuilder\QueryBuilder; use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Query builder with commonly used helpers for filecache queries @@ -37,7 +37,7 @@ use OCP\ILogger; class CacheQueryBuilder extends QueryBuilder { private $alias = null; - public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(IDBConnection $connection, SystemConfig $systemConfig, LoggerInterface $logger) { parent::__construct($connection, $systemConfig, $logger); } diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index e065e95e4fd..3bf9abf3524 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -34,7 +34,7 @@ use OCP\Files\IMimeTypeLoader; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchQuery; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QuerySearchHelper { @@ -44,8 +44,7 @@ class QuerySearchHelper { private $connection; /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var SearchBuilder */ private $searchBuilder; /** @var QueryOptimizer */ @@ -55,7 +54,7 @@ class QuerySearchHelper { IMimeTypeLoader $mimetypeLoader, IDBConnection $connection, SystemConfig $systemConfig, - ILogger $logger, + LoggerInterface $logger, SearchBuilder $searchBuilder, QueryOptimizer $queryOptimizer ) { diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 9a5eddc4878..666ba9b065b 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -38,9 +38,9 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\ICache; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Cache mounts points per user in the cache so we can easilly look them up @@ -64,10 +64,7 @@ class UserMountCache implements IUserMountCache { **/ private $mountsForUsers; - /** - * @var ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var ICache @@ -76,12 +73,8 @@ class UserMountCache implements IUserMountCache { /** * UserMountCache constructor. - * - * @param IDBConnection $connection - * @param IUserManager $userManager - * @param ILogger $logger */ - public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { + public function __construct(IDBConnection $connection, IUserManager $userManager, LoggerInterface $logger) { $this->connection = $connection; $this->userManager = $userManager; $this->logger = $logger; diff --git a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php index 0043503f2cd..3a20afba5a5 100644 --- a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php +++ b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php @@ -31,18 +31,17 @@ use OC\Files\Storage\Wrapper\Jail; use OCP\Files\Config\IRootMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Mount provider for object store app data folder for previews */ class ObjectStorePreviewCacheMountProvider implements IRootMountProvider { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; - public function __construct(ILogger $logger, IConfig $config) { + public function __construct(LoggerInterface $logger, IConfig $config) { $this->logger = $logger; $this->config = $config; } diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 53162737b6f..a8b36ee7731 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -44,9 +44,9 @@ use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class Root @@ -73,7 +73,7 @@ class Root extends Folder implements IRootFolder { private ?IUser $user; private CappedMemoryCache $userFolderCache; private IUserMountCache $userMountCache; - private ILogger $logger; + private LoggerInterface $logger; private IUserManager $userManager; private IEventDispatcher $eventDispatcher; @@ -81,16 +81,13 @@ class Root extends Folder implements IRootFolder { * @param Manager $manager * @param View $view * @param IUser|null $user - * @param IUserMountCache $userMountCache - * @param ILogger $logger - * @param IUserManager $userManager */ public function __construct( $manager, $view, $user, IUserMountCache $userMountCache, - ILogger $logger, + LoggerInterface $logger, IUserManager $userManager, IEventDispatcher $eventDispatcher ) { diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index a3c8d92f3d2..b463cb9d44d 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -32,6 +32,7 @@ use Icewind\Streams\RetryWrapper; use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; use OCP\Files\StorageAuthException; +use Psr\Log\LoggerInterface; const SWIFT_SEGMENT_SIZE = 1073741824; // 1GB @@ -48,7 +49,7 @@ class Swift implements IObjectStore { $this->swiftFactory = $connectionFactory ?: new SwiftFactory( \OC::$server->getMemCacheFactory()->createDistributed('swift::'), $params, - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $this->params = $params; } diff --git a/lib/private/Files/ObjectStore/SwiftFactory.php b/lib/private/Files/ObjectStore/SwiftFactory.php index df4b5a93678..bd75ccada2e 100644 --- a/lib/private/Files/ObjectStore/SwiftFactory.php +++ b/lib/private/Files/ObjectStore/SwiftFactory.php @@ -40,7 +40,6 @@ use GuzzleHttp\HandlerStack; use OCP\Files\StorageAuthException; use OCP\Files\StorageNotAvailableException; use OCP\ICache; -use OCP\ILogger; use OpenStack\Common\Auth\Token; use OpenStack\Common\Error\BadResponseError; use OpenStack\Common\Transport\Utils as TransportUtils; @@ -50,13 +49,14 @@ use OpenStack\Identity\v3\Service as IdentityV3Service; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\OpenStack; use Psr\Http\Message\RequestInterface; +use Psr\Log\LoggerInterface; class SwiftFactory { private $cache; private $params; /** @var Container|null */ private $container = null; - private $logger; + private LoggerInterface $logger; public const DEFAULT_OPTIONS = [ 'autocreate' => false, @@ -65,7 +65,7 @@ class SwiftFactory { 'catalogType' => 'object-store' ]; - public function __construct(ICache $cache, array $params, ILogger $logger) { + public function __construct(ICache $cache, array $params, LoggerInterface $logger) { $this->cache = $cache; $this->params = $params; $this->logger = $logger; @@ -203,7 +203,7 @@ class SwiftFactory { $this->logger->debug('Cached token for swift expired'); } } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } @@ -279,7 +279,7 @@ class SwiftFactory { /** @var RequestInterface $request */ $request = $e->getRequest(); $host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort(); - \OC::$server->getLogger()->error("Can't connect to object storage server at $host"); + $this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]); throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e); } } diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index b4a85755b20..ee874d97b55 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -587,8 +587,8 @@ class DAV extends Common { return false; } return [ - 'mtime' => strtotime($response['{DAV:}getlastmodified']), - 'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, + 'mtime' => isset($response['{DAV:}getlastmodified']) ? strtotime($response['{DAV:}getlastmodified']) : null, + 'size' => (int)($response['{DAV:}getcontentlength'] ?? 0), ]; } catch (\Exception $e) { $this->convertException($e, $path); @@ -804,9 +804,12 @@ class DAV extends Common { } else { return false; } - } else { + } elseif (isset($response['{DAV:}getlastmodified'])) { $remoteMtime = strtotime($response['{DAV:}getlastmodified']); return $remoteMtime > $time; + } else { + // neither `getetag` nor `getlastmodified` is set + return false; } } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 405) { diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 75611d1ab0f..4cfe932cc9f 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -50,7 +50,7 @@ use OCP\Encryption\Keys\IStorage; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Encryption extends Wrapper { use LocalTempFileTrait; @@ -64,8 +64,7 @@ class Encryption extends Wrapper { /** @var \OCP\Encryption\IManager */ private $encryptionManager; - /** @var \OCP\ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $uid; @@ -96,21 +95,12 @@ class Encryption extends Wrapper { /** * @param array $parameters - * @param IManager $encryptionManager - * @param Util $util - * @param ILogger $logger - * @param IFile $fileHelper - * @param string $uid - * @param IStorage $keyStorage - * @param Update $update - * @param Manager $mountManager - * @param ArrayCache $arrayCache */ public function __construct( $parameters, IManager $encryptionManager = null, Util $util = null, - ILogger $logger = null, + LoggerInterface $logger = null, IFile $fileHelper = null, $uid = null, IStorage $keyStorage = null, @@ -448,9 +438,8 @@ class Encryption extends Wrapper { } } } catch (ModuleDoesNotExistsException $e) { - $this->logger->logException($e, [ - 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', - 'level' => ILogger::WARN, + $this->logger->warning('Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', [ + 'exception' => $e, 'app' => 'core', ]); } @@ -503,8 +492,7 @@ class Encryption extends Wrapper { try { $result = $this->fixUnencryptedSize($path, $size, $unencryptedSize); } catch (\Exception $e) { - $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path); - $this->logger->logException($e); + $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path, ['exception' => $e]); } unset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]); } diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index bd2bfb5f939..4cade024460 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -42,8 +42,8 @@ declare(strict_types=1); namespace OC\Files\Type; use OCP\Files\IMimeTypeDetector; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; /** * Class Detection @@ -66,8 +66,7 @@ class Detection implements IMimeTypeDetector { /** @var IURLGenerator */ private $urlGenerator; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $customConfigDir; @@ -75,14 +74,8 @@ class Detection implements IMimeTypeDetector { /** @var string */ private $defaultConfigDir; - /** - * @param IURLGenerator $urlGenerator - * @param ILogger $logger - * @param string $customConfigDir - * @param string $defaultConfigDir - */ public function __construct(IURLGenerator $urlGenerator, - ILogger $logger, + LoggerInterface $logger, string $customConfigDir, string $defaultConfigDir) { $this->urlGenerator = $urlGenerator; diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 5b633617608..dc220bc710d 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -48,7 +48,7 @@ use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Scanner @@ -71,8 +71,7 @@ class Scanner extends PublicEmitter { /** @var IEventDispatcher */ private $dispatcher; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** * Whether to use a DB transaction @@ -92,9 +91,8 @@ class Scanner extends PublicEmitter { * @param string $user * @param IDBConnection|null $db * @param IEventDispatcher $dispatcher - * @param ILogger $logger */ - public function __construct($user, $db, IEventDispatcher $dispatcher, ILogger $logger) { + public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInterface $logger) { $this->user = $user; $this->db = $db; $this->dispatcher = $dispatcher; @@ -263,8 +261,7 @@ class Scanner extends PublicEmitter { } $propagator->commitBatch(); } catch (StorageNotAvailableException $e) { - $this->logger->error('Storage ' . $storage->getId() . ' not available'); - $this->logger->logException($e); + $this->logger->error('Storage ' . $storage->getId() . ' not available', ['exception' => $e]); $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); } if ($this->useTransaction) { diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index e1bd009e79c..28f7a400b41 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -44,8 +44,8 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\GroupInterface; use OCP\IGroup; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -71,8 +71,7 @@ class Manager extends PublicEmitter implements IGroupManager { private $userManager; /** @var EventDispatcherInterface */ private $dispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \OC\Group\Group[] */ private $cachedGroups = []; @@ -83,14 +82,9 @@ class Manager extends PublicEmitter implements IGroupManager { /** @var \OC\SubAdmin */ private $subAdmin = null; - /** - * @param \OC\User\Manager $userManager - * @param EventDispatcherInterface $dispatcher - * @param ILogger $logger - */ public function __construct(\OC\User\Manager $userManager, EventDispatcherInterface $dispatcher, - ILogger $logger) { + LoggerInterface $logger) { $this->userManager = $userManager; $this->dispatcher = $dispatcher; $this->logger = $logger; diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 673f566e354..3ba85a2dd9f 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -39,7 +39,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IResponse; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class Client @@ -51,8 +50,6 @@ class Client implements IClient { private $client; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var LocalAddressChecker */ @@ -60,13 +57,11 @@ class Client implements IClient { public function __construct( IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, GuzzleClient $client, LocalAddressChecker $localAddressChecker ) { $this->config = $config; - $this->logger = $logger; $this->client = $client; $this->certificateManager = $certificateManager; $this->localAddressChecker = $localAddressChecker; diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php index d1aed2d7883..e868d4af7a5 100644 --- a/lib/private/Http/Client/ClientService.php +++ b/lib/private/Http/Client/ClientService.php @@ -33,7 +33,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class ClientService @@ -43,8 +42,6 @@ use OCP\ILogger; class ClientService implements IClientService { /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var DnsPinMiddleware */ @@ -53,12 +50,10 @@ class ClientService implements IClientService { private $localAddressChecker; public function __construct(IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, DnsPinMiddleware $dnsPinMiddleware, LocalAddressChecker $localAddressChecker) { $this->config = $config; - $this->logger = $logger; $this->certificateManager = $certificateManager; $this->dnsPinMiddleware = $dnsPinMiddleware; $this->localAddressChecker = $localAddressChecker; @@ -76,7 +71,6 @@ class ClientService implements IClientService { return new Client( $this->config, - $this->logger, $this->certificateManager, $client, $this->localAddressChecker diff --git a/lib/private/Http/Client/LocalAddressChecker.php b/lib/private/Http/Client/LocalAddressChecker.php index c534c5971d1..2789b1b5935 100644 --- a/lib/private/Http/Client/LocalAddressChecker.php +++ b/lib/private/Http/Client/LocalAddressChecker.php @@ -25,14 +25,13 @@ declare(strict_types=1); */ namespace OC\Http\Client; -use OCP\ILogger; use OCP\Http\Client\LocalServerException; +use Psr\Log\LoggerInterface; class LocalAddressChecker { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index 1ea78d047d2..5eb03ad856b 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -31,9 +31,9 @@ use OC\DB\QueryBuilder\Literal; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; +use Psr\Log\LoggerInterface; /** * Locking provider that stores the locks in the database @@ -44,10 +44,7 @@ class DBLockingProvider extends AbstractLockingProvider { */ private $connection; - /** - * @var \OCP\ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var \OCP\AppFramework\Utility\ITimeFactory @@ -104,15 +101,11 @@ class DBLockingProvider extends AbstractLockingProvider { } /** - * @param \OCP\IDBConnection $connection - * @param \OCP\ILogger $logger - * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory - * @param int $ttl * @param bool $cacheSharedLocks */ public function __construct( IDBConnection $connection, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $timeFactory, int $ttl = 3600, $cacheSharedLocks = true diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 61f506d2676..2f3480498be 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -41,7 +41,6 @@ use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Mail\Events\BeforeMessageSent; @@ -49,6 +48,7 @@ use OCP\Mail\IAttachment; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use Psr\Log\LoggerInterface; /** * Class Mailer provides some basic functions to create a mail message that can be used in combination with @@ -73,8 +73,7 @@ class Mailer implements IMailer { private $instance = null; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var Defaults */ private $defaults; /** @var IURLGenerator */ @@ -86,16 +85,8 @@ class Mailer implements IMailer { /** @var IFactory */ private $l10nFactory; - /** - * @param IConfig $config - * @param ILogger $logger - * @param Defaults $defaults - * @param IURLGenerator $urlGenerator - * @param IL10N $l10n - * @param IEventDispatcher $dispatcher - */ public function __construct(IConfig $config, - ILogger $logger, + LoggerInterface $logger, Defaults $defaults, IURLGenerator $urlGenerator, IL10N $l10n, diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 7791c4beae9..73206aac011 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -33,8 +33,8 @@ namespace OC\Memcache; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IMemcache; +use Psr\Log\LoggerInterface; class Factory implements ICacheFactory { public const NULL_CACHE = NullCache::class; @@ -44,10 +44,7 @@ class Factory implements ICacheFactory { */ private $globalPrefix; - /** - * @var ILogger $logger - */ - private $logger; + private LoggerInterface $logger; /** * @var string $localCacheClass @@ -67,16 +64,14 @@ class Factory implements ICacheFactory { /** @var string */ private $logFile; - /** - * @param string $globalPrefix - * @param ILogger $logger - * @param string|null $localCacheClass - * @param string|null $distributedCacheClass - * @param string|null $lockingCacheClass - * @param string $logFile - */ - public function __construct(string $globalPrefix, ILogger $logger, - $localCacheClass = null, $distributedCacheClass = null, $lockingCacheClass = null, string $logFile = '') { + public function __construct( + string $globalPrefix, + LoggerInterface $logger, + ?string $localCacheClass = null, + ?string $distributedCacheClass = null, + ?string $lockingCacheClass = null, + string $logFile = '' + ) { $this->logger = $logger; $this->logFile = $logFile; $this->globalPrefix = $globalPrefix; diff --git a/lib/private/Migration/SimpleOutput.php b/lib/private/Migration/SimpleOutput.php index 5024fdac585..f97bcb767f8 100644 --- a/lib/private/Migration/SimpleOutput.php +++ b/lib/private/Migration/SimpleOutput.php @@ -21,8 +21,8 @@ */ namespace OC\Migration; -use OCP\ILogger; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; /** * Class SimpleOutput @@ -33,12 +33,10 @@ use OCP\Migration\IOutput; * @package OC\Migration */ class SimpleOutput implements IOutput { - - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; private $appName; - public function __construct(ILogger $logger, $appName) { + public function __construct(LoggerInterface $logger, $appName) { $this->logger = $logger; $this->appName = $appName; } diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 677588fa9ee..91bfd47f5de 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -94,13 +94,12 @@ class Repair implements IOutput { /** @var string */ private $currentStep; - private $logger; + private LoggerInterface $logger; /** * Creates a new repair step runner * * @param IRepairStep[] $repairSteps array of RepairStep instances - * @param EventDispatcherInterface $dispatcher */ public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher, LoggerInterface $logger) { $this->repairSteps = $repairSteps; @@ -172,7 +171,7 @@ class Repair implements IOutput { */ public static function getRepairSteps() { return [ - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false), + new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->getDatabaseConnection(), false), new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()), new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), @@ -199,7 +198,7 @@ class Repair implements IOutput { new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)), new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), - new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()), + new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)), new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)), @@ -240,7 +239,7 @@ class Repair implements IOutput { $connectionAdapter = \OC::$server->get(ConnectionAdapter::class); $config = \OC::$server->getConfig(); $steps = [ - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connectionAdapter, true), + new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), $connectionAdapter, true), new SqliteAutoincrement($connection), new SaveAccountsTableData($connectionAdapter, $config), new DropAccountTermsTable($connectionAdapter), diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index e949c261b80..25e85f00af8 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -30,16 +30,15 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\MySQLPlatform; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; class Collation implements IRepairStep { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IDBConnection */ protected $connection; @@ -48,12 +47,14 @@ class Collation implements IRepairStep { protected $ignoreFailures; /** - * @param IConfig $config - * @param ILogger $logger - * @param IDBConnection $connection * @param bool $ignoreFailures */ - public function __construct(IConfig $config, ILogger $logger, IDBConnection $connection, $ignoreFailures) { + public function __construct( + IConfig $config, + LoggerInterface $logger, + IDBConnection $connection, + $ignoreFailures + ) { $this->connection = $connection; $this->config = $config; $this->logger = $logger; @@ -83,7 +84,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } @@ -95,7 +96,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index 39b48562791..25dc24fb66c 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -30,9 +30,9 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; use RuntimeException; /** @@ -52,10 +52,9 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var IAppData */ private $appData; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(IConfig $config, IAppData $appData, ILogger $logger) { + public function __construct(IConfig $config, IAppData $appData, LoggerInterface $logger) { $this->config = $config; $this->appData = $appData; $this->logger = $logger; @@ -71,7 +70,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { } catch (NotFoundException $e) { return; } catch (RuntimeException $e) { - $this->logger->logException($e, ['message' => 'Failed to fetch directory listing in CleanupCardDAVPhotoCache']); + $this->logger->error('Failed to fetch directory listing in CleanupCardDAVPhotoCache', ['exception' => $e]); return; } @@ -90,7 +89,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var ISimpleFolder $folder */ $folder->getFile('photo.')->delete(); } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); $output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."'); } } diff --git a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php index 67f9d6912d9..7f4bbc35c17 100644 --- a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php +++ b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php @@ -29,15 +29,14 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class CleanPreviewsBackgroundJob extends QueuedJob { /** @var IRootFolder */ private $rootFolder; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IJobList */ private $jobList; @@ -50,15 +49,9 @@ class CleanPreviewsBackgroundJob extends QueuedJob { /** * CleanPreviewsBackgroundJob constructor. - * - * @param IRootFolder $rootFolder - * @param ILogger $logger - * @param IJobList $jobList - * @param ITimeFactory $timeFactory - * @param IUserManager $userManager */ public function __construct(IRootFolder $rootFolder, - ILogger $logger, + LoggerInterface $logger, IJobList $jobList, ITimeFactory $timeFactory, IUserManager $userManager) { diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index 553ea285fd4..f65060e710b 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -24,7 +24,7 @@ */ namespace OC\Route; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CachingRouter extends Router { /** @@ -34,9 +34,8 @@ class CachingRouter extends Router { /** * @param \OCP\ICache $cache - * @param ILogger $logger */ - public function __construct($cache, ILogger $logger) { + public function __construct($cache, LoggerInterface $logger) { $this->cache = $cache; parent::__construct($logger); } diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index fcde8f08897..b957173cacc 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -34,9 +34,9 @@ namespace OC\Route; use OC\AppFramework\Routing\RouteParser; use OCP\AppFramework\App; -use OCP\ILogger; use OCP\Route\IRouter; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGenerator; @@ -61,15 +61,11 @@ class Router implements IRouter { protected $loaded = false; /** @var array */ protected $loadedApps = []; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var RequestContext */ protected $context; - /** - * @param ILogger $logger - */ - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; $baseUrl = \OC::$WEBROOT; if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { @@ -364,7 +360,7 @@ class Router implements IRouter { try { return $this->getGenerator()->generate($name, $parameters, $referenceType); } catch (RouteNotFoundException $e) { - $this->logger->logException($e, ['level' => ILogger::INFO]); + $this->logger->info($e->getMessage(), ['exception' => $e]); return ''; } } diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index d5f35f504e0..3c228261ec2 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -28,14 +28,14 @@ declare(strict_types=1); namespace OC\Search; use InvalidArgumentException; -use OC\AppFramework\Bootstrap\Coordinator; use OCP\AppFramework\QueryException; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OC\AppFramework\Bootstrap\Coordinator; +use Psr\Log\LoggerInterface; use function array_map; /** @@ -68,12 +68,11 @@ class SearchComposer { /** @var IServerContainer */ private $container; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Coordinator $bootstrapCoordinator, IServerContainer $container, - ILogger $logger) { + LoggerInterface $logger) { $this->container = $container; $this->logger = $logger; $this->bootstrapCoordinator = $bootstrapCoordinator; @@ -99,9 +98,8 @@ class SearchComposer { $this->providers[$provider->getId()] = $provider; } catch (QueryException $e) { // Log an continue. We can be fault tolerant here. - $this->logger->logException($e, [ - 'message' => 'Could not load search provider dynamically: ' . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error('Could not load search provider dynamically: ' . $e->getMessage(), [ + 'exception' => $e, 'app' => $registration->getAppId(), ]); } diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index abbe77c6637..c47d102b881 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -36,8 +36,8 @@ use OC\Security\Normalizer\IpAddress; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Security\Bruteforce\MaxDelayReached; +use Psr\Log\LoggerInterface; /** * Class Throttler implements the bruteforce protection for security actions in @@ -62,22 +62,15 @@ class Throttler { private $db; /** @var ITimeFactory */ private $timeFactory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var bool */ private $hasAttemptsDeleted = false; - /** - * @param IDBConnection $db - * @param ITimeFactory $timeFactory - * @param ILogger $logger - * @param IConfig $config - */ public function __construct(IDBConnection $db, ITimeFactory $timeFactory, - ILogger $logger, + LoggerInterface $logger, IConfig $config) { $this->db = $db; $this->timeFactory = $timeFactory; diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index 74ea59c3792..fa26c19ceae 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -36,8 +36,8 @@ use OC\Files\Filesystem; use OCP\ICertificate; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; /** * Manage trusted certificates for users @@ -53,25 +53,16 @@ class CertificateManager implements ICertificateManager { */ protected $config; - /** - * @var ILogger - */ - protected $logger; + protected LoggerInterface $logger; /** @var ISecureRandom */ protected $random; private ?string $bundlePath = null; - /** - * @param \OC\Files\View $view relative to data/ - * @param IConfig $config - * @param ILogger $logger - * @param ISecureRandom $random - */ public function __construct(\OC\Files\View $view, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ISecureRandom $random) { $this->view = $view; $this->config = $config; @@ -147,7 +138,8 @@ class CertificateManager implements ICertificateManager { $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle // log as exception so we have a stacktrace - $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle')); + $e = new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'); + $this->logger->error($e->getMessage(), ['exception' => $e]); return; } diff --git a/lib/private/Security/IdentityProof/Manager.php b/lib/private/Security/IdentityProof/Manager.php index 0878efeebc7..c92d7390969 100644 --- a/lib/private/Security/IdentityProof/Manager.php +++ b/lib/private/Security/IdentityProof/Manager.php @@ -32,9 +32,9 @@ namespace OC\Security\IdentityProof; use OC\Files\AppData\Factory; use OCP\Files\IAppData; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class Manager { /** @var IAppData */ @@ -43,13 +43,12 @@ class Manager { private $crypto; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Factory $appDataFactory, ICrypto $crypto, IConfig $config, - ILogger $logger + LoggerInterface $logger ) { $this->appData = $appDataFactory->get('identityproof'); $this->crypto = $crypto; diff --git a/lib/private/Server.php b/lib/private/Server.php index b189905cfaf..682e6fa06ce 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -354,7 +354,7 @@ class Server extends ServerContainer implements IServerContainer { ); return new Encryption\Manager( $c->get(\OCP\IConfig::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->getL10N('core'), new View(), $util, @@ -428,7 +428,7 @@ class Server extends ServerContainer implements IServerContainer { $view, null, $c->get(IUserMountCache::class), - $this->get(ILogger::class), + $this->get(LoggerInterface::class), $this->get(IUserManager::class), $this->get(IEventDispatcher::class), ); @@ -466,7 +466,11 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) { - $groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class)); + $groupManager = new \OC\Group\Manager( + $this->get(IUserManager::class), + $c->get(SymfonyAdapter::class), + $this->get(LoggerInterface::class) + ); $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->get(IEventDispatcher::class); @@ -547,7 +551,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(\OCP\IConfig::class), $c->get(ISecureRandom::class), $c->getLockdownManager(), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(IEventDispatcher::class) ); /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */ @@ -687,7 +691,9 @@ class Server extends ServerContainer implements IServerContainer { $this->registerDeprecatedAlias('UserCache', ICache::class); $this->registerService(Factory::class, function (Server $c) { - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class), + $arrayCacheFactory = new \OC\Memcache\Factory( + '', + $c->get(LoggerInterface::class), ArrayCache::class, ArrayCache::class, ArrayCache::class @@ -711,7 +717,9 @@ class Server extends ServerContainer implements IServerContainer { $instanceId = \OC_Util::getInstanceId(); $path = \OC::$SERVERROOT; $prefix = md5($instanceId . '-' . $version . '-' . $path); - return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class), + return new \OC\Memcache\Factory( + $prefix, + $c->get(LoggerInterface::class), $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), $config->getSystemValue('memcache.locking', null), @@ -792,7 +800,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(Router::class, function (Server $c) { $cacheFactory = $c->get(ICacheFactory::class); - $logger = $c->get(ILogger::class); + $logger = $c->get(LoggerInterface::class); if ($cacheFactory->isLocalCacheAvailable()) { $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); } else { @@ -863,7 +871,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(IClientService::class, ClientService::class); $this->registerService(LocalAddressChecker::class, function (ContainerInterface $c) { return new LocalAddressChecker( - $c->get(ILogger::class), + $c->get(LoggerInterface::class), ); }); $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) { @@ -934,7 +942,7 @@ class Server extends ServerContainer implements IServerContainer { $mountCache = new UserMountCache( $c->get(IDBConnection::class), $c->get(IUserManager::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); $listener = new UserMountCacheListener($mountCache); $listener->listen($c->get(IUserManager::class)); @@ -951,7 +959,7 @@ class Server extends ServerContainer implements IServerContainer { // builtin providers $config = $c->get(\OCP\IConfig::class); - $logger = $c->get(ILogger::class); + $logger = $c->get(LoggerInterface::class); $manager->registerProvider(new CacheMountProvider($config)); $manager->registerHomeProvider(new LocalHomeMountProvider()); $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); @@ -1054,7 +1062,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(IMailer::class, function (Server $c) { return new Mailer( $c->get(\OCP\IConfig::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(Defaults::class), $c->get(IURLGenerator::class), $c->getL10N('lib'), @@ -1094,7 +1102,7 @@ class Server extends ServerContainer implements IServerContainer { } return new DBLockingProvider( $c->get(IDBConnection::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), new TimeFactory(), $ttl, !\OC::$CLI @@ -1117,7 +1125,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) { return new \OC\Files\Type\Detection( $c->get(IURLGenerator::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), \OC::$configDir, \OC::$SERVERROOT . '/resources/config/' ); @@ -1214,7 +1222,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IURLGenerator::class), $this->get(ICacheFactory::class), $c->get(SystemConfig::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); }); $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); @@ -1263,7 +1271,7 @@ class Server extends ServerContainer implements IServerContainer { $factory = new $factoryClass($this); $manager = new \OC\Share20\Manager( - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(\OCP\IConfig::class), $c->get(ISecureRandom::class), $c->get(IHasher::class), @@ -1342,7 +1350,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IAppManager::class), $c->get(IClientService::class), $c->get(ICloudIdManager::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); }); @@ -1451,7 +1459,7 @@ class Server extends ServerContainer implements IServerContainer { // Delete avatar on user deletion $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { - $logger = $this->get(ILogger::class); + $logger = $this->get(LoggerInterface::class); $manager = $this->getAvatarManager(); /** @var IUser $user */ $user = $e->getSubject(); @@ -2360,8 +2368,8 @@ class Server extends ServerContainer implements IServerContainer { private function registerDeprecatedAlias(string $alias, string $target) { $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { try { - /** @var ILogger $logger */ - $logger = $container->get(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $container->get(LoggerInterface::class); $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); } catch (ContainerExceptionInterface $e) { // Could not get logger. Continue diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 2aa4d099024..2a76ddafb25 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -57,7 +57,6 @@ use OCP\HintException; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -75,6 +74,7 @@ use OCP\Share\IManager; use OCP\Share\IProviderFactory; use OCP\Share\IShare; use OCP\Share\IShareProvider; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -85,8 +85,7 @@ class Manager implements IManager { /** @var IProviderFactory */ private $factory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var ISecureRandom */ @@ -125,7 +124,7 @@ class Manager implements IManager { private $knownUserService; public function __construct( - ILogger $logger, + LoggerInterface $logger, IConfig $config, ISecureRandom $secureRandom, IHasher $hasher, @@ -951,7 +950,7 @@ class Manager implements IManager { return; } } catch (\Exception $e) { - $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); + $this->logger->error('Share notification mail could not be sent', ['exception' => $e]); } } diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 9ee11e723e5..a038ba7ce9b 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -31,7 +31,7 @@ */ namespace OC\Template; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CSSResourceLocator extends ResourceLocator { @@ -39,13 +39,12 @@ class CSSResourceLocator extends ResourceLocator { protected $scssCacher; /** - * @param ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map * @param SCSSCacher $scssCacher */ - public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map, $scssCacher) { $this->scssCacher = $scssCacher; parent::__construct($logger, $theme, $core_map, $party_map); diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index 01500aa2e9c..c2956d5712a 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -36,13 +36,11 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class IconsCacher { - - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -68,13 +66,9 @@ class IconsCacher { private $cachedList; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param ITimeFactory $timeFactory * @throws \OCP\Files\NotPermittedException */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, ITimeFactory $timeFactory) { diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index d2073fbbb83..a6d9f0ee558 100644 --- a/lib/private/Template/JSCombiner.php +++ b/lib/private/Template/JSCombiner.php @@ -33,8 +33,8 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class JSCombiner { @@ -50,24 +50,16 @@ class JSCombiner { /** @var SystemConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var ICacheFactory */ private $cacheFactory; - /** - * @param IAppData $appData - * @param IURLGenerator $urlGenerator - * @param ICacheFactory $cacheFactory - * @param SystemConfig $config - * @param ILogger $logger - */ public function __construct(IAppData $appData, IURLGenerator $urlGenerator, ICacheFactory $cacheFactory, SystemConfig $config, - ILogger $logger) { + LoggerInterface $logger) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->cacheFactory = $cacheFactory; diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index bf84e1ae958..95ae0d3d832 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -27,12 +27,14 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + class JSResourceLocator extends ResourceLocator { /** @var JSCombiner */ protected $jsCombiner; - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { + public function __construct(LoggerInterface $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { parent::__construct($logger, $theme, $core_map, $party_map); $this->jsCombiner = $JSCombiner; diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index 3ca34259907..5a50cc6fd1b 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -29,6 +29,8 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + abstract class ResourceLocator { protected $theme; @@ -39,16 +41,14 @@ abstract class ResourceLocator { protected $resources = []; - /** @var \OCP\ILogger */ - protected $logger; + protected LoggerInterface $logger; /** - * @param \OCP\ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map) { $this->logger = $logger; $this->theme = $theme; $this->mapping = $core_map + $party_map; diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 536557e7a3d..a552122b358 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -41,16 +41,14 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IMemcache; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; use ScssPhp\ScssPhp\Compiler; use ScssPhp\ScssPhp\OutputStyle; class SCSSCacher { - - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -91,17 +89,9 @@ class SCSSCacher { private $appConfig; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param IConfig $config - * @param \OC_Defaults $defaults * @param string $serverRoot - * @param ICacheFactory $cacheFactory - * @param IconsCacher $iconsCacher - * @param ITimeFactory $timeFactory */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, IConfig $config, @@ -340,7 +330,7 @@ class SCSSCacher { '@import "functions.scss";' . '@import "' . $fileNameSCSS . '";'); } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['app' => 'scss_cacher', 'exception' => $e]); return false; } @@ -395,7 +385,7 @@ class SCSSCacher { try { $file->delete(); } catch (NotPermittedException $e) { - $this->logger->logException($e, ['message' => 'SCSSCacher::resetCache unable to delete file: ' . $file->getName(), 'app' => 'scss_cacher']); + $this->logger->error('SCSSCacher::resetCache unable to delete file: ' . $file->getName(), ['exception' => $e, 'app' => 'scss_cacher']); } } } @@ -431,7 +421,7 @@ class SCSSCacher { $scss->compile($variables); $this->injectedVariables = $variables; } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'scss_cacher']); } return $variables; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index d7a86ff92bf..cf06f021590 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -57,6 +57,7 @@ use OCP\IUserSession; use OCP\Support\Subscription\IRegistry; use OCP\UserStatus\IManager as IUserStatusManager; use OCP\Util; +use Psr\Log\LoggerInterface; class TemplateLayout extends \OC_Template { private static $versionHash = ''; @@ -345,7 +346,7 @@ class TemplateLayout extends \OC_Template { } $locator = new \OC\Template\CSSResourceLocator( - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), $theme, [ \OC::$SERVERROOT => \OC::$WEBROOT ], [ \OC::$SERVERROOT => \OC::$WEBROOT ], @@ -380,7 +381,7 @@ class TemplateLayout extends \OC_Template { $theme = \OC_Util::getTheme(); $locator = new \OC\Template\JSResourceLocator( - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), $theme, [ \OC::$SERVERROOT => \OC::$WEBROOT ], [ \OC::$SERVERROOT => \OC::$WEBROOT ], diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index e3ced6e5b12..e2b66853788 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -30,21 +30,20 @@ namespace OC\Updater; use OCP\AppFramework\Db\DoesNotExistException; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class ChangesCheck { /** @var IClientService */ protected $clientService; /** @var ChangesMapper */ private $mapper; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public const RESPONSE_NO_CONTENT = 0; public const RESPONSE_USE_CACHE = 1; public const RESPONSE_HAS_CONTENT = 2; - public function __construct(IClientService $clientService, ChangesMapper $mapper, ILogger $logger) { + public function __construct(IClientService $clientService, ChangesMapper $mapper, LoggerInterface $logger) { $this->clientService = $clientService; $this->mapper = $mapper; $this->logger = $logger; diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index cd26337cd20..365a01c4595 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -54,7 +54,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\NotPermittedException; use OCP\IConfig; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IUser; @@ -64,6 +63,7 @@ use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\PostLoginEvent; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -114,21 +114,10 @@ class Session implements IUserSession, Emitter { /** @var ILockdownManager */ private $lockdownManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IEventDispatcher */ private $dispatcher; - /** - * @param Manager $manager - * @param ISession $session - * @param ITimeFactory $timeFactory - * @param IProvider|null $tokenProvider - * @param IConfig $config - * @param ISecureRandom $random - * @param ILockdownManager $lockdownManager - * @param ILogger $logger - */ public function __construct(Manager $manager, ISession $session, ITimeFactory $timeFactory, @@ -136,7 +125,7 @@ class Session implements IUserSession, Emitter { IConfig $config, ISecureRandom $random, ILockdownManager $lockdownManager, - ILogger $logger, + LoggerInterface $logger, IEventDispatcher $dispatcher ) { $this->manager = $manager; @@ -533,9 +522,8 @@ class Session implements IUserSession, Emitter { } catch (ExpiredTokenException $e) { throw $e; } catch (InvalidTokenException $ex) { - $this->logger->logException($ex, [ - 'level' => ILogger::DEBUG, - 'message' => 'Token is not valid: ' . $ex->getMessage(), + $this->logger->debug('Token is not valid: ' . $ex->getMessage(), [ + 'exception' => $ex, ]); return false; } @@ -890,7 +878,7 @@ class Session implements IUserSession, Emitter { } catch (SessionNotAvailableException $ex) { return false; } catch (InvalidTokenException $ex) { - \OC::$server->getLogger()->warning('Renewing session token failed', ['app' => 'core']); + $this->logger->warning('Renewing session token failed', ['app' => 'core']); return false; } diff --git a/lib/public/DB/QueryBuilder/IFunctionBuilder.php b/lib/public/DB/QueryBuilder/IFunctionBuilder.php index 04c5cbd07bd..d4edc8ea9f8 100644 --- a/lib/public/DB/QueryBuilder/IFunctionBuilder.php +++ b/lib/public/DB/QueryBuilder/IFunctionBuilder.php @@ -124,6 +124,24 @@ interface IFunctionBuilder { public function count($count = '', $alias = ''): IQueryFunction; /** + * @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured + * @param string $alias Alias for the length + * + * @return IQueryFunction + * @since 24.0.0 + */ + public function octetLength($field, $alias = ''): IQueryFunction; + + /** + * @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured + * @param string $alias Alias for the length + * + * @return IQueryFunction + * @since 24.0.0 + */ + public function charLength($field, $alias = ''): IQueryFunction; + + /** * Takes the maximum of all rows in a column * * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead |