Просмотр исходного кода

Merge pull request #9308 from nextcloud/proper-ocp-constants

Move log constants to ILogger
tags/v14.0.0beta1
Morris Jobke 6 лет назад
Родитель
Сommit
b7e8ab97e7
Аккаунт пользователя с таким Email не найден
74 измененных файлов: 412 добавлений и 298 удалений
  1. 2
    2
      apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php
  2. 1
    1
      apps/encryption/lib/KeyManager.php
  3. 2
    1
      apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
  4. 1
    1
      apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
  5. 1
    1
      apps/federatedfilesharing/lib/FederatedShareProvider.php
  6. 2
    2
      apps/federation/lib/BackgroundJob/GetSharedSecret.php
  7. 1
    1
      apps/federation/lib/Middleware/AddServerMiddleware.php
  8. 1
    1
      apps/federation/lib/SyncJob.php
  9. 1
    1
      apps/federation/lib/TrustedServers.php
  10. 2
    1
      apps/files_external/lib/Lib/Storage/SMB.php
  11. 10
    9
      apps/files_external/lib/Lib/Storage/Swift.php
  12. 2
    1
      apps/files_external/lib/Service/LegacyStoragesService.php
  13. 4
    3
      apps/files_external/lib/Service/StoragesService.php
  14. 4
    1
      apps/files_trashbin/ajax/delete.php
  15. 4
    1
      apps/files_trashbin/ajax/undelete.php
  16. 1
    1
      apps/files_trashbin/lib/Storage.php
  17. 4
    4
      apps/provisioning_api/lib/Controller/UsersController.php
  18. 1
    1
      apps/provisioning_api/tests/Controller/UsersControllerTest.php
  19. 2
    2
      apps/sharebymail/lib/ShareByMailProvider.php
  20. 30
    25
      apps/user_ldap/lib/Access.php
  21. 45
    33
      apps/user_ldap/lib/Connection.php
  22. 7
    6
      apps/user_ldap/lib/Group_LDAP.php
  23. 14
    13
      apps/user_ldap/lib/Jobs/UpdateGroups.php
  24. 10
    9
      apps/user_ldap/lib/User/User.php
  25. 6
    5
      apps/user_ldap/lib/User_LDAP.php
  26. 9
    8
      apps/user_ldap/lib/Wizard.php
  27. 2
    1
      core/Controller/SetupController.php
  28. 3
    1
      core/ajax/update.php
  29. 2
    1
      lib/autoloader.php
  30. 2
    1
      lib/base.php
  31. 1
    1
      lib/private/App/AppStore/Fetcher/AppFetcher.php
  32. 2
    2
      lib/private/App/AppStore/Fetcher/Fetcher.php
  33. 6
    5
      lib/private/AppFramework/DependencyInjection/DIContainer.php
  34. 1
    1
      lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
  35. 2
    1
      lib/private/Archive/ZIP.php
  36. 2
    1
      lib/private/Cache/File.php
  37. 1
    1
      lib/private/CapabilitiesManager.php
  38. 3
    2
      lib/private/DateTimeZone.php
  39. 3
    2
      lib/private/Files/Cache/Scanner.php
  40. 3
    2
      lib/private/Files/Filesystem.php
  41. 3
    2
      lib/private/Files/Mount/MountPoint.php
  42. 3
    2
      lib/private/Files/Mount/ObjectHomeMountProvider.php
  43. 2
    1
      lib/private/Files/ObjectStore/S3ConnectionTrait.php
  44. 2
    1
      lib/private/Files/Storage/Common.php
  45. 2
    1
      lib/private/Files/Storage/DAV.php
  46. 5
    4
      lib/private/Files/Storage/Local.php
  47. 1
    1
      lib/private/Files/Storage/Wrapper/Encryption.php
  48. 5
    4
      lib/private/Files/View.php
  49. 2
    2
      lib/private/Installer.php
  50. 12
    12
      lib/private/Log.php
  51. 3
    1
      lib/private/Log/File.php
  52. 2
    1
      lib/private/Log/Rotate.php
  53. 7
    5
      lib/private/Log/Syslog.php
  54. 3
    1
      lib/private/NaturalSort.php
  55. 2
    1
      lib/private/Preview/Bitmap.php
  56. 3
    1
      lib/private/Preview/Office.php
  57. 3
    1
      lib/private/Preview/SVG.php
  58. 4
    4
      lib/private/Settings/Manager.php
  59. 5
    4
      lib/private/Setup/MySQL.php
  60. 33
    32
      lib/private/Share/Share.php
  61. 36
    35
      lib/private/Tags.php
  62. 2
    2
      lib/private/Updater.php
  63. 2
    1
      lib/private/User/Database.php
  64. 7
    6
      lib/private/legacy/app.php
  65. 3
    1
      lib/private/legacy/db.php
  66. 2
    1
      lib/private/legacy/files.php
  67. 6
    4
      lib/private/legacy/user.php
  68. 5
    4
      lib/private/legacy/util.php
  69. 21
    0
      lib/public/ILogger.php
  70. 16
    2
      lib/public/Util.php
  71. 1
    1
      settings/Controller/UsersController.php
  72. 4
    1
      settings/ajax/enableapp.php
  73. 3
    2
      tests/lib/Log/FileTest.php
  74. 2
    1
      tests/lib/LoggerTest.php

+ 2
- 2
apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php Просмотреть файл

*/ */
public function logException(\Exception $ex) { public function logException(\Exception $ex) {
$exceptionClass = get_class($ex); $exceptionClass = get_class($ex);
$level = \OCP\Util::FATAL;
$level = ILogger::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass]) || if (isset($this->nonFatalExceptions[$exceptionClass]) ||
( (
$exceptionClass === ServiceUnavailable::class && $exceptionClass === ServiceUnavailable::class &&
$ex->getMessage() === 'System in maintenance mode.' $ex->getMessage() === 'System in maintenance mode.'
) )
) { ) {
$level = \OCP\Util::DEBUG;
$level = ILogger::DEBUG;
} }


$this->logger->logException($ex, [ $this->logger->logException($ex, [

+ 1
- 1
apps/encryption/lib/KeyManager.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
$this->log->logException($e, [ $this->log->logException($e, [
'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.', 'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.',
'level' => \OCP\Util::WARN,
'level' => ILogger::WARN,
'app' => 'encryption', 'app' => 'encryption',
]); ]);
return false; return false;

+ 2
- 1
apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php Просмотреть файл

use OCP\Files\StorageInvalidException; use OCP\Files\StorageInvalidException;
use OCP\Http\Client\IClientService; use OCP\Http\Client\IClientService;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
use OCP\ISession; use OCP\ISession;
use OCP\IUserSession; use OCP\IUserSession;
$this->federatedShareProvider->create($share); $this->federatedShareProvider->create($share);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::WARN,
'level' => ILogger::WARN,
'app' => 'federatedfilesharing', 'app' => 'federatedfilesharing',
]); ]);
return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);

+ 1
- 1
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Server can not add remote share.', 'message' => 'Server can not add remote share.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_sharing' 'app' => 'files_sharing'
]); ]);
throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);

+ 1
- 1
apps/federatedfilesharing/lib/FederatedShareProvider.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Failed to notify remote server of federated share, removing share.', 'message' => 'Failed to notify remote server of federated share, removing share.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'federatedfilesharing', 'app' => 'federatedfilesharing',
]); ]);
$failure = true; $failure = true;

+ 2
- 2
apps/federation/lib/BackgroundJob/GetSharedSecret.php Просмотреть файл

$status = -1; // There is no status code if we could not connect $status = -1; // There is no status code if we could not connect
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Could not connect to ' . $target, 'message' => 'Could not connect to ' . $target,
'level' => \OCP\Util::INFO,
'level' => ILogger::INFO,
'app' => 'federation', 'app' => 'federation',
]); ]);
} catch (RingException $e) { } catch (RingException $e) {
$status = -1; // There is no status code if we could not connect $status = -1; // There is no status code if we could not connect
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Could not connect to ' . $target, 'message' => 'Could not connect to ' . $target,
'level' => \OCP\Util::INFO,
'level' => ILogger::INFO,
'app' => 'federation', 'app' => 'federation',
]); ]);
} catch (\Exception $e) { } catch (\Exception $e) {

+ 1
- 1
apps/federation/lib/Middleware/AddServerMiddleware.php Просмотреть файл

throw $exception; throw $exception;
} }
$this->logger->logException($exception, [ $this->logger->logException($exception, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => $this->appName, 'app' => $this->appName,
]); ]);
if ($exception instanceof HintException) { if ($exception instanceof HintException) {

+ 1
- 1
apps/federation/lib/SyncJob.php Просмотреть файл

if ($ex instanceof \Exception) { if ($ex instanceof \Exception) {
$this->logger->logException($ex, [ $this->logger->logException($ex, [
'message' => "Error while syncing $url.", 'message' => "Error while syncing $url.",
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'fed-sync', 'app' => 'fed-sync',
]); ]);
} }

+ 1
- 1
apps/federation/lib/TrustedServers.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'No Nextcloud server.', 'message' => 'No Nextcloud server.',
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'federation', 'app' => 'federation',
]); ]);
return false; return false;

+ 2
- 1
apps/files_external/lib/Lib/Storage/SMB.php Просмотреть файл

use OCP\Files\Notify\IRenameChange; use OCP\Files\Notify\IRenameChange;
use OCP\Files\Storage\INotifyStorage; use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageNotAvailableException; use OCP\Files\StorageNotAvailableException;
use OCP\ILogger;
use OCP\Util; use OCP\Util;


class SMB extends Common implements INotifyStorage { class SMB extends Common implements INotifyStorage {
$this->remove($target); $this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget); $result = $this->share->rename($absoluteSource, $absoluteTarget);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['level' => Util::WARN]);
\OC::$server->getLogger()->logException($e, ['level' => ILogger::WARN]);
return false; return false;
} }
unset($this->statCache[$absoluteSource], $this->statCache[$absoluteTarget]); unset($this->statCache[$absoluteSource], $this->statCache[$absoluteTarget]);

+ 10
- 9
apps/files_external/lib/Lib/Storage/Swift.php Просмотреть файл

use Icewind\Streams\IteratorDirectory; use Icewind\Streams\IteratorDirectory;
use OC\Files\ObjectStore\SwiftFactory; use OC\Files\ObjectStore\SwiftFactory;
use OCP\Files\StorageBadConfigException; use OCP\Files\StorageBadConfigException;
use OCP\ILogger;
use OpenStack\Common\Error\BadResponseError; use OpenStack\Common\Error\BadResponseError;
use OpenStack\ObjectStore\v1\Models\StorageObject; use OpenStack\ObjectStore\v1\Models\StorageObject;


// Expected response is "404 Not Found", so only log if it isn't // Expected response is "404 Not Found", so only log if it isn't
if ($e->getResponse()->getStatusCode() !== 404) { if ($e->getResponse()->getStatusCode() !== 404) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
} }
$this->objectCache->remove($path); $this->objectCache->remove($path);
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
$this->objectCache->remove($path . '/'); $this->objectCache->remove($path . '/');
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
return IteratorDirectory::wrap($files); return IteratorDirectory::wrap($files);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
} }
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
if ($e->getResponse()->getStatusCode() !== 404) { if ($e->getResponse()->getStatusCode() !== 404) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
throw $e; throw $e;
return $this->objectStore->readObject($path); return $this->objectStore->readObject($path);
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
$this->objectCache->remove($path2 . '/'); $this->objectCache->remove($path2 . '/');
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;
$this->objectCache->remove($path2 . '/'); $this->objectCache->remove($path2 . '/');
} catch (BadResponseError $e) { } catch (BadResponseError $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return false; return false;

+ 2
- 1
apps/files_external/lib/Service/LegacyStoragesService.php Просмотреть файл

namespace OCA\Files_External\Service; namespace OCA\Files_External\Service;


use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Lib\StorageConfig;
use OCP\ILogger;


/** /**
* Read mount config from legacy mount.json * Read mount config from legacy mount.json
// don't die if a storage backend doesn't exist // don't die if a storage backend doesn't exist
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Could not load storage.', 'message' => 'Could not load storage.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
} }

+ 4
- 3
apps/files_external/lib/Service/StoragesService.php Просмотреть файл

use \OCA\Files_External\Lib\Auth\AuthMechanism; use \OCA\Files_External\Lib\Auth\AuthMechanism;
use OCP\Files\Config\IUserMountCache; use OCP\Files\Config\IUserMountCache;
use \OCP\Files\StorageNotAvailableException; use \OCP\Files\StorageNotAvailableException;
use OCP\ILogger;


/** /**
* Service class to manage external storages * Service class to manage external storages
// don't die if a storage backend doesn't exist // don't die if a storage backend doesn't exist
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Could not load storage.', 'message' => 'Could not load storage.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return null; return null;
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Could not load storage.', 'message' => 'Could not load storage.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
return null; return null;
// be instantiated or whenever $user vars where used, in which case // be instantiated or whenever $user vars where used, in which case
// the storage id could not be computed // the storage id could not be computed
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_external', 'app' => 'files_external',
]); ]);
} }

+ 4
- 1
apps/files_trashbin/ajax/delete.php Просмотреть файл

* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */

use OCP\ILogger;

\OC_JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
\OC_JSON::callCheck(); \OC_JSON::callCheck();
\OC::$server->getSession()->close(); \OC::$server->getSession()->close();
OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp); OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp);
if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) {
$error[] = $filename; $error[] = $filename;
\OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', \OCP\Util::ERROR);
\OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', ILogger::ERROR);
} }
// only list deleted files if not deleting everything // only list deleted files if not deleting everything
else if (!$deleteAll) { else if (!$deleteAll) {

+ 4
- 1
apps/files_trashbin/ajax/undelete.php Просмотреть файл

* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */

use OCP\ILogger;

\OC_JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
\OC_JSON::callCheck(); \OC_JSON::callCheck();
\OC::$server->getSession()->close(); \OC::$server->getSession()->close();


if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) { if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) {
$error[] = $filename; $error[] = $filename;
\OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, \OCP\Util::ERROR);
\OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, ILogger::ERROR);
} else { } else {
$success[$i]['filename'] = $file; $success[$i]['filename'] = $file;
$success[$i]['timestamp'] = $timestamp; $success[$i]['timestamp'] = $timestamp;

+ 1
- 1
apps/files_trashbin/lib/Storage.php Просмотреть файл

// do nothing, in this case we just disable the trashbin and continue // do nothing, in this case we just disable the trashbin and continue
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Trashbin storage could not check if a file was moved out of a shared folder.', 'message' => 'Trashbin storage could not check if a file was moved out of a shared folder.',
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'files_trashbin', 'app' => 'files_trashbin',
]); ]);
} }

+ 4
- 4
apps/provisioning_api/lib/Controller/UsersController.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => "Can't send new user mail to $email", 'message' => "Can't send new user mail to $email",
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'ocs_api', 'app' => 'ocs_api',
]); ]);
throw new OCSException('Unable to send the invitation mail', 109); throw new OCSException('Unable to send the invitation mail', 109);
} catch (HintException $e ) { } catch (HintException $e ) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Failed addUser attempt with hint exception.', 'message' => 'Failed addUser attempt with hint exception.',
'level' => \OCP\Util::WARN,
'level' => ILogger::WARN,
'app' => 'ocs_api', 'app' => 'ocs_api',
]); ]);
throw new OCSException($e->getHint(), 107); throw new OCSException($e->getHint(), 107);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Failed addUser attempt with exception.', 'message' => 'Failed addUser attempt with exception.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'ocs_api', 'app' => 'ocs_api',
]); ]);
throw new OCSException('Bad request', 101); throw new OCSException('Bad request', 101);
} catch(\Exception $e) { } catch(\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => "Can't send new user mail to $email", 'message' => "Can't send new user mail to $email",
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'settings', 'app' => 'settings',
]); ]);
throw new OCSException('Sending email failed', 102); throw new OCSException('Sending email failed', 102);

+ 1
- 1
apps/provisioning_api/tests/Controller/UsersControllerTest.php Просмотреть файл

->method('logException') ->method('logException')
->with($exception, [ ->with($exception, [
'message' => 'Failed addUser attempt with exception.', 'message' => 'Failed addUser attempt with exception.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'ocs_api', 'app' => 'ocs_api',
]); ]);
$loggedInUser = $this->getMockBuilder(IUser::class) $loggedInUser = $this->getMockBuilder(IUser::class)

+ 2
- 2
apps/sharebymail/lib/ShareByMailProvider.php Просмотреть файл

} catch (HintException $hintException) { } catch (HintException $hintException) {
$this->logger->logException($hintException, [ $this->logger->logException($hintException, [
'message' => 'Failed to send share by mail.', 'message' => 'Failed to send share by mail.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'sharebymail', 'app' => 'sharebymail',
]); ]);
$this->removeShareFromTable($shareId); $this->removeShareFromTable($shareId);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Failed to send share by mail.', 'message' => 'Failed to send share by mail.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'sharebymail', 'app' => 'sharebymail',
]); ]);
$this->removeShareFromTable($shareId); $this->removeShareFromTable($shareId);

+ 30
- 25
apps/user_ldap/lib/Access.php Просмотреть файл

use OCA\User_LDAP\Mapping\AbstractMapping; use OCA\User_LDAP\Mapping\AbstractMapping;
use OC\ServerNotAvailableException; use OC\ServerNotAvailableException;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Util; use OCP\Util;


if(!$this->checkConnection()) { if(!$this->checkConnection()) {
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'No LDAP Connector assigned, access impossible for readAttribute.', 'No LDAP Connector assigned, access impossible for readAttribute.',
\OCP\Util::WARN);
ILogger::WARN);
return false; return false;
} }
$cr = $this->connection->getConnectionResource(); $cr = $this->connection->getConnectionResource();
if(!$this->ldap->isResource($cr)) { if(!$this->ldap->isResource($cr)) {
//LDAP not available //LDAP not available
\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG);
return false; return false;
} }
//Cancel possibly running Paged Results operation, otherwise we run in //Cancel possibly running Paged Results operation, otherwise we run in
} }
} while($isRangeRequest); } while($isRangeRequest);


\OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, ILogger::DEBUG);
return false; return false;
} }


if (!$this->ldap->isResource($rr)) { if (!$this->ldap->isResource($rr)) {
if ($attribute !== '') { if ($attribute !== '') {
//do not throw this message on userExists check, irritates //do not throw this message on userExists check, irritates
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, ILogger::DEBUG);
} }
//in case an error occurs , e.g. object does not exist //in case an error occurs , e.g. object does not exist
return false; return false;
} }
if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) { if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) {
\OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', ILogger::DEBUG);
return true; return true;
} }
$er = $this->invokeLDAPMethod('firstEntry', $cr, $rr); $er = $this->invokeLDAPMethod('firstEntry', $cr, $rr);
$cr = $this->connection->getConnectionResource(); $cr = $this->connection->getConnectionResource();
if(!$this->ldap->isResource($cr)) { if(!$this->ldap->isResource($cr)) {
//LDAP not available //LDAP not available
\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG);
return false; return false;
} }
try { try {
} }
} else { } else {
//If the UUID can't be detected something is foul. //If the UUID can't be detected something is foul.
\OCP\Util::writeLog('user_ldap', 'Cannot determine UUID for '.$fdn.'. Skipping.', \OCP\Util::INFO);
\OCP\Util::writeLog('user_ldap', 'Cannot determine UUID for '.$fdn.'. Skipping.', ILogger::INFO);
return false; return false;
} }


if(is_null($ldapName)) { if(is_null($ldapName)) {
$ldapName = $this->readAttribute($fdn, $nameAttribute, $filter); $ldapName = $this->readAttribute($fdn, $nameAttribute, $filter);
if(!isset($ldapName[0]) && empty($ldapName[0])) { if(!isset($ldapName[0]) && empty($ldapName[0])) {
\OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', \OCP\Util::INFO);
\OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', ILogger::INFO);
return false; return false;
} }
$ldapName = $ldapName[0]; $ldapName = $ldapName[0];
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'app' => 'user_ldap', 'app' => 'user_ldap',
'level' => Util::WARN,
'level' => ILogger::WARN,
]); ]);
// we don't attempt to set a username here. We can go for // we don't attempt to set a username here. We can go for
// for an alternative 4 digit random number as we would append // for an alternative 4 digit random number as we would append
} }


//if everything else did not help.. //if everything else did not help..
\OCP\Util::writeLog('user_ldap', 'Could not create unique name for '.$fdn.'.', \OCP\Util::INFO);
\OCP\Util::writeLog('user_ldap', 'Could not create unique name for '.$fdn.'.', ILogger::INFO);
return false; return false;
} }


* Maybe implement exponential backoff? * Maybe implement exponential backoff?
* This was enough to get solr indexer working which has large delays between LDAP fetches. * This was enough to get solr indexer working which has large delays between LDAP fetches.
*/ */
\OCP\Util::writeLog('user_ldap', "Connection lost on $command, attempting to reestablish.", \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', "Connection lost on $command, attempting to reestablish.", ILogger::DEBUG);
$this->connection->resetConnectionResource(); $this->connection->resetConnectionResource();
$cr = $this->connection->getConnectionResource(); $cr = $this->connection->getConnectionResource();


if(!$this->ldap->isResource($cr)) { if(!$this->ldap->isResource($cr)) {
// Seems like we didn't find any resource. // Seems like we didn't find any resource.
\OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", ILogger::DEBUG);
throw $e; throw $e;
} }


if(!$this->ldap->isResource($cr)) { if(!$this->ldap->isResource($cr)) {
// Seems like we didn't find any resource. // Seems like we didn't find any resource.
// Return an empty array just like before. // Return an empty array just like before.
\OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', ILogger::DEBUG);
return false; return false;
} }


// cannot use $cr anymore, might have changed in the previous call! // cannot use $cr anymore, might have changed in the previous call!
$error = $this->ldap->errno($this->connection->getConnectionResource()); $error = $this->ldap->errno($this->connection->getConnectionResource());
if(!is_array($sr) || $error !== 0) { if(!is_array($sr) || $error !== 0) {
\OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), \OCP\Util::ERROR);
\OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), ILogger::ERROR);
return false; return false;
} }


* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
\OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), ILogger::DEBUG);


$limitPerPage = (int)$this->connection->ldapPagingSize; $limitPerPage = (int)$this->connection->ldapPagingSize;
if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) {
\OCP\Util::writeLog( \OCP\Util::writeLog(
'user_ldap', 'user_ldap',
'Creating advanced filter for search failed, falling back to simple method.', 'Creating advanced filter for search failed, falling back to simple method.',
\OCP\Util::INFO
ILogger::INFO
); );
} }
} }


$value = $this->readAttribute($dn, $attribute); $value = $this->readAttribute($dn, $attribute);
if(is_array($value) && isset($value[0]) && !empty($value[0])) { if(is_array($value) && isset($value[0]) && !empty($value[0])) {
\OCP\Util::writeLog('user_ldap',
'Setting '.$attribute.' as '.$uuidAttr,
\OCP\Util::DEBUG);
\OCP\Util::writeLog(
'user_ldap',
'Setting '.$attribute.' as '.$uuidAttr,
ILogger::DEBUG
);
$this->connection->$uuidAttr = $attribute; $this->connection->$uuidAttr = $attribute;
return true; return true;
} }
} }
\OCP\Util::writeLog('user_ldap',
'Could not autodetect the UUID attribute',
\OCP\Util::ERROR);
\OCP\Util::writeLog(
'user_ldap',
'Could not autodetect the UUID attribute',
ILogger::ERROR
);


return false; return false;
} }
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'initializing paged search for Filter '.$filter.' base '.print_r($bases, true) 'initializing paged search for Filter '.$filter.' base '.print_r($bases, true)
.' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset, .' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset,
\OCP\Util::DEBUG);
ILogger::DEBUG);
//get the cookie from the search for the previous search, required by LDAP //get the cookie from the search for the previous search, required by LDAP
foreach($bases as $base) { foreach($bases as $base) {


if(!$pagedSearchOK) { if(!$pagedSearchOK) {
return false; return false;
} }
\OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Ready for a paged search', ILogger::DEBUG);
} else { } else {
$e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset); $e = new \Exception('No paged search possible, Limit '.$limit.' Offset '.$offset);
\OC::$server->getLogger()->logException($e, ['level' => Util::DEBUG]);
\OC::$server->getLogger()->logException($e, ['level' => ILogger::DEBUG]);
} }


} }

+ 45
- 33
apps/user_ldap/lib/Connection.php Просмотреть файл

namespace OCA\User_LDAP; namespace OCA\User_LDAP;


use OC\ServerNotAvailableException; use OC\ServerNotAvailableException;
use OCP\ILogger;


/** /**
* magic properties (incomplete) * magic properties (incomplete)
$this->establishConnection(); $this->establishConnection();
} }
if(is_null($this->ldapConnectionRes)) { if(is_null($this->ldapConnectionRes)) {
\OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, \OCP\Util::ERROR);
\OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->configuration->ldapHost, ILogger::ERROR);
throw new ServerNotAvailableException('Connection to LDAP server could not be established'); throw new ServerNotAvailableException('Connection to LDAP server could not be established');
} }
return $this->ldapConnectionRes; return $this->ldapConnectionRes;
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'Illegal value for the '. 'Illegal value for the '.
$effectiveSetting.', '.'reset to '. $effectiveSetting.', '.'reset to '.
'autodetect.', \OCP\Util::INFO);
'autodetect.', ILogger::INFO);
} }


} }
if((stripos($this->configuration->ldapHost, 'ldaps://') === 0) if((stripos($this->configuration->ldapHost, 'ldaps://') === 0)
&& $this->configuration->ldapTLS) { && $this->configuration->ldapTLS) {
$this->configuration->ldapTLS = false; $this->configuration->ldapTLS = false;
\OCP\Util::writeLog('user_ldap',
'LDAPS (already using secure connection) and '.
'TLS do not work together. Switched off TLS.',
\OCP\Util::INFO);
\OCP\Util::writeLog(
'user_ldap',
'LDAPS (already using secure connection) and TLS do not work together. Switched off TLS.',
ILogger::INFO
);
} }
} }


break; break;
} }
$configurationOK = false; $configurationOK = false;
\OCP\Util::writeLog('user_ldap',
$errorStr.'No '.$subj.' given!',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
$errorStr.'No '.$subj.' given!',
ILogger::WARN
);
} }
} }


($agent === '' && $pwd !== '') ($agent === '' && $pwd !== '')
|| ($agent !== '' && $pwd === '') || ($agent !== '' && $pwd === '')
) { ) {
\OCP\Util::writeLog('user_ldap',
$errorStr.'either no password is given for the '.
'user agent or a password is given, but not an '.
'LDAP agent.',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
$errorStr.'either no password is given for the user ' .
'agent or a password is given, but not an LDAP agent.',
ILogger::WARN);
$configurationOK = false; $configurationOK = false;
} }


$baseGroups = $this->configuration->ldapBaseGroups; $baseGroups = $this->configuration->ldapBaseGroups;


if(empty($base) && empty($baseUsers) && empty($baseGroups)) { if(empty($base) && empty($baseUsers) && empty($baseGroups)) {
\OCP\Util::writeLog('user_ldap',
$errorStr.'Not a single Base DN given.',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
$errorStr.'Not a single Base DN given.',
ILogger::WARN
);
$configurationOK = false; $configurationOK = false;
} }


if(mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') if(mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8')
=== false) { === false) {
\OCP\Util::writeLog('user_ldap',
$errorStr.'login filter does not contain %uid '.
'place holder.',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
$errorStr.'login filter does not contain %uid place holder.',
ILogger::WARN
);
$configurationOK = false; $configurationOK = false;
} }


return false; return false;
} }
if(!$this->ignoreValidation && !$this->configured) { if(!$this->ignoreValidation && !$this->configured) {
\OCP\Util::writeLog('user_ldap',
'Configuration is invalid, cannot connect',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
'Configuration is invalid, cannot connect',
ILogger::WARN
);
return false; return false;
} }
if(!$this->ldapConnectionRes) { if(!$this->ldapConnectionRes) {
if(!$this->ldap->areLDAPFunctionsAvailable()) { if(!$this->ldap->areLDAPFunctionsAvailable()) {
$phpLDAPinstalled = false; $phpLDAPinstalled = false;
\OCP\Util::writeLog('user_ldap',
'function ldap_connect is not available. Make '.
'sure that the PHP ldap module is installed.',
\OCP\Util::ERROR);
\OCP\Util::writeLog(
'user_ldap',
'function ldap_connect is not available. Make sure that the PHP ldap module is installed.',
ILogger::ERROR
);


return false; return false;
} }
if(putenv('LDAPTLS_REQCERT=never')) { if(putenv('LDAPTLS_REQCERT=never')) {
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'Turned off SSL certificate validation successfully.', 'Turned off SSL certificate validation successfully.',
\OCP\Util::DEBUG);
ILogger::DEBUG);
} else { } else {
\OCP\Util::writeLog('user_ldap',
'Could not turn off SSL certificate validation.',
\OCP\Util::WARN);
\OCP\Util::writeLog(
'user_ldap',
'Could not turn off SSL certificate validation.',
ILogger::WARN
);
} }
} }




\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'Bind failed: ' . $errno . ': ' . $this->ldap->error($cr), 'Bind failed: ' . $errno . ': ' . $this->ldap->error($cr),
\OCP\Util::WARN);
ILogger::WARN);


// Set to failure mode, if LDAP error code is not LDAP_SUCCESS or LDAP_INVALID_CREDENTIALS // Set to failure mode, if LDAP error code is not LDAP_SUCCESS or LDAP_INVALID_CREDENTIALS
if($errno !== 0x00 && $errno !== 0x31) { if($errno !== 0x00 && $errno !== 0x31) {

+ 7
- 6
apps/user_ldap/lib/Group_LDAP.php Просмотреть файл



use OC\Cache\CappedMemoryCache; use OC\Cache\CappedMemoryCache;
use OCP\GroupInterface; use OCP\GroupInterface;
use OCP\ILogger;


class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP { class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP {
protected $enabled = false; protected $enabled = false;
} }
} else { } else {
\OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '.
'of group ' . $dnGroup, \OCP\Util::DEBUG);
'of group ' . $dnGroup, ILogger::DEBUG);
} }
} }
return $dynamicMembers; return $dynamicMembers;
} }
} else { } else {
\OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '.
'of group ' . print_r($dynamicGroup, true), \OCP\Util::DEBUG);
'of group ' . print_r($dynamicGroup, true), ILogger::DEBUG);
} }
} }
} }
$result = $this->access->readAttribute($userDN, 'uid'); $result = $this->access->readAttribute($userDN, 'uid');
if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '. \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '.
$this->access->connection->ldapHost, \OCP\Util::DEBUG);
$this->access->connection->ldapHost, ILogger::DEBUG);
} }
$uid = $result[0]; $uid = $result[0];
} else { } else {
$cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset;


//Check cache before driving unnecessary searches //Check cache before driving unnecessary searches
\OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, ILogger::DEBUG);
$ldap_groups = $this->access->connection->getFromCache($cacheKey); $ldap_groups = $this->access->connection->getFromCache($cacheKey);
if(!is_null($ldap_groups)) { if(!is_null($ldap_groups)) {
return $ldap_groups; return $ldap_groups;
$this->access->connection->ldapGroupFilter, $this->access->connection->ldapGroupFilter,
$this->access->getFilterPartForGroupSearch($search) $this->access->getFilterPartForGroupSearch($search)
)); ));
\OCP\Util::writeLog('user_ldap', 'getGroups Filter '.$filter, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'getGroups Filter '.$filter, ILogger::DEBUG);
$ldap_groups = $this->access->fetchListOfGroups($filter, $ldap_groups = $this->access->fetchListOfGroups($filter,
array($this->access->connection->ldapGroupDisplayName, 'dn'), array($this->access->connection->ldapGroupDisplayName, 'dn'),
$limit, $limit,
$chunkLimit = min($pagingSize, $overallLimit - $chunkOffset); $chunkLimit = min($pagingSize, $overallLimit - $chunkOffset);
$ldapGroups = $this->getGroupsChunk($search, $chunkLimit, $chunkOffset); $ldapGroups = $this->getGroupsChunk($search, $chunkLimit, $chunkOffset);
$nread = count($ldapGroups); $nread = count($ldapGroups);
\OCP\Util::writeLog('user_ldap', 'getGroups('.$search.'): read '.$nread.' at offset '.$chunkOffset.' (limit: '.$chunkLimit.')', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'getGroups('.$search.'): read '.$nread.' at offset '.$chunkOffset.' (limit: '.$chunkLimit.')', ILogger::DEBUG);
if ($nread) { if ($nread) {
$allGroups = array_merge($allGroups, $ldapGroups); $allGroups = array_merge($allGroups, $ldapGroups);
$chunkOffset += $nread; $chunkOffset += $nread;

+ 14
- 13
apps/user_ldap/lib/Jobs/UpdateGroups.php Просмотреть файл

use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\User\Manager;
use OCP\ILogger;


class UpdateGroups extends \OC\BackgroundJob\TimedJob { class UpdateGroups extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB; static private $groupsFromDB;
} }


static public function updateGroups() { static public function updateGroups() {
\OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Run background job "updateGroups"', ILogger::DEBUG);


$knownGroups = array_keys(self::getKnownGroups()); $knownGroups = array_keys(self::getKnownGroups());
$actualGroups = self::getGroupBE()->getGroups(); $actualGroups = self::getGroupBE()->getGroups();
if(empty($actualGroups) && empty($knownGroups)) { if(empty($actualGroups) && empty($knownGroups)) {
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.', 'bgJ "updateGroups" – groups do not seem to be configured properly, aborting.',
\OCP\Util::INFO);
ILogger::INFO);
return; return;
} }


self::handleCreatedGroups(array_diff($actualGroups, $knownGroups)); self::handleCreatedGroups(array_diff($actualGroups, $knownGroups));
self::handleRemovedGroups(array_diff($knownGroups, $actualGroups)); self::handleRemovedGroups(array_diff($knownGroups, $actualGroups));


\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Finished.', ILogger::DEBUG);
} }


/** /**
* @param string[] $groups * @param string[] $groups
*/ */
static private function handleKnownGroups($groups) { static private function handleKnownGroups($groups) {
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', ILogger::DEBUG);
$query = \OC_DB::prepare(' $query = \OC_DB::prepare('
UPDATE `*PREFIX*ldap_group_members` UPDATE `*PREFIX*ldap_group_members`
SET `owncloudusers` = ? SET `owncloudusers` = ?
\OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group)); \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', array('uid' => $removedUser, 'gid' => $group));
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".', 'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
\OCP\Util::INFO);
ILogger::INFO);
$hasChanged = true; $hasChanged = true;
} }
foreach(array_diff($actualUsers, $knownUsers) as $addedUser) { foreach(array_diff($actualUsers, $knownUsers) as $addedUser) {
\OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group)); \OCP\Util::emitHook('OC_User', 'post_addToGroup', array('uid' => $addedUser, 'gid' => $group));
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".', 'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
\OCP\Util::INFO);
ILogger::INFO);
$hasChanged = true; $hasChanged = true;
} }
if($hasChanged) { if($hasChanged) {
} }
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – FINISHED dealing with known Groups.', 'bgJ "updateGroups" – FINISHED dealing with known Groups.',
\OCP\Util::DEBUG);
ILogger::DEBUG);
} }


/** /**
* @param string[] $createdGroups * @param string[] $createdGroups
*/ */
static private function handleCreatedGroups($createdGroups) { static private function handleCreatedGroups($createdGroups) {
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', ILogger::DEBUG);
$query = \OC_DB::prepare(' $query = \OC_DB::prepare('
INSERT INSERT
INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`) INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`)
foreach($createdGroups as $createdGroup) { foreach($createdGroups as $createdGroup) {
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – new group "'.$createdGroup.'" found.', 'bgJ "updateGroups" – new group "'.$createdGroup.'" found.',
\OCP\Util::INFO);
ILogger::INFO);
$users = serialize(self::getGroupBE()->usersInGroup($createdGroup)); $users = serialize(self::getGroupBE()->usersInGroup($createdGroup));
$query->execute(array($createdGroup, $users)); $query->execute(array($createdGroup, $users));
} }
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – FINISHED dealing with created Groups.', 'bgJ "updateGroups" – FINISHED dealing with created Groups.',
\OCP\Util::DEBUG);
ILogger::DEBUG);
} }


/** /**
* @param string[] $removedGroups * @param string[] $removedGroups
*/ */
static private function handleRemovedGroups($removedGroups) { static private function handleRemovedGroups($removedGroups) {
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', ILogger::DEBUG);
$query = \OC_DB::prepare(' $query = \OC_DB::prepare('
DELETE DELETE
FROM `*PREFIX*ldap_group_members` FROM `*PREFIX*ldap_group_members`
foreach($removedGroups as $removedGroup) { foreach($removedGroups as $removedGroup) {
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.', 'bgJ "updateGroups" – group "'.$removedGroup.'" was removed.',
\OCP\Util::INFO);
ILogger::INFO);
$query->execute(array($removedGroup)); $query->execute(array($removedGroup));
} }
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – FINISHED dealing with removed groups.', 'bgJ "updateGroups" – FINISHED dealing with removed groups.',
\OCP\Util::DEBUG);
ILogger::DEBUG);
} }


/** /**

+ 10
- 9
apps/user_ldap/lib/User/User.php Просмотреть файл

use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\LogWrapper;
use OCP\IAvatarManager; use OCP\IAvatarManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\Image; use OCP\Image;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Util; use OCP\Util;
INotificationManager $notificationManager) { INotificationManager $notificationManager) {
if ($username === null) { if ($username === null) {
$log->log("uid for '$dn' must not be null!", Util::ERROR);
$log->log("uid for '$dn' must not be null!", ILogger::ERROR);
throw new \InvalidArgumentException('uid must not be null!'); throw new \InvalidArgumentException('uid must not be null!');
} else if ($username === '') { } else if ($username === '') {
$log->log("uid for '$dn' must not be an empty string", Util::ERROR);
$log->log("uid for '$dn' must not be an empty string", ILogger::ERROR);
throw new \InvalidArgumentException('uid must not be an empty string!'); throw new \InvalidArgumentException('uid must not be an empty string!');
} }


if ($this->verifyQuotaValue($aQuota[0])) { if ($this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0]; $quota = $aQuota[0];
} else { } else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', \OCP\Util::WARN);
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::WARN);
} }
} }
} }
if ($this->verifyQuotaValue($valueFromLDAP)) { if ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP; $quota = $valueFromLDAP;
} else { } else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::WARN);
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::WARN);
} }
} }


if($quota !== false) { if($quota !== false) {
$targetUser->setQuota($quota); $targetUser->setQuota($quota);
} else { } else {
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN);
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::WARN);
} }
} else { } else {
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR);
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::ERROR);
} }
} }


*/ */
private function setOwnCloudAvatar() { private function setOwnCloudAvatar() {
if(!$this->image->valid()) { if(!$this->image->valid()) {
$this->log->log('jpegPhoto data invalid for '.$this->dn, \OCP\Util::ERROR);
$this->log->log('jpegPhoto data invalid for '.$this->dn, ILogger::ERROR);
return; return;
} }
//make sure it is a square and not bigger than 128x128 //make sure it is a square and not bigger than 128x128
$size = min(array($this->image->width(), $this->image->height(), 128)); $size = min(array($this->image->width(), $this->image->height(), 128));
if(!$this->image->centerCrop($size)) { if(!$this->image->centerCrop($size)) {
$this->log->log('croping image for avatar failed for '.$this->dn, \OCP\Util::ERROR);
$this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR);
return; return;
} }


} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Could not set avatar for ' . $this->dn, 'message' => 'Could not set avatar for ' . $this->dn,
'level' => \OCP\Util::INFO,
'level' => ILogger::INFO,
'app' => 'user_ldap', 'app' => 'user_ldap',
]); ]);
} }

+ 6
- 5
apps/user_ldap/lib/User_LDAP.php Просмотреть файл

use OCA\User_LDAP\User\OfflineUser; use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User; use OCA\User_LDAP\User\User;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\IUser; use OCP\IUser;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager; use OCP\Notification\IManager as INotificationManager;
try { try {
$ldapRecord = $this->getLDAPUserByLoginName($uid); $ldapRecord = $this->getLDAPUserByLoginName($uid);
} catch(NotOnLDAP $e) { } catch(NotOnLDAP $e) {
if($this->ocConfig->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) {
if($this->ocConfig->getSystemValue('loglevel', ILogger::WARN) === ILogger::DEBUG) {
\OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']); \OC::$server->getLogger()->logException($e, ['app' => 'user_ldap']);
} }
return false; return false;
Util::writeLog('user_ldap', Util::writeLog('user_ldap',
'LDAP Login: Could not get user object for DN ' . $dn . 'LDAP Login: Could not get user object for DN ' . $dn .
'. Maybe the LDAP entry has no set display name attribute?', '. Maybe the LDAP entry has no set display name attribute?',
Util::WARN);
ILogger::WARN);
return false; return false;
} }
if($user->getUsername() !== false) { if($user->getUsername() !== false) {


Util::writeLog('user_ldap', Util::writeLog('user_ldap',
'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter,
Util::DEBUG);
ILogger::DEBUG);
//do the search and translate results to Nextcloud names //do the search and translate results to Nextcloud names
$ldap_users = $this->access->fetchListOfUsers( $ldap_users = $this->access->fetchListOfUsers(
$filter, $filter,
$this->access->userManager->getAttributes(true), $this->access->userManager->getAttributes(true),
$limit, $offset); $limit, $offset);
$ldap_users = $this->access->nextcloudUserNames($ldap_users); $ldap_users = $this->access->nextcloudUserNames($ldap_users);
Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', Util::DEBUG);
Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', ILogger::DEBUG);


$this->access->connection->writeToCache($cachekey, $ldap_users); $this->access->connection->writeToCache($cachekey, $ldap_users);
return $ldap_users; return $ldap_users;


if(is_null($user)) { if(is_null($user)) {
Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '. Util::writeLog('user_ldap', 'No DN found for '.$uid.' on '.
$this->access->connection->ldapHost, Util::DEBUG);
$this->access->connection->ldapHost, ILogger::DEBUG);
$this->access->connection->writeToCache('userExists'.$uid, false); $this->access->connection->writeToCache('userExists'.$uid, false);
return false; return false;
} else if($user instanceof OfflineUser) { } else if($user instanceof OfflineUser) {

+ 9
- 8
apps/user_ldap/lib/Wizard.php Просмотреть файл

namespace OCA\User_LDAP; namespace OCA\User_LDAP;


use OC\ServerNotAvailableException; use OC\ServerNotAvailableException;
use OCP\ILogger;


class Wizard extends LDAPUtility { class Wizard extends LDAPUtility {
/** @var \OCP\IL10N */ /** @var \OCP\IL10N */
if($writeLog) { if($writeLog) {
\OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' .
'automatically been reset, because the original value ' . 'automatically been reset, because the original value ' .
'did not return any results.', \OCP\Util::INFO);
'did not return any results.', ILogger::INFO);
} }
} }


foreach($portSettings as $setting) { foreach($portSettings as $setting) {
$p = $setting['port']; $p = $setting['port'];
$t = $setting['tls']; $t = $setting['tls'];
\OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, ILogger::DEBUG);
//connectAndBind may throw Exception, it needs to be catched by the //connectAndBind may throw Exception, it needs to be catched by the
//callee of this method //callee of this method


'ldapTLS' => (int)$t 'ldapTLS' => (int)$t
); );
$this->configuration->setConfiguration($config); $this->configuration->setConfiguration($config);
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, ILogger::DEBUG);
$this->result->addChange('ldap_port', $p); $this->result->addChange('ldap_port', $p);
return $this->result; return $this->result;
} }
$errorNo = $this->ldap->errno($cr); $errorNo = $this->ldap->errno($cr);
$errorMsg = $this->ldap->error($cr); $errorMsg = $this->ldap->error($cr);
\OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base.
' Error '.$errorNo.': '.$errorMsg, \OCP\Util::INFO);
' Error '.$errorNo.': '.$errorMsg, ILogger::INFO);
return false; return false;
} }
$entries = $this->ldap->countEntries($cr, $rr); $entries = $this->ldap->countEntries($cr, $rr);
break; break;
} }


\OCP\Util::writeLog('user_ldap', 'Wiz: Final filter '.$filter, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: Final filter '.$filter, ILogger::DEBUG);


return $filter; return $filter;
} }
if(!$hostInfo) { if(!$hostInfo) {
throw new \Exception(self::$l->t('Invalid Host')); throw new \Exception(self::$l->t('Invalid Host'));
} }
\OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', ILogger::DEBUG);
$cr = $this->ldap->connect($host, $port); $cr = $this->ldap->connect($host, $port);
if(!is_resource($cr)) { if(!is_resource($cr)) {
throw new \Exception(self::$l->t('Invalid Host')); throw new \Exception(self::$l->t('Invalid Host'));
} }
} }


\OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: Attemping to Bind ', ILogger::DEBUG);
//interesting part: do the bind! //interesting part: do the bind!
$login = $this->ldap->bind($cr, $login = $this->ldap->bind($cr,
$this->configuration->ldapAgentName, $this->configuration->ldapAgentName,


if($login === true) { if($login === true) {
$this->ldap->unbind($cr); $this->ldap->unbind($cr);
\OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, \OCP\Util::DEBUG);
\OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, ILogger::DEBUG);
return true; return true;
} }



+ 2
- 1
core/Controller/SetupController.php Просмотреть файл

namespace OC\Core\Controller; namespace OC\Core\Controller;


use OC\Setup; use OC\Setup;
use OCP\ILogger;


class SetupController { class SetupController {
/** @var Setup */ /** @var Setup */


public function loadAutoConfig($post) { public function loadAutoConfig($post) {
if( file_exists($this->autoConfigFile)) { if( file_exists($this->autoConfigFile)) {
\OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', \OCP\Util::INFO);
\OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', ILogger::INFO);
$AUTOCONFIG = array(); $AUTOCONFIG = array();
include $this->autoConfigFile; include $this->autoConfigFile;
$post = array_merge ($post, $AUTOCONFIG); $post = array_merge ($post, $AUTOCONFIG);

+ 3
- 1
core/ajax/update.php Просмотреть файл

* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */

use OCP\ILogger;
use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\EventDispatcher\GenericEvent;


if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
$updater->upgrade(); $updater->upgrade();
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'update', 'app' => 'update',
]); ]);
$eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage());

+ 2
- 1
lib/autoloader.php Просмотреть файл

namespace OC; namespace OC;


use \OCP\AutoloadNotAllowedException; use \OCP\AutoloadNotAllowedException;
use OCP\ILogger;


class Autoloader { class Autoloader {
/** @var bool */ /** @var bool */
* Remove "apps/" from inclusion path for smooth migration to multi app dir * Remove "apps/" from inclusion path for smooth migration to multi app dir
*/ */
if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) { if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
\OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', ILogger::DEBUG);
$paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]); $paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]);
} }
} elseif (strpos($class, 'OC_') === 0) { } elseif (strpos($class, 'OC_') === 0) {

+ 2
- 1
lib/base.php Просмотреть файл

* *
*/ */


use OCP\ILogger;
use OCP\Share; use OCP\Share;
use OC\Encryption\HookManager; use OC\Encryption\HookManager;
use OC\Files\Filesystem; use OC\Files\Filesystem;
// so log the exception // so log the exception
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Exception when running cache gc.', 'message' => 'Exception when running cache gc.',
'level' => \OCP\Util::WARN,
'level' => ILogger::WARN,
'app' => 'core', 'app' => 'core',
]); ]);
} }

+ 1
- 1
lib/private/App/AppStore/Fetcher/AppFetcher.php Просмотреть файл

$releases[] = $release; $releases[] = $release;
} }
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::WARN]);
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]);
} }
} }
} }

+ 2
- 2
lib/private/App/AppStore/Fetcher/Fetcher.php Просмотреть файл

$file->putContent(json_encode($responseJson)); $file->putContent(json_encode($responseJson));
return json_decode($file->getContent(), true)['data']; return json_decode($file->getContent(), true)['data'];
} catch (ConnectException $e) { } catch (ConnectException $e) {
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::INFO, 'message' => 'Could not connect to appstore']);
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO, 'message' => 'Could not connect to appstore']);
return []; return [];
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::INFO]);
$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO]);
return []; return [];
} }
} }

+ 6
- 5
lib/private/AppFramework/DependencyInjection/DIContainer.php Просмотреть файл

use OCP\Files\IAppData; use OCP\Files\IAppData;
use OCP\GlobalScale\IConfig; use OCP\GlobalScale\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
use OCP\IServerContainer; use OCP\IServerContainer;
use OCP\IUserSession; use OCP\IUserSession;
public function log($message, $level) { public function log($message, $level) {
switch($level){ switch($level){
case 'debug': case 'debug':
$level = \OCP\Util::DEBUG;
$level = ILogger::DEBUG;
break; break;
case 'info': case 'info':
$level = \OCP\Util::INFO;
$level = ILogger::INFO;
break; break;
case 'warn': case 'warn':
$level = \OCP\Util::WARN;
$level = ILogger::WARN;
break; break;
case 'fatal': case 'fatal':
$level = \OCP\Util::FATAL;
$level = ILogger::FATAL;
break; break;
default: default:
$level = \OCP\Util::ERROR;
$level = ILogger::ERROR;
break; break;
} }
\OCP\Util::writeLog($this->getAppName(), $message, $level); \OCP\Util::writeLog($this->getAppName(), $message, $level);

+ 1
- 1
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php Просмотреть файл

} }


$this->logger->logException($exception, [ $this->logger->logException($exception, [
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'core', 'app' => 'core',
]); ]);
return $response; return $response;

+ 2
- 1
lib/private/Archive/ZIP.php Просмотреть файл

namespace OC\Archive; namespace OC\Archive;


use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
use OCP\ILogger;


class ZIP extends Archive{ class ZIP extends Archive{
/** /**
$this->zip=new \ZipArchive(); $this->zip=new \ZipArchive();
if($this->zip->open($source, \ZipArchive::CREATE)) { if($this->zip->open($source, \ZipArchive::CREATE)) {
}else{ }else{
\OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, \OCP\Util::WARN);
\OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN);
} }
} }
/** /**

+ 2
- 1
lib/private/Cache/File.php Просмотреть файл

use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC\Files\View; use OC\Files\View;
use OCP\ICache; use OCP\ICache;
use OCP\ILogger;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;


class File implements ICache { class File implements ICache {
$this->storage = new View('/' . $user->getUID() . '/cache'); $this->storage = new View('/' . $user->getUID() . '/cache');
return $this->storage; return $this->storage;
} else { } else {
\OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', ILogger::ERROR);
throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in'); throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
} }
} }

+ 1
- 1
lib/private/CapabilitiesManager.php Просмотреть файл

} catch (QueryException $e) { } catch (QueryException $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'CapabilitiesManager', 'message' => 'CapabilitiesManager',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
continue; continue;

+ 3
- 2
lib/private/DateTimeZone.php Просмотреть файл



use OCP\IConfig; use OCP\IConfig;
use OCP\IDateTimeZone; use OCP\IDateTimeZone;
use OCP\ILogger;
use OCP\ISession; use OCP\ISession;


class DateTimeZone implements IDateTimeZone { class DateTimeZone implements IDateTimeZone {
try { try {
return new \DateTimeZone($timeZone); return new \DateTimeZone($timeZone);
} catch (\Exception $e) { } catch (\Exception $e) {
\OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG);
\OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", ILogger::DEBUG);
return new \DateTimeZone($this->getDefaultTimeZone()); return new \DateTimeZone($this->getDefaultTimeZone());
} }
} }
} }


// No timezone found, fallback to UTC // No timezone found, fallback to UTC
\OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", \OCP\Util::DEBUG);
\OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", ILogger::DEBUG);
return new \DateTimeZone($this->getDefaultTimeZone()); return new \DateTimeZone($this->getDefaultTimeZone());
} }
} }

+ 3
- 2
lib/private/Files/Cache/Scanner.php Просмотреть файл

use OC\Hooks\BasicEmitter; use OC\Hooks\BasicEmitter;
use OCP\Files\Cache\IScanner; use OCP\Files\Cache\IScanner;
use OCP\Files\ForbiddenException; use OCP\Files\ForbiddenException;
use OCP\ILogger;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;


/** /**
protected function getData($path) { protected function getData($path) {
$data = $this->storage->getMetaData($path); $data = $this->storage->getMetaData($path);
if (is_null($data)) { if (is_null($data)) {
\OCP\Util::writeLog(Scanner::class, "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG);
\OCP\Util::writeLog(Scanner::class, "!!! Path '$path' is not accessible or present !!!", ILogger::DEBUG);
} }
return $data; return $data;
} }
} }
\OC::$server->getLogger()->logException($ex, [ \OC::$server->getLogger()->logException($ex, [
'message' => 'Exception while scanning file "' . $child . '"', 'message' => 'Exception while scanning file "' . $child . '"',
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'core', 'app' => 'core',
]); ]);
$exceptionOccurred = true; $exceptionOccurred = true;

+ 3
- 2
lib/private/Files/Filesystem.php Просмотреть файл

use OC\Lockdown\Filesystem\NullStorage; use OC\Lockdown\Filesystem\NullStorage;
use OCP\Files\Config\IMountProvider; use OCP\Files\Config\IMountProvider;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\ILogger;
use OCP\IUserManager; use OCP\IUserManager;


class Filesystem { class Filesystem {
$userObject = $userManager->get($user); $userObject = $userManager->get($user);


if (is_null($userObject)) { if (is_null($userObject)) {
\OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, \OCP\Util::ERROR);
\OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR);
// reset flag, this will make it possible to rethrow the exception if called again // reset flag, this will make it possible to rethrow the exception if called again
unset(self::$usersSetup[$user]); unset(self::$usersSetup[$user]);
throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); throw new \OC\User\NoUserException('Backends provided no user object for ' . $user);
// workaround in case of different casings // workaround in case of different casings
if ($user !== $realUid) { if ($user !== $realUid) {
$stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50)); $stack = json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 50));
\OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, \OCP\Util::WARN);
\OCP\Util::writeLog('files', 'initMountPoints() called with wrong user casing. This could be a bug. Expected: "' . $realUid . '" got "' . $user . '". Stack: ' . $stack, ILogger::WARN);
$user = $realUid; $user = $realUid;


// again with the correct casing // again with the correct casing

+ 3
- 2
lib/private/Files/Mount/MountPoint.php Просмотреть файл

use OC\Files\Storage\StorageFactory; use OC\Files\Storage\StorageFactory;
use OC\Files\Storage\Storage; use OC\Files\Storage\Storage;
use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\ILogger;


class MountPoint implements IMountPoint { class MountPoint implements IMountPoint {
/** /**
// the root storage could not be initialized, show the user! // the root storage could not be initialized, show the user!
throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception); throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception);
} else { } else {
\OC::$server->getLogger()->logException($exception, ['level' => \OCP\Util::ERROR]);
\OC::$server->getLogger()->logException($exception, ['level' => ILogger::ERROR]);
} }
return; return;
} }
} else { } else {
\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR);
$this->invalidStorage = true; $this->invalidStorage = true;
return; return;
} }

+ 3
- 2
lib/private/Files/Mount/ObjectHomeMountProvider.php Просмотреть файл

use OCP\Files\Config\IHomeMountProvider; use OCP\Files\Config\IHomeMountProvider;
use OCP\Files\Storage\IStorageFactory; use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\IUser; use OCP\IUser;


/** /**


// sanity checks // sanity checks
if (empty($config['class'])) { if (empty($config['class'])) {
\OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
} }
if (!isset($config['arguments'])) { if (!isset($config['arguments'])) {
$config['arguments'] = []; $config['arguments'] = [];


// sanity checks // sanity checks
if (empty($config['class'])) { if (empty($config['class'])) {
\OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
} }
if (!isset($config['arguments'])) { if (!isset($config['arguments'])) {
$config['arguments'] = []; $config['arguments'] = [];

+ 2
- 1
lib/private/Files/ObjectStore/S3ConnectionTrait.php Просмотреть файл

use Aws\ClientResolver; use Aws\ClientResolver;
use Aws\S3\Exception\S3Exception; use Aws\S3\Exception\S3Exception;
use Aws\S3\S3Client; use Aws\S3\S3Client;
use OCP\ILogger;


trait S3ConnectionTrait { trait S3ConnectionTrait {
/** @var array */ /** @var array */
} catch (S3Exception $e) { } catch (S3Exception $e) {
$logger->logException($e, [ $logger->logException($e, [
'message' => 'Invalid remote storage.', 'message' => 'Invalid remote storage.',
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'objectstore', 'app' => 'objectstore',
]); ]);
throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());

+ 2
- 1
lib/private/Files/Storage/Common.php Просмотреть файл

use OCP\Files\ReservedWordException; use OCP\Files\ReservedWordException;
use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorage;
use OCP\ILogger;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException; use OCP\Lock\LockedException;


return false; return false;
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->info("External storage not available: " . $e->getMessage()); \OC::$server->getLogger()->info("External storage not available: " . $e->getMessage());
\OC::$server->getLogger()->logException($e, ['level' => \OCP\Util::DEBUG]);
\OC::$server->getLogger()->logException($e, ['level' => ILogger::DEBUG]);
return false; return false;
} }
} }

+ 2
- 1
lib/private/Files/Storage/DAV.php Просмотреть файл



use Exception; use Exception;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use OCP\ILogger;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
use OC\Files\Filesystem; use OC\Files\Filesystem;
if ($response->getStatusCode() === Http::STATUS_LOCKED) { if ($response->getStatusCode() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path); throw new \OCP\Lock\LockedException($path);
} else { } else {
Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), Util::ERROR);
Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR);
} }
} }



+ 5
- 4
lib/private/Files/Storage/Local.php Просмотреть файл

use OC\Files\Storage\Wrapper\Jail; use OC\Files\Storage\Wrapper\Jail;
use OCP\Files\ForbiddenException; use OCP\Files\ForbiddenException;
use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorage;
use OCP\ILogger;


/** /**
* for local filestore, we only have to map the paths * for local filestore, we only have to map the paths
$dstParent = dirname($path2); $dstParent = dirname($path2);


if (!$this->isUpdatable($srcParent)) { if (!$this->isUpdatable($srcParent)) {
\OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, ILogger::ERROR);
return false; return false;
} }


if (!$this->isUpdatable($dstParent)) { if (!$this->isUpdatable($dstParent)) {
\OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, ILogger::ERROR);
return false; return false;
} }


if (!$this->file_exists($path1)) { if (!$this->file_exists($path1)) {
\OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, ILogger::ERROR);
return false; return false;
} }


return $fullPath; return $fullPath;
} }


\OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", \OCP\Util::ERROR);
\OCP\Util::writeLog('core', "Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", ILogger::ERROR);
throw new ForbiddenException('Following symlinks is not allowed', false); throw new ForbiddenException('Following symlinks is not allowed', false);
} }



+ 1
- 1
lib/private/Files/Storage/Wrapper/Encryption.php Просмотреть файл

} catch (ModuleDoesNotExistsException $e) { } catch (ModuleDoesNotExistsException $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted',
'level' => \OCP\Util::WARN,
'level' => ILogger::WARN,
'app' => 'core', 'app' => 'core',
]); ]);
} }

+ 5
- 4
lib/private/Files/View.php Просмотреть файл

use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\Files\ReservedWordException; use OCP\Files\ReservedWordException;
use OCP\ILogger;
use OCP\IUser; use OCP\IUser;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException; use OCP\Lock\LockedException;
$hooks[] = 'write'; $hooks[] = 'write';
break; break;
default: default:
\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, ILogger::ERROR);
} }


if ($mode !== 'r' && $mode !== 'w') { if ($mode !== 'r' && $mode !== 'w') {
// sometimes when the storage is not available it can be any exception // sometimes when the storage is not available it can be any exception
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"', 'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'lib', 'app' => 'lib',
]); ]);
continue; continue;
if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) { if (!$targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
\OCP\Util::writeLog('files', \OCP\Util::writeLog('files',
'It is not allowed to move one mount point into another one', 'It is not allowed to move one mount point into another one',
\OCP\Util::DEBUG);
ILogger::DEBUG);
return false; return false;
} }


if (count($shares) > 0) { if (count($shares) > 0) {
\OCP\Util::writeLog('files', \OCP\Util::writeLog('files',
'It is not allowed to move one mount point into a shared folder', 'It is not allowed to move one mount point into a shared folder',
\OCP\Util::DEBUG);
ILogger::DEBUG);
return false; return false;
} }



+ 2
- 2
lib/private/Installer.php Просмотреть файл

$this->downloadApp($appId); $this->downloadApp($appId);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
OC_Helper::rmdirr($appDir); OC_Helper::rmdirr($appDir);
return true; return true;
}else{ }else{
\OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', ILogger::ERROR);


return false; return false;
} }

+ 12
- 12
lib/private/Log.php Просмотреть файл

* @return void * @return void
*/ */
public function emergency(string $message, array $context = []) { public function emergency(string $message, array $context = []) {
$this->log(Util::FATAL, $message, $context);
$this->log(ILogger::FATAL, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function alert(string $message, array $context = []) { public function alert(string $message, array $context = []) {
$this->log(Util::ERROR, $message, $context);
$this->log(ILogger::ERROR, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function critical(string $message, array $context = []) { public function critical(string $message, array $context = []) {
$this->log(Util::ERROR, $message, $context);
$this->log(ILogger::ERROR, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function error(string $message, array $context = []) { public function error(string $message, array $context = []) {
$this->log(Util::ERROR, $message, $context);
$this->log(ILogger::ERROR, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function warning(string $message, array $context = []) { public function warning(string $message, array $context = []) {
$this->log(Util::WARN, $message, $context);
$this->log(ILogger::WARN, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function notice(string $message, array $context = []) { public function notice(string $message, array $context = []) {
$this->log(Util::INFO, $message, $context);
$this->log(ILogger::INFO, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function info(string $message, array $context = []) { public function info(string $message, array $context = []) {
$this->log(Util::INFO, $message, $context);
$this->log(ILogger::INFO, $message, $context);
} }


/** /**
* @return void * @return void
*/ */
public function debug(string $message, array $context = []) { public function debug(string $message, array $context = []) {
$this->log(Util::DEBUG, $message, $context);
$this->log(ILogger::DEBUG, $message, $context);
} }






// if log condition is satisfied change the required log level to DEBUG // if log condition is satisfied change the required log level to DEBUG
if ($this->logConditionSatisfied) { if ($this->logConditionSatisfied) {
return Util::DEBUG;
return ILogger::DEBUG;
} }


if (isset($context['app'])) { if (isset($context['app'])) {
if (!empty($logCondition) if (!empty($logCondition)
&& isset($logCondition['apps']) && isset($logCondition['apps'])
&& in_array($app, $logCondition['apps'], true)) { && in_array($app, $logCondition['apps'], true)) {
return Util::DEBUG;
return ILogger::DEBUG;
} }
} }


return min($this->config->getValue('loglevel', Util::WARN), Util::FATAL);
return min($this->config->getValue('loglevel', ILogger::WARN), ILogger::FATAL);
} }


/** /**
*/ */
public function logException(\Throwable $exception, array $context = []) { public function logException(\Throwable $exception, array $context = []) {
$app = $context['app'] ?? 'no app in context'; $app = $context['app'] ?? 'no app in context';
$level = $context['level'] ?? Util::ERROR;
$level = $context['level'] ?? ILogger::ERROR;


$serializer = new ExceptionSerializer(); $serializer = new ExceptionSerializer();
$data = $serializer->serializeException($exception); $data = $serializer->serializeException($exception);

+ 3
- 1
lib/private/Log/File.php Просмотреть файл



namespace OC\Log; namespace OC\Log;


use OCP\ILogger;

/** /**
* logging utilities * logging utilities
* *
*/ */
public static function getEntries($limit=50, $offset=0) { public static function getEntries($limit=50, $offset=0) {
self::init(); self::init();
$minLevel = \OC::$server->getSystemConfig()->getValue("loglevel", \OCP\Util::WARN);
$minLevel = \OC::$server->getSystemConfig()->getValue("loglevel", ILogger::WARN);
$entries = array(); $entries = array();
$handle = @fopen(self::$logFile, 'rb'); $handle = @fopen(self::$logFile, 'rb');
if ($handle) { if ($handle) {

+ 2
- 1
lib/private/Log/Rotate.php Просмотреть файл

*/ */


namespace OC\Log; namespace OC\Log;
use OCP\ILogger;


/** /**
* This rotates the current logfile to a new name, this way the total log usage * This rotates the current logfile to a new name, this way the total log usage
$rotatedLogfile = $logfile.'.1'; $rotatedLogfile = $logfile.'.1';
rename($logfile, $rotatedLogfile); rename($logfile, $rotatedLogfile);
$msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"'; $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
\OCP\Util::writeLog(Rotate::class, $msg, \OCP\Util::WARN);
\OCP\Util::writeLog(Rotate::class, $msg, ILogger::WARN);
} }
} }

+ 7
- 5
lib/private/Log/Syslog.php Просмотреть файл



namespace OC\Log; namespace OC\Log;


use OCP\ILogger;

class Syslog { class Syslog {
static protected $levels = array( static protected $levels = array(
\OCP\Util::DEBUG => LOG_DEBUG,
\OCP\Util::INFO => LOG_INFO,
\OCP\Util::WARN => LOG_WARNING,
\OCP\Util::ERROR => LOG_ERR,
\OCP\Util::FATAL => LOG_CRIT,
ILogger::DEBUG => LOG_DEBUG,
ILogger::INFO => LOG_INFO,
ILogger::WARN => LOG_WARNING,
ILogger::ERROR => LOG_ERR,
ILogger::FATAL => LOG_CRIT,
); );


/** /**

+ 3
- 1
lib/private/NaturalSort.php Просмотреть файл



namespace OC; namespace OC;


use OCP\ILogger;

class NaturalSort { class NaturalSort {
private static $instance; private static $instance;
private $collator; private $collator;
// or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator // or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator
if (isset($injectedCollator)) { if (isset($injectedCollator)) {
$this->collator = $injectedCollator; $this->collator = $injectedCollator;
\OCP\Util::writeLog('core', 'forced use of '.get_class($injectedCollator), \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', 'forced use of '.get_class($injectedCollator), ILogger::DEBUG);
} }
} }



+ 2
- 1
lib/private/Preview/Bitmap.php Просмотреть файл

namespace OC\Preview; namespace OC\Preview;


use Imagick; use Imagick;
use OCP\ILogger;


/** /**
* Creates a PNG preview using ImageMagick via the PECL extension * Creates a PNG preview using ImageMagick via the PECL extension
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => 'Imagick says:', 'message' => 'Imagick says:',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;

+ 3
- 1
lib/private/Preview/Office.php Просмотреть файл

*/ */
namespace OC\Preview; namespace OC\Preview;


use OCP\ILogger;

abstract class Office extends Provider { abstract class Office extends Provider {
private $cmd; private $cmd;


unlink($absPath); unlink($absPath);
unlink($pdfPreview); unlink($pdfPreview);
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;

+ 3
- 1
lib/private/Preview/SVG.php Просмотреть файл

*/ */
namespace OC\Preview; namespace OC\Preview;


use OCP\ILogger;

class SVG extends Provider { class SVG extends Provider {
/** /**
* {@inheritDoc} * {@inheritDoc}
$svg->setImageFormat('png32'); $svg->setImageFormat('png32');
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;

+ 4
- 4
lib/private/Settings/Manager.php Просмотреть файл

/** @var ISection $section */ /** @var ISection $section */
$section = \OC::$server->query($class); $section = \OC::$server->query($class);
} catch (QueryException $e) { } catch (QueryException $e) {
$this->log->logException($e, ['level' => Util::INFO]);
$this->log->logException($e, ['level' => ILogger::INFO]);
continue; continue;
} }


if (!$section instanceof ISection) { if (!$section instanceof ISection) {
$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => Util::INFO]);
$this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]);
continue; continue;
} }


/** @var ISettings $setting */ /** @var ISettings $setting */
$setting = \OC::$server->query($class); $setting = \OC::$server->query($class);
} catch (QueryException $e) { } catch (QueryException $e) {
$this->log->logException($e, ['level' => Util::INFO]);
$this->log->logException($e, ['level' => ILogger::INFO]);
continue; continue;
} }


if (!$setting instanceof ISettings) { if (!$setting instanceof ISettings) {
$this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => Util::INFO]);
$this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]);
continue; continue;
} }



+ 5
- 4
lib/private/Setup/MySQL.php Просмотреть файл



use OC\DB\MySqlTools; use OC\DB\MySqlTools;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\ILogger;


class MySQL extends AbstractDatabase { class MySQL extends AbstractDatabase {
public $dbprettyname = 'MySQL/MariaDB'; public $dbprettyname = 'MySQL/MariaDB';
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->logger->logException($ex, [ $this->logger->logException($ex, [
'message' => 'Database creation failed.', 'message' => 'Database creation failed.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'mysql.setup', 'app' => 'mysql.setup',
]); ]);
return; return;
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->logger->logException($ex, [ $this->logger->logException($ex, [
'message' => 'Could not automatically grant privileges, this can be ignored if database user already had privileges.', 'message' => 'Could not automatically grant privileges, this can be ignored if database user already had privileges.',
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'mysql.setup', 'app' => 'mysql.setup',
]); ]);
} }
catch (\Exception $ex){ catch (\Exception $ex){
$this->logger->logException($ex, [ $this->logger->logException($ex, [
'message' => 'Database user creation failed.', 'message' => 'Database user creation failed.',
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'mysql.setup', 'app' => 'mysql.setup',
]); ]);
} }
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->logger->logException($ex, [ $this->logger->logException($ex, [
'message' => 'Can not create a new MySQL user, will continue with the provided user.', 'message' => 'Can not create a new MySQL user, will continue with the provided user.',
'level' => \OCP\Util::INFO,
'level' => ILogger::INFO,
'app' => 'mysql.setup', 'app' => 'mysql.setup',
]); ]);
} }

+ 33
- 32
lib/private/Share/Share.php Просмотреть файл



use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger;
use OCP\Util; use OCP\Util;


/** /**
\OCP\Util::writeLog('OCP\Share', \OCP\Util::writeLog('OCP\Share',
'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class'] 'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class']
.' is already registered for '.$itemType, .' is already registered for '.$itemType,
\OCP\Util::WARN);
ILogger::WARN);
} }
return false; return false;
} }
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
$result = $query->execute(array($token)); $result = $query->execute(array($token));
if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, ILogger::ERROR);
} }
$row = $result->fetchRow(); $row = $result->fetchRow();
if ($row === false) { if ($row === false) {
if ($backend->isShareTypeAllowed($shareType) === false) { if ($backend->isShareTypeAllowed($shareType) === false) {
$message = 'Sharing %s failed, because the backend does not allow shares from type %i'; $message = 'Sharing %s failed, because the backend does not allow shares from type %i';
$message_t = $l->t('Sharing %s failed, because the backend does not allow shares from type %i', array($itemSourceName, $shareType)); $message_t = $l->t('Sharing %s failed, because the backend does not allow shares from type %i', array($itemSourceName, $shareType));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareType), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareType), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


if (!$path) { if (!$path) {
$message = 'Sharing %s failed, because the file does not exist'; $message = 'Sharing %s failed, because the file does not exist';
$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName)); $message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
// verify that the user has share permission // verify that the user has share permission
if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) { if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) {
$message = 'You are not allowed to share %s'; $message = 'You are not allowed to share %s';
$message_t = $l->t('You are not allowed to share %s', [$path]); $message_t = $l->t('You are not allowed to share %s', [$path]);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $path), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $path), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
foreach ($mounts as $mount) { foreach ($mounts as $mount) {
if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
$message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!'; $message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!';
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG);
throw new \Exception($message); throw new \Exception($message);
} }


if ($shareWith == $uidOwner) { if ($shareWith == $uidOwner) {
$message = 'Sharing %s failed, because you can not share with yourself'; $message = 'Sharing %s failed, because you can not share with yourself';
$message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]); $message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
if (!\OC::$server->getUserManager()->userExists($shareWith)) { if (!\OC::$server->getUserManager()->userExists($shareWith)) {
$message = 'Sharing %s failed, because the user %s does not exist'; $message = 'Sharing %s failed, because the user %s does not exist';
$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
if ($shareWithinGroupOnly) { if ($shareWithinGroupOnly) {
$message = 'Sharing %s failed, because the user ' $message = 'Sharing %s failed, because the user '
.'%s is not a member of any groups that %s is a member of'; .'%s is not a member of any groups that %s is a member of';
$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemName, $shareWith, $uidOwner)); $message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemName, $shareWith, $uidOwner));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
$message = 'Sharing %s failed, because this item is already shared with %s'; $message = 'Sharing %s failed, because this item is already shared with %s';
$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
$message = 'Sharing %s failed, because this item is already shared with user %s'; $message = 'Sharing %s failed, because this item is already shared with user %s';
$message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::ERROR);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
if (!\OC::$server->getGroupManager()->groupExists($shareWith)) { if (!\OC::$server->getGroupManager()->groupExists($shareWith)) {
$message = 'Sharing %s failed, because the group %s does not exist'; $message = 'Sharing %s failed, because the group %s does not exist';
$message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
if ($shareWithinGroupOnly) { if ($shareWithinGroupOnly) {
$message = 'Sharing %s failed, because ' $message = 'Sharing %s failed, because '
. '%s is not a member of the group %s'; . '%s is not a member of the group %s';
$message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith)); $message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
if ($checkExists['share_with'] === $shareWith && $checkExists['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) { if ($checkExists['share_with'] === $shareWith && $checkExists['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
$message = 'Sharing %s failed, because this item is already shared with %s'; $message = 'Sharing %s failed, because this item is already shared with %s';
$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
if (\OCP\Util::isPublicLinkPasswordRequired() && empty($shareWith)) { if (\OCP\Util::isPublicLinkPasswordRequired() && empty($shareWith)) {
$message = 'You need to provide a password to create a public link, only protected links are allowed'; $message = 'You need to provide a password to create a public link, only protected links are allowed';
$message_t = $l->t('You need to provide a password to create a public link, only protected links are allowed'); $message_t = $l->t('You need to provide a password to create a public link, only protected links are allowed');
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


} }
$message = 'Sharing %s failed, because sharing with links is not allowed'; $message = 'Sharing %s failed, because sharing with links is not allowed';
$message_t = $l->t('Sharing %s failed, because sharing with links is not allowed', array($itemSourceName)); $message_t = $l->t('Sharing %s failed, because sharing with links is not allowed', array($itemSourceName));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} else if ($shareType === self::SHARE_TYPE_REMOTE) { } else if ($shareType === self::SHARE_TYPE_REMOTE) {


$shareWith, $uidOwner, self::FORMAT_NONE, null, 1, true, true)) { $shareWith, $uidOwner, self::FORMAT_NONE, null, 1, true, true)) {
$message = 'Sharing %s failed, because this item is already shared with %s'; $message = 'Sharing %s failed, because this item is already shared with %s';
$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith)); $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) { if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) {
$message = 'Not allowed to create a federated share with the same user.'; $message = 'Not allowed to create a federated share with the same user.';
$message_t = $l->t('Not allowed to create a federated share with the same user'); $message_t = $l->t('Not allowed to create a federated share with the same user');
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


// Future share types need to include their own conditions // Future share types need to include their own conditions
$message = 'Share type %s is not valid for %s'; $message = 'Share type %s is not valid for %s';
$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource)); $message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


$result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient)); $result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient));


if($result === false) { if($result === false) {
\OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', ILogger::ERROR);
} }
} }


if ($date > $maxDate) { if ($date > $maxDate) {
$warning = 'Cannot set expiration date. Shares cannot expire later than ' . $maxDays . ' after they have been shared'; $warning = 'Cannot set expiration date. Shares cannot expire later than ' . $maxDays . ' after they have been shared';
$warning_t = $l->t('Cannot set expiration date. Shares cannot expire later than %s after they have been shared', array($maxDays)); $warning_t = $l->t('Cannot set expiration date. Shares cannot expire later than %s after they have been shared', array($maxDays));
\OCP\Util::writeLog('OCP\Share', $warning, \OCP\Util::WARN);
\OCP\Util::writeLog('OCP\Share', $warning, ILogger::WARN);
throw new \Exception($warning_t); throw new \Exception($warning_t);
} }
} }
if ($date < $today) { if ($date < $today) {
$message = 'Cannot set expiration date. Expiration date is in the past'; $message = 'Cannot set expiration date. Expiration date is in the past';
$message_t = $l->t('Cannot set expiration date. Expiration date is in the past'); $message_t = $l->t('Cannot set expiration date. Expiration date is in the past');
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN);
\OCP\Util::writeLog('OCP\Share', $message, ILogger::WARN);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) { if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
$message = 'Sharing backend %s must implement the interface OCP\Share_Backend'; $message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
$message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class)); $message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
return self::$backends[$itemType]; return self::$backends[$itemType];
} else { } else {
$message = 'Sharing backend %s not found'; $message = 'Sharing backend %s not found';
$message_t = $l->t('Sharing backend %s not found', array($class)); $message_t = $l->t('Sharing backend %s not found', array($class));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
$message = 'Sharing backend for %s not found'; $message = 'Sharing backend for %s not found';
$message_t = $l->t('Sharing backend for %s not found', array($itemType)); $message_t = $l->t('Sharing backend for %s not found', array($itemType));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), \OCP\Util::ERROR);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), ILogger::ERROR);
throw new \Exception($message_t); throw new \Exception($message_t);
} }


if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('OCP\Share', \OCP\Util::writeLog('OCP\Share',
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=', \OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
\OCP\Util::ERROR);
ILogger::ERROR);
} }
$items = array(); $items = array();
$targets = array(); $targets = array();
if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' . \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
\OCP\Util::ERROR);
ILogger::ERROR);
} else { } else {
$parentRow = $parentResult->fetchRow(); $parentRow = $parentResult->fetchRow();
$tmpPath = $parentRow['file_target']; $tmpPath = $parentRow['file_target'];
$message = 'Sharing %s failed, because the user %s is the original sharer'; $message = 'Sharing %s failed, because the user %s is the original sharer';
$message_t = $l->t('Sharing failed, because the user %s is the original sharer', [$shareWith]); $message_t = $l->t('Sharing failed, because the user %s is the original sharer', [$shareWith]);


\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} }
$message = 'Sharing %s failed, because the permissions exceed permissions granted to %s'; $message = 'Sharing %s failed, because the permissions exceed permissions granted to %s';
$message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner)); $message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner));


\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} else { } else {
// TODO Don't check if inside folder // TODO Don't check if inside folder
$message = 'Sharing %s failed, because resharing is not allowed'; $message = 'Sharing %s failed, because resharing is not allowed';
$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName)); $message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName));


\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} else { } else {
$message = 'Sharing %s failed, because the sharing backend for ' $message = 'Sharing %s failed, because the sharing backend for '
.'%s could not find its source'; .'%s could not find its source';
$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType)); $message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
if ($backend instanceof \OCP\Share_Backend_File_Dependent) { if ($backend instanceof \OCP\Share_Backend_File_Dependent) {
$message = 'Sharing %s failed, because the file could not be found in the file cache'; $message = 'Sharing %s failed, because the file could not be found in the file cache';
$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource)); $message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource));


\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::DEBUG);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), ILogger::DEBUG);
throw new \Exception($message_t); throw new \Exception($message_t);
} }
} else { } else {

+ 36
- 35
lib/private/Tags.php Просмотреть файл

use OC\Tagging\Tag; use OC\Tagging\Tag;
use OC\Tagging\TagMapper; use OC\Tagging\TagMapper;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ILogger;


class Tags implements \OCP\ITags { class Tags implements \OCP\ITags {


$entries[$objId][] = $row['category']; $entries[$objId][] = $row['category'];
} }
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR);
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
return false; return false;
} }
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
} elseif(is_string($tag)) { } elseif(is_string($tag)) {
$tag = trim($tag); $tag = trim($tag);
if($tag === '') { if($tag === '') {
\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG);
return false; return false;
} }
$tagId = $this->getTagId($tag); $tagId = $this->getTagId($tag);
$stmt = \OC_DB::prepare($sql); $stmt = \OC_DB::prepare($sql);
$result = $stmt->execute(array($tagId)); $result = $stmt->execute(array($tagId));
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR);
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
return false; return false;
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
$name = trim($name); $name = trim($name);


if($name === '') { if($name === '') {
\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG);
return false; return false;
} }
if($this->userHasTag($name, $this->user)) { if($this->userHasTag($name, $this->user)) {
\OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', ILogger::DEBUG);
return false; return false;
} }
try { try {
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
} }
\OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), ILogger::DEBUG);
return $tag->getId(); return $tag->getId();
} }


$to = trim($to); $to = trim($to);


if($to === '' || $from === '') { if($to === '' || $from === '') {
\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG);
return false; return false;
} }


$key = $this->getTagByName($from); $key = $this->getTagByName($from);
} }
if($key === false) { if($key === false) {
\OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', ILogger::DEBUG);
return false; return false;
} }
$tag = $this->tags[$key]; $tag = $this->tags[$key];


if($this->userHasTag($to, $tag->getOwner())) { if($this->userHasTag($to, $tag->getOwner())) {
\OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', ILogger::DEBUG);
return false; return false;
} }


} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
// reload tags to get the proper ids. // reload tags to get the proper ids.
$this->tags = $this->mapper->loadTags($this->owners, $this->type); $this->tags = $this->mapper->loadTags($this->owners, $this->type);
\OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true),
\OCP\Util::DEBUG);
ILogger::DEBUG);
// Loop through temporarily cached objectid/tagname pairs // Loop through temporarily cached objectid/tagname pairs
// and save relations. // and save relations.
$tags = $this->tags; $tags = $this->tags;
$dbConnection = \OC::$server->getDatabaseConnection(); $dbConnection = \OC::$server->getDatabaseConnection();
foreach(self::$relations as $relation) { foreach(self::$relations as $relation) {
$tagId = $this->getTagId($relation['tag']); $tagId = $this->getTagId($relation['tag']);
\OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, ILogger::DEBUG);
if($tagId) { if($tagId) {
try { try {
$dbConnection->insertIfNotExist(self::RELATION_TABLE, $dbConnection->insertIfNotExist(self::RELATION_TABLE,
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
self::$relations = array(); // reset self::$relations = array(); // reset
} else { } else {
\OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! ' \OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! '
. print_r($this->tags, true), \OCP\Util::ERROR);
. print_r($this->tags, true), ILogger::ERROR);
} }
} }


. 'WHERE `uid` = ?'); . 'WHERE `uid` = ?');
$result = $stmt->execute(array($arguments['uid'])); $result = $stmt->execute(array($arguments['uid']));
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR);
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
. 'WHERE `uid` = ?'); . 'WHERE `uid` = ?');
$result = $stmt->execute(array($arguments['uid'])); $result = $stmt->execute(array($arguments['uid']));
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR);
\OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
} }
$stmt = \OC_DB::prepare($query); $stmt = \OC_DB::prepare($query);
$result = $stmt->execute($updates); $result = $stmt->execute($updates);
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), \OCP\Util::ERROR);
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
return false; return false;
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return array(); return array();
if(is_string($tag) && !is_numeric($tag)) { if(is_string($tag) && !is_numeric($tag)) {
$tag = trim($tag); $tag = trim($tag);
if($tag === '') { if($tag === '') {
\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG);
return false; return false;
} }
if(!$this->hasTag($tag)) { if(!$this->hasTag($tag)) {
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
if(is_string($tag) && !is_numeric($tag)) { if(is_string($tag) && !is_numeric($tag)) {
$tag = trim($tag); $tag = trim($tag);
if($tag === '') { if($tag === '') {
\OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG);
return false; return false;
} }
$tagId = $this->getTagId($tag); $tagId = $this->getTagId($tag);
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;
array_filter($names); array_filter($names);


\OCP\Util::writeLog('core', __METHOD__ . ', before: ' \OCP\Util::writeLog('core', __METHOD__ . ', before: '
. print_r($this->tags, true), \OCP\Util::DEBUG);
. print_r($this->tags, true), ILogger::DEBUG);
foreach($names as $name) { foreach($names as $name) {
$id = null; $id = null;


$this->mapper->delete($tag); $this->mapper->delete($tag);
} else { } else {
\OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name
. ': not found.', \OCP\Util::ERROR);
. ': not found.', ILogger::ERROR);
} }
if(!is_null($id) && $id !== false) { if(!is_null($id) && $id !== false) {
try { try {
if ($result === null) { if ($result === null) {
\OCP\Util::writeLog('core', \OCP\Util::writeLog('core',
__METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(),
\OCP\Util::ERROR);
ILogger::ERROR);
return false; return false;
} }
} catch(\Exception $e) { } catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'message' => __METHOD__, 'message' => __METHOD__,
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'core', 'app' => 'core',
]); ]);
return false; return false;

+ 2
- 2
lib/private/Updater.php Просмотреть файл

$this->emitRepairEvents(); $this->emitRepairEvents();
$this->logAllEvents(); $this->logAllEvents();


$logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
$logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
$this->config->setSystemValue('loglevel', Util::DEBUG);
$this->config->setSystemValue('loglevel', ILogger::DEBUG);


$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);



+ 2
- 1
lib/private/User/Database.php Просмотреть файл



use OC\Cache\CappedMemoryCache; use OC\Cache\CappedMemoryCache;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\ILogger;
use OCP\User\Backend\ABackend; use OCP\User\Backend\ABackend;
use OCP\User\Backend\ICheckPasswordBackend; use OCP\User\Backend\ICheckPasswordBackend;
use OCP\User\Backend\ICountUsersBackend; use OCP\User\Backend\ICountUsersBackend;
$query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
$result = $query->execute(); $result = $query->execute();
if ($result === false) { if ($result === false) {
Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
Util::writeLog('core', \OC_DB::getErrorMessage(), ILogger::ERROR);
return false; return false;
} }
return $result->fetchOne(); return $result->fetchOne();

+ 7
- 6
lib/private/legacy/app.php Просмотреть файл

use OC\Installer; use OC\Installer;
use OC\Repair; use OC\Repair;
use OCP\App\ManagerEvent; use OCP\App\ManagerEvent;
use OCP\ILogger;


/** /**
* This class manages the apps. It allows them to register and integrate in the * This class manages the apps. It allows them to register and integrate in the
} }
} }


\OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'No application directories are marked as writable.', ILogger::ERROR);
return null; return null;
} }




foreach (OC::$APPSROOTS as $apps_dir) { foreach (OC::$APPSROOTS as $apps_dir) {
if (!is_readable($apps_dir['path'])) { if (!is_readable($apps_dir['path'])) {
\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN);
continue; continue;
} }
$dh = opendir($apps_dir['path']); $dh = opendir($apps_dir['path']);


$info = OC_App::getAppInfo($app, false, $langCode); $info = OC_App::getAppInfo($app, false, $langCode);
if (!is_array($info)) { if (!is_array($info)) {
\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);
continue; continue;
} }


if (!isset($info['name'])) { if (!isset($info['name'])) {
\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR);
continue; continue;
} }


} }
return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
} else { } else {
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR);
return false; return false;
} }
} else { } else {
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR);
return false; return false;
} }
} }

+ 3
- 1
lib/private/legacy/db.php Просмотреть файл

* *
*/ */


use OCP\ILogger;

/** /**
* This class manages the access to the database. It basically is a wrapper for * This class manages the access to the database. It basically is a wrapper for
* Doctrine with some adaptions. * Doctrine with some adaptions.
try { try {
$result = $schemaManager->updateDbFromStructure($file); $result = $schemaManager->updateDbFromStructure($file);
} catch (Exception $e) { } catch (Exception $e) {
\OCP\Util::writeLog('core', 'Failed to update database structure ('.$e.')', \OCP\Util::FATAL);
\OCP\Util::writeLog('core', 'Failed to update database structure ('.$e.')', ILogger::FATAL);
throw $e; throw $e;
} }
return $result; return $result;

+ 2
- 1
lib/private/legacy/files.php Просмотреть файл



use OC\Files\View; use OC\Files\View;
use OC\Streamer; use OC\Streamer;
use OCP\ILogger;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;


/** /**
if (!$handle) { if (!$handle) {
\OCP\Util::writeLog('files', \OCP\Util::writeLog('files',
'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions',
\OCP\Util::WARN);
ILogger::WARN);
$success = false; $success = false;
continue; // try to update as many files as possible continue; // try to update as many files as possible
} }

+ 6
- 4
lib/private/legacy/user.php Просмотреть файл

* *
*/ */


use OCP\ILogger;

/** /**
* This class provides wrapper methods for user management. Multiple backends are * This class provides wrapper methods for user management. Multiple backends are
* supported. User management operations are delegated to the configured backend for * supported. User management operations are delegated to the configured backend for
case 'database': case 'database':
case 'mysql': case 'mysql':
case 'sqlite': case 'sqlite':
\OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG);
self::$_usedBackends[$backend] = new \OC\User\Database(); self::$_usedBackends[$backend] = new \OC\User\Database();
\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break; break;
\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
break; break;
default: default:
\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG);
$className = 'OC_USER_' . strtoupper($backend); $className = 'OC_USER_' . strtoupper($backend);
self::$_usedBackends[$backend] = new $className(); self::$_usedBackends[$backend] = new $className();
\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
self::useBackend($backend); self::useBackend($backend);
self::$_setupedBackends[] = $i; self::$_setupedBackends[] = $i;
} else { } else {
\OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', \OCP\Util::DEBUG);
\OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG);
} }
} else { } else {
\OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', \OCP\Util::ERROR);
\OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR);
} }
} }
} }

+ 5
- 4
lib/private/legacy/util.php Просмотреть файл



use OCP\IConfig; use OCP\IConfig;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUser; use OCP\IUser;


class OC_Util { class OC_Util {
private static function initObjectStoreRootFS($config) { private static function initObjectStoreRootFS($config) {
// check misconfiguration // check misconfiguration
if (empty($config['class'])) { if (empty($config['class'])) {
\OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
} }
if (!isset($config['arguments'])) { if (!isset($config['arguments'])) {
$config['arguments'] = array(); $config['arguments'] = array();
private static function initObjectStoreMultibucketRootFS($config) { private static function initObjectStoreMultibucketRootFS($config) {
// check misconfiguration // check misconfiguration
if (empty($config['class'])) { if (empty($config['class'])) {
\OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
} }
if (!isset($config['arguments'])) { if (!isset($config['arguments'])) {
$config['arguments'] = array(); $config['arguments'] = array();
\OCP\Util::writeLog( \OCP\Util::writeLog(
'files_skeleton', 'files_skeleton',
'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), 'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'),
\OCP\Util::DEBUG
ILogger::DEBUG
); );
self::copyr($skeletonDirectory, $userDirectory); self::copyr($skeletonDirectory, $userDirectory);
// update the file cache // update the file cache
// XCache // XCache
if (function_exists('xcache_clear_cache')) { if (function_exists('xcache_clear_cache')) {
if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) { if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) {
\OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN);
\OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', ILogger::WARN);
} else { } else {
@xcache_clear_cache(XC_TYPE_PHP, 0); @xcache_clear_cache(XC_TYPE_PHP, 0);
} }

+ 21
- 0
lib/public/ILogger.php Просмотреть файл

* https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface
*/ */
interface ILogger { interface ILogger {
/**
* @since 14.0.0
*/
const DEBUG=0;
/**
* @since 14.0.0
*/
const INFO=1;
/**
* @since 14.0.0
*/
const WARN=2;
/**
* @since 14.0.0
*/
const ERROR=3;
/**
* @since 14.0.0
*/
const FATAL=4;

/** /**
* System is unusable. * System is unusable.
* *

+ 16
- 2
lib/public/Util.php Просмотреть файл

* @since 4.0.0 * @since 4.0.0
*/ */
class Util { class Util {
// consts for Logging
/**
* @deprecated 14.0.0 use \OCP\ILogger::DEBUG
*/
const DEBUG=0; const DEBUG=0;
/**
* @deprecated 14.0.0 use \OCP\ILogger::INFO
*/
const INFO=1; const INFO=1;
/**
* @deprecated 14.0.0 use \OCP\ILogger::WARN
*/
const WARN=2; const WARN=2;
/**
* @deprecated 14.0.0 use \OCP\ILogger::ERROR
*/
const ERROR=3; const ERROR=3;
/**
* @deprecated 14.0.0 use \OCP\ILogger::FATAL
*/
const FATAL=4; const FATAL=4;


/** \OCP\Share\IManager */ /** \OCP\Share\IManager */
* @since ....0.0 - parameter $level was added in 7.0.0 * @since ....0.0 - parameter $level was added in 7.0.0
* @deprecated 8.2.0 use logException of \OCP\ILogger * @deprecated 8.2.0 use logException of \OCP\ILogger
*/ */
public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) {
public static function logException( $app, \Exception $ex, $level = ILogger::FATAL) {
\OC::$server->getLogger()->logException($ex, ['app' => $app]); \OC::$server->getLogger()->logException($ex, ['app' => $app]);
} }



+ 1
- 1
settings/Controller/UsersController.php Просмотреть файл

} catch (\Exception $e) { } catch (\Exception $e) {
$this->log->logException($e, [ $this->log->logException($e, [
'message' => "Can't send new user mail to $email", 'message' => "Can't send new user mail to $email",
'level' => \OCP\Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'settings', 'app' => 'settings',
]); ]);
} }

+ 4
- 1
settings/ajax/enableapp.php Просмотреть файл

* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */

use OCP\ILogger;

OC_JSON::checkAdminUser(); OC_JSON::checkAdminUser();
\OC_JSON::callCheck(); \OC_JSON::callCheck();


OC_JSON::success(['data' => ['update_required' => $updateRequired]]); OC_JSON::success(['data' => ['update_required' => $updateRequired]]);
} catch (Exception $e) { } catch (Exception $e) {
\OC::$server->getLogger()->logException($e, [ \OC::$server->getLogger()->logException($e, [
'level' => \OCP\Util::DEBUG,
'level' => ILogger::DEBUG,
'app' => 'core', 'app' => 'core',
]); ]);
OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); OC_JSON::error(array("data" => array("message" => $e->getMessage()) ));

+ 3
- 2
tests/lib/Log/FileTest.php Просмотреть файл

namespace Test\Log; namespace Test\Log;


use OC\Log\File; use OC\Log\File;
use OCP\ILogger;
use Test\TestCase; use Test\TestCase;


/** /**


# set format & write log line # set format & write log line
$config->setSystemValue('logdateformat', 'u'); $config->setSystemValue('logdateformat', 'u');
File::write('test', 'message', \OCP\Util::ERROR);
File::write('test', 'message', ILogger::ERROR);
# read log line # read log line
$handle = @fopen($config->getSystemValue('logfile'), 'r'); $handle = @fopen($config->getSystemValue('logfile'), 'r');
$line = fread($handle, 1000); $line = fread($handle, 1000);

+ 2
- 1
tests/lib/LoggerTest.php Просмотреть файл

namespace Test; namespace Test;


use OC\Log; use OC\Log;
use OCP\ILogger;


class LoggerTest extends TestCase { class LoggerTest extends TestCase {


$this->config->expects($this->any()) $this->config->expects($this->any())
->method('getValue') ->method('getValue')
->will(($this->returnValueMap([ ->will(($this->returnValueMap([
['loglevel', \OCP\Util::WARN, \OCP\Util::WARN],
['loglevel', ILogger::WARN, ILogger::WARN],
['log.condition', [], ['apps' => ['files']]] ['log.condition', [], ['apps' => ['files']]]
]))); ])));
$logger = $this->logger; $logger = $this->logger;

Загрузка…
Отмена
Сохранить