Browse Source

fix: Apply new coding standard to all files

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/44534/head
Côme Chilliet 1 month ago
parent
commit
ec5133b739
100 changed files with 195 additions and 196 deletions
  1. 9
    9
      apps/admin_audit/lib/AuditLogger.php
  2. 1
    1
      apps/cloud_federation_api/lib/Capabilities.php
  3. 1
    1
      apps/comments/lib/Activity/Provider.php
  4. 1
    1
      apps/contactsinteraction/tests/Db/RecentContactMapperTest.php
  5. 1
    1
      apps/dav/appinfo/v2/direct.php
  6. 1
    1
      apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
  7. 1
    1
      apps/dav/lib/CalDAV/Activity/Provider/Event.php
  8. 1
    1
      apps/dav/lib/CalDAV/Activity/Provider/Todo.php
  9. 1
    1
      apps/dav/lib/CalDAV/BirthdayService.php
  10. 1
    1
      apps/dav/lib/CalDAV/CalDavBackend.php
  11. 2
    2
      apps/dav/lib/CalDAV/Reminder/ReminderService.php
  12. 2
    2
      apps/dav/lib/CalDAV/Schedule/Plugin.php
  13. 1
    1
      apps/dav/lib/CalDAV/Status/StatusService.php
  14. 1
    1
      apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php
  15. 1
    1
      apps/dav/lib/CardDAV/Activity/Provider/Card.php
  16. 1
    1
      apps/dav/lib/CardDAV/CardDavBackend.php
  17. 1
    1
      apps/dav/lib/CardDAV/SyncService.php
  18. 3
    3
      apps/dav/lib/Command/MoveCalendar.php
  19. 1
    1
      apps/dav/lib/Comments/EntityCollection.php
  20. 1
    1
      apps/dav/lib/Connector/Sabre/CachingTree.php
  21. 2
    2
      apps/dav/lib/Connector/Sabre/Directory.php
  22. 1
    1
      apps/dav/lib/Connector/Sabre/Exception/FileLocked.php
  23. 1
    1
      apps/dav/lib/Connector/Sabre/Exception/Forbidden.php
  24. 1
    1
      apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php
  25. 1
    1
      apps/dav/lib/Connector/Sabre/File.php
  26. 2
    2
      apps/dav/lib/Connector/Sabre/FilesPlugin.php
  27. 1
    1
      apps/dav/lib/Connector/Sabre/Node.php
  28. 1
    1
      apps/dav/lib/DAV/Sharing/Xml/Invite.php
  29. 1
    1
      apps/dav/lib/HookManager.php
  30. 1
    1
      apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
  31. 23
    23
      apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
  32. 3
    3
      apps/dav/tests/unit/Connector/Sabre/FileTest.php
  33. 1
    1
      apps/dav/tests/unit/Files/MultipartRequestParserTest.php
  34. 3
    3
      apps/encryption/lib/Hooks/UserHooks.php
  35. 2
    2
      apps/files/lib/Activity/FavoriteProvider.php
  36. 4
    4
      apps/files/lib/Activity/Provider.php
  37. 1
    1
      apps/files/lib/Collaboration/Resources/ResourceProvider.php
  38. 2
    2
      apps/files/lib/Controller/DirectEditingController.php
  39. 1
    1
      apps/files/lib/Controller/ViewController.php
  40. 1
    1
      apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php
  41. 1
    1
      apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php
  42. 1
    1
      apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
  43. 1
    1
      apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php
  44. 1
    1
      apps/files_external/lib/Lib/Auth/Password/UserProvided.php
  45. 1
    1
      apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
  46. 1
    1
      apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
  47. 1
    1
      apps/files_external/lib/Lib/Backend/InvalidBackend.php
  48. 1
    1
      apps/files_external/lib/Lib/Backend/Local.php
  49. 1
    1
      apps/files_external/lib/Lib/Backend/SMB.php
  50. 1
    1
      apps/files_external/lib/Lib/Backend/SMB_OC.php
  51. 1
    1
      apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php
  52. 1
    1
      apps/files_external/lib/Lib/Storage/FTP.php
  53. 1
    1
      apps/files_external/lib/Lib/Storage/SFTP.php
  54. 1
    1
      apps/files_external/lib/Lib/StorageModifierTrait.php
  55. 1
    1
      apps/files_external/lib/MountConfig.php
  56. 1
    1
      apps/files_external/lib/Service/UserGlobalStoragesService.php
  57. 4
    4
      apps/files_external/templates/settings.php
  58. 3
    3
      apps/files_sharing/lib/Activity/Providers/Base.php
  59. 1
    1
      apps/files_sharing/lib/Activity/Providers/Downloads.php
  60. 1
    1
      apps/files_sharing/lib/Activity/Providers/Groups.php
  61. 1
    1
      apps/files_sharing/lib/Activity/Providers/PublicLinks.php
  62. 1
    1
      apps/files_sharing/lib/Activity/Providers/RemoteShares.php
  63. 1
    1
      apps/files_sharing/lib/Activity/Providers/Users.php
  64. 16
    16
      apps/files_sharing/lib/Controller/ShareAPIController.php
  65. 1
    1
      apps/files_sharing/lib/Controller/ShareesAPIController.php
  66. 1
    1
      apps/files_sharing/lib/External/Storage.php
  67. 1
    1
      apps/files_sharing/lib/Helper.php
  68. 1
    1
      apps/files_sharing/lib/ShareBackend/File.php
  69. 2
    2
      apps/files_trashbin/lib/Command/ExpireTrash.php
  70. 1
    1
      apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php
  71. 5
    5
      apps/files_trashbin/lib/Storage.php
  72. 1
    1
      apps/files_trashbin/lib/Trash/LegacyTrashBackend.php
  73. 2
    2
      apps/provisioning_api/lib/Controller/GroupsController.php
  74. 2
    2
      apps/provisioning_api/lib/Controller/UsersController.php
  75. 1
    1
      apps/settings/lib/Activity/GroupProvider.php
  76. 1
    1
      apps/settings/lib/Activity/Provider.php
  77. 1
    1
      apps/settings/lib/Activity/SecurityProvider.php
  78. 2
    2
      apps/settings/lib/Controller/ChangePasswordController.php
  79. 2
    2
      apps/settings/lib/Controller/UsersController.php
  80. 1
    1
      apps/settings/lib/Mailer/NewUserMailHelper.php
  81. 1
    1
      apps/settings/lib/SetupChecks/PhpOpcacheSetup.php
  82. 1
    2
      apps/settings/templates/settings/personal/security/twofactor.php
  83. 1
    1
      apps/sharebymail/lib/Activity.php
  84. 1
    1
      apps/systemtags/lib/Activity/Provider.php
  85. 1
    1
      apps/testing/lib/Controller/LockingController.php
  86. 1
    1
      apps/theming/lib/Controller/UserThemeController.php
  87. 1
    1
      apps/theming/lib/Service/ThemeInjectionService.php
  88. 2
    2
      apps/theming/tests/Controller/UserThemeControllerTest.php
  89. 1
    1
      apps/twofactor_backupcodes/lib/Activity/Provider.php
  90. 2
    2
      apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
  91. 16
    16
      apps/user_ldap/lib/Access.php
  92. 1
    1
      apps/user_ldap/lib/Configuration.php
  93. 1
    1
      apps/user_ldap/lib/Connection.php
  94. 1
    1
      apps/user_ldap/lib/DataCollector/LdapDataCollector.php
  95. 1
    1
      apps/user_ldap/lib/Jobs/Sync.php
  96. 1
    1
      apps/user_ldap/lib/Mapping/AbstractMapping.php
  97. 6
    6
      apps/user_ldap/lib/User/User.php
  98. 1
    1
      apps/user_ldap/tests/Group_LDAPTest.php
  99. 1
    1
      apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php
  100. 0
    0
      apps/user_ldap/tests/User/UserTest.php

+ 9
- 9
apps/admin_audit/lib/AuditLogger.php View File

$this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag); $this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag);
} }


public function emergency($message, array $context = array()): void {
public function emergency($message, array $context = []): void {
$this->parentLogger->emergency($message, $context); $this->parentLogger->emergency($message, $context);
} }


public function alert($message, array $context = array()): void {
public function alert($message, array $context = []): void {
$this->parentLogger->alert($message, $context); $this->parentLogger->alert($message, $context);
} }


public function critical($message, array $context = array()): void {
public function critical($message, array $context = []): void {
$this->parentLogger->critical($message, $context); $this->parentLogger->critical($message, $context);
} }


public function error($message, array $context = array()): void {
public function error($message, array $context = []): void {
$this->parentLogger->error($message, $context); $this->parentLogger->error($message, $context);
} }


public function warning($message, array $context = array()): void {
public function warning($message, array $context = []): void {
$this->parentLogger->warning($message, $context); $this->parentLogger->warning($message, $context);
} }


public function notice($message, array $context = array()): void {
public function notice($message, array $context = []): void {
$this->parentLogger->notice($message, $context); $this->parentLogger->notice($message, $context);
} }


public function info($message, array $context = array()): void {
public function info($message, array $context = []): void {
$this->parentLogger->info($message, $context); $this->parentLogger->info($message, $context);
} }


public function debug($message, array $context = array()): void {
public function debug($message, array $context = []): void {
$this->parentLogger->debug($message, $context); $this->parentLogger->debug($message, $context);
} }


public function log($level, $message, array $context = array()): void {
public function log($level, $message, array $context = []): void {
$this->parentLogger->log($level, $message, $context); $this->parentLogger->log($level, $message, $context);
} }
} }

+ 1
- 1
apps/cloud_federation_api/lib/Capabilities.php View File

$this->provider->setApiVersion(self::API_VERSION); $this->provider->setApiVersion(self::API_VERSION);


$pos = strrpos($url, '/'); $pos = strrpos($url, '/');
if (false === $pos) {
if ($pos === false) {
throw new OCMArgumentException('generated route should contains a slash character'); throw new OCMArgumentException('generated route should contains a slash character');
} }



+ 1
- 1
apps/comments/lib/Activity/Provider.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'comments') { if ($event->getApp() !== 'comments') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/contactsinteraction/tests/Db/RecentContactMapperTest.php View File

$this->assertCount(0, $this->recentContactMapper->findAll('admin')); $this->assertCount(0, $this->recentContactMapper->findAll('admin'));
} }


protected function createRecentContact(string $email = null, string $federatedCloudId = null): RecentContact {
protected function createRecentContact(?string $email = null, ?string $federatedCloudId = null): RecentContact {
$props = [ $props = [
'URI' => UUIDUtil::getUUID(), 'URI' => UUIDUtil::getUUID(),
'FN' => 'Foo Bar', 'FN' => 'Foo Bar',

+ 1
- 1
apps/dav/appinfo/v2/direct.php View File

* 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 \OCA\DAV\Direct\ServerFactory;
use OCA\DAV\Direct\ServerFactory;


// no php execution timeout for webdav // no php execution timeout for webdav
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) { if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {

+ 1
- 1
apps/dav/lib/CalDAV/Activity/Provider/Calendar.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/dav/lib/CalDAV/Activity/Provider/Event.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/dav/lib/CalDAV/Activity/Provider/Todo.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/dav/lib/CalDAV/BirthdayService.php View File

*/ */
private function formatTitle(string $field, private function formatTitle(string $field,
string $name, string $name,
int $year = null,
?int $year = null,
bool $supports4Byte = true):string { bool $supports4Byte = true):string {
if ($supports4Byte) { if ($supports4Byte) {
switch ($field) { switch ($field) {

+ 1
- 1
apps/dav/lib/CalDAV/CalDavBackend.php View File

->andWhere($searchOr) ->andWhere($searchOr)
->andWhere($calendarObjectIdQuery->expr()->isNull('deleted_at')); ->andWhere($calendarObjectIdQuery->expr()->isNull('deleted_at'));


if ('' !== $pattern) {
if ($pattern !== '') {
if (!$escapePattern) { if (!$escapePattern) {
$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern))); $calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern)));
} else { } else {

+ 2
- 2
apps/dav/lib/CalDAV/Reminder/ReminderService.php View File

private function getRemindersForVAlarm(VAlarm $valarm, private function getRemindersForVAlarm(VAlarm $valarm,
array $objectData, array $objectData,
DateTimeZone $calendarTimeZone, DateTimeZone $calendarTimeZone,
string $eventHash = null,
string $alarmHash = null,
?string $eventHash = null,
?string $alarmHash = null,
bool $isRecurring = false, bool $isRecurring = false,
bool $isRecurrenceException = false):array { bool $isRecurrenceException = false):array {
if ($eventHash === null) { if ($eventHash === null) {

+ 2
- 2
apps/dav/lib/CalDAV/Schedule/Plugin.php View File

use Sabre\VObject\Parameter; use Sabre\VObject\Parameter;
use Sabre\VObject\Property; use Sabre\VObject\Property;
use Sabre\VObject\Reader; use Sabre\VObject\Reader;
use function \Sabre\Uri\split;
use function Sabre\Uri\split;


class Plugin extends \Sabre\CalDAV\Schedule\Plugin { class Plugin extends \Sabre\CalDAV\Schedule\Plugin {


* @param Property|null $attendee * @param Property|null $attendee
* @return bool * @return bool
*/ */
private function getAttendeeRSVP(Property $attendee = null):bool {
private function getAttendeeRSVP(?Property $attendee = null):bool {
if ($attendee !== null) { if ($attendee !== null) {
$rsvp = $attendee->offsetGet('RSVP'); $rsvp = $attendee->offsetGet('RSVP');
if (($rsvp instanceof Parameter) && (strcasecmp($rsvp->getValue(), 'TRUE') === 0)) { if (($rsvp instanceof Parameter) && (strcasecmp($rsvp->getValue(), 'TRUE') === 0)) {

+ 1
- 1
apps/dav/lib/CalDAV/Status/StatusService.php View File

} }


$sct = $calendarObject->getSchedulingTransparency(); $sct = $calendarObject->getSchedulingTransparency();
if ($sct !== null && ScheduleCalendarTransp::TRANSPARENT == strtolower($sct->getValue())) {
if ($sct !== null && strtolower($sct->getValue()) == ScheduleCalendarTransp::TRANSPARENT) {
// If a calendar is marked as 'transparent', it means we must // If a calendar is marked as 'transparent', it means we must
// ignore it for free-busy purposes. // ignore it for free-busy purposes.
continue; continue;

+ 1
- 1
apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php View File

* @return IEvent * @return IEvent
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') { if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/dav/lib/CardDAV/Activity/Provider/Card.php View File

* @return IEvent * @return IEvent
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') { if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/dav/lib/CardDAV/CardDavBackend.php View File

->andWhere($query2->expr()->in('cp.name', $query2->createNamedParameter($searchProperties, IQueryBuilder::PARAM_STR_ARRAY))); ->andWhere($query2->expr()->in('cp.name', $query2->createNamedParameter($searchProperties, IQueryBuilder::PARAM_STR_ARRAY)));


// No need for like when the pattern is empty // No need for like when the pattern is empty
if ('' !== $pattern) {
if ($pattern !== '') {
if (!$useWildcards) { if (!$useWildcards) {
$query2->andWhere($query2->expr()->eq('cp.value', $query2->createNamedParameter($pattern))); $query2->andWhere($query2->expr()->eq('cp.value', $query2->createNamedParameter($pattern)));
} elseif (!$escapePattern) { } elseif (!$escapePattern) {

+ 1
- 1
apps/dav/lib/CardDAV/SyncService.php View File

return $this->localSystemAddressBook; return $this->localSystemAddressBook;
} }


public function syncInstance(\Closure $progressCallback = null) {
public function syncInstance(?\Closure $progressCallback = null) {
$systemAddressBook = $this->getLocalSystemAddressBook(); $systemAddressBook = $this->getLocalSystemAddressBook();
$this->userManager->callForAllUsers(function ($user) use ($systemAddressBook, $progressCallback) { $this->userManager->callForAllUsers(function ($user) use ($systemAddressBook, $progressCallback) {
$this->updateUser($user); $this->updateUser($user);

+ 3
- 3
apps/dav/lib/Command/MoveCalendar.php View File



$calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name); $calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name);


if (null === $calendar) {
if ($calendar === null) {
throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user."); throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user.");
} }


* Check if the calendar exists for user * Check if the calendar exists for user
*/ */
protected function calendarExists(string $userDestination, string $name): bool { protected function calendarExists(string $userDestination, string $name): bool {
return null !== $this->calDav->getCalendarByUri(self::URI_USERS . $userDestination, $name);
return $this->calDav->getCalendarByUri(self::URI_USERS . $userDestination, $name) !== null;
} }


/** /**
* Check that user destination is member of the groups which whom the calendar was shared * Check that user destination is member of the groups which whom the calendar was shared
* If we ask to force the migration, the share with the group is dropped * If we ask to force the migration, the share with the group is dropped
*/ */
if ($this->shareManager->shareWithGroupMembersOnly() === true && 'groups' === $prefix && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($this->shareManager->shareWithGroupMembersOnly() === true && $prefix === 'groups' && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($force) { if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]); $this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]);
} else { } else {

+ 1
- 1
apps/dav/lib/Comments/EntityCollection.php View File

* @param \DateTime|null $datetime * @param \DateTime|null $datetime
* @return CommentNode[] * @return CommentNode[]
*/ */
public function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) {
public function findChildren($limit = 0, $offset = 0, ?\DateTime $datetime = null) {
$comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime); $comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime);
$result = []; $result = [];
foreach ($comments as $comment) { foreach ($comments as $comment) {

+ 1
- 1
apps/dav/lib/Connector/Sabre/CachingTree.php View File

$path = trim($path, '/'); $path = trim($path, '/');
foreach ($this->cache as $nodePath => $node) { foreach ($this->cache as $nodePath => $node) {
$nodePath = (string) $nodePath; $nodePath = (string) $nodePath;
if ('' === $path || $nodePath == $path || str_starts_with($nodePath, $path . '/')) {
if ($path === '' || $nodePath == $path || str_starts_with($nodePath, $path . '/')) {
unset($this->cache[$nodePath]); unset($this->cache[$nodePath]);
} }
} }

+ 2
- 2
apps/dav/lib/Connector/Sabre/Directory.php View File

/** /**
* Sets up the node, expects a full path name * Sets up the node, expects a full path name
*/ */
public function __construct(View $view, FileInfo $info, ?CachingTree $tree = null, IShareManager $shareManager = null) {
public function __construct(View $view, FileInfo $info, ?CachingTree $tree = null, ?IShareManager $shareManager = null) {
parent::__construct($view, $info, $shareManager); parent::__construct($view, $info, $shareManager);
$this->tree = $tree; $this->tree = $tree;
} }
* @throws \Sabre\DAV\Exception\NotFound * @throws \Sabre\DAV\Exception\NotFound
* @throws \Sabre\DAV\Exception\ServiceUnavailable * @throws \Sabre\DAV\Exception\ServiceUnavailable
*/ */
public function getChild($name, $info = null, IRequest $request = null, IL10N $l10n = null) {
public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N $l10n = null) {
if (!$this->info->isReadable()) { if (!$this->info->isReadable()) {
// avoid detecting files through this way // avoid detecting files through this way
throw new NotFound(); throw new NotFound();

+ 1
- 1
apps/dav/lib/Connector/Sabre/Exception/FileLocked.php View File

use Exception; use Exception;


class FileLocked extends \Sabre\DAV\Exception { class FileLocked extends \Sabre\DAV\Exception {
public function __construct($message = "", $code = 0, Exception $previous = null) {
public function __construct($message = "", $code = 0, ?Exception $previous = null) {
if ($previous instanceof \OCP\Files\LockNotAcquiredException) { if ($previous instanceof \OCP\Files\LockNotAcquiredException) {
$message = sprintf('Target file %s is locked by another process.', $previous->path); $message = sprintf('Target file %s is locked by another process.', $previous->path);
} }

+ 1
- 1
apps/dav/lib/Connector/Sabre/Exception/Forbidden.php View File

* @param bool $retry * @param bool $retry
* @param \Exception $previous * @param \Exception $previous
*/ */
public function __construct($message, $retry = false, \Exception $previous = null) {
public function __construct($message, $retry = false, ?\Exception $previous = null) {
parent::__construct($message, 0, $previous); parent::__construct($message, 0, $previous);
$this->retry = $retry; $this->retry = $retry;
} }

+ 1
- 1
apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php View File

* @param bool $retry * @param bool $retry
* @param \Exception|null $previous * @param \Exception|null $previous
*/ */
public function __construct($message, $retry = false, \Exception $previous = null) {
public function __construct($message, $retry = false, ?\Exception $previous = null) {
parent::__construct($message, 0, $previous); parent::__construct($message, 0, $previous);
$this->retry = $retry; $this->retry = $retry;
} }

+ 1
- 1
apps/dav/lib/Connector/Sabre/File.php View File

* @param ?IRequest $request * @param ?IRequest $request
* @param ?IL10N $l10n * @param ?IL10N $l10n
*/ */
public function __construct(View $view, FileInfo $info, IManager $shareManager = null, IRequest $request = null, IL10N $l10n = null) {
public function __construct(View $view, FileInfo $info, ?IManager $shareManager = null, ?IRequest $request = null, ?IL10N $l10n = null) {
parent::__construct($view, $info, $shareManager); parent::__construct($view, $info, $shareManager);


if ($l10n) { if ($l10n) {

+ 2
- 2
apps/dav/lib/Connector/Sabre/FilesPlugin.php View File

*/ */
private function handleUpdatePropertiesMetadata(PropPatch $propPatch, Node $node): void { private function handleUpdatePropertiesMetadata(PropPatch $propPatch, Node $node): void {
$userId = $this->userSession->getUser()?->getUID(); $userId = $this->userSession->getUser()?->getUID();
if (null === $userId) {
if ($userId === null) {
return; return;
} }


* @param \Sabre\DAV\INode $node * @param \Sabre\DAV\INode $node
* @throws \Sabre\DAV\Exception\BadRequest * @throws \Sabre\DAV\Exception\BadRequest
*/ */
public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) {
public function sendFileIdHeader($filePath, ?\Sabre\DAV\INode $node = null) {
// chunked upload handling // chunked upload handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) { if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
[$path, $name] = \Sabre\Uri\split($filePath); [$path, $name] = \Sabre\Uri\split($filePath);

+ 1
- 1
apps/dav/lib/Connector/Sabre/Node.php View File

/** /**
* Sets up the node, expects a full path name * Sets up the node, expects a full path name
*/ */
public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
public function __construct(View $view, FileInfo $info, ?IManager $shareManager = null) {
$this->fileView = $view; $this->fileView = $view;
$this->path = $this->fileView->getRelativePath($info->getPath()); $this->path = $this->fileView->getRelativePath($info->getPath());
$this->info = $info; $this->info = $info;

+ 1
- 1
apps/dav/lib/DAV/Sharing/Xml/Invite.php View File

* *
* @param array $users * @param array $users
*/ */
public function __construct(array $users, array $organizer = null) {
public function __construct(array $users, ?array $organizer = null) {
$this->users = $users; $this->users = $users;
$this->organizer = $organizer; $this->organizer = $organizer;
} }

+ 1
- 1
apps/dav/lib/HookManager.php View File

} }
} }


public function firstLogin(IUser $user = null) {
public function firstLogin(?IUser $user = null) {
if (!is_null($user)) { if (!is_null($user)) {
$principal = 'principals/users/' . $user->getUID(); $principal = 'principals/users/' . $user->getUID();
if ($this->calDav->getCalendarsForUserCount($principal) === 0) { if ($this->calDav->getCalendarsForUserCount($principal) === 0) {

+ 1
- 1
apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php View File

* @param array|null $replyTo * @param array|null $replyTo
* @return IMessage * @return IMessage
*/ */
private function getMessageMock(string $toMail, IEMailTemplate $templateMock, array $replyTo = null):IMessage {
private function getMessageMock(string $toMail, IEMailTemplate $templateMock, ?array $replyTo = null):IMessage {
$message = $this->createMock(IMessage::class); $message = $this->createMock(IMessage::class);
$i = 0; $i = 0;



+ 23
- 23
apps/dav/tests/unit/CardDAV/CardDavBackendTest.php View File

public const UNIT_TEST_GROUP = 'principals/groups/carddav-unit-test-group'; public const UNIT_TEST_GROUP = 'principals/groups/carddav-unit-test-group';


private $vcardTest0 = 'BEGIN:VCARD'.PHP_EOL. private $vcardTest0 = 'BEGIN:VCARD'.PHP_EOL.
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test'.PHP_EOL.
'FN:Test'.PHP_EOL.
'N:Test;;;;'.PHP_EOL.
'END:VCARD';
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test'.PHP_EOL.
'FN:Test'.PHP_EOL.
'N:Test;;;;'.PHP_EOL.
'END:VCARD';


private $vcardTest1 = 'BEGIN:VCARD'.PHP_EOL. private $vcardTest1 = 'BEGIN:VCARD'.PHP_EOL.
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test2'.PHP_EOL.
'FN:Test2'.PHP_EOL.
'N:Test2;;;;'.PHP_EOL.
'END:VCARD';
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test2'.PHP_EOL.
'FN:Test2'.PHP_EOL.
'N:Test2;;;;'.PHP_EOL.
'END:VCARD';


private $vcardTest2 = 'BEGIN:VCARD'.PHP_EOL. private $vcardTest2 = 'BEGIN:VCARD'.PHP_EOL.
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test3'.PHP_EOL.
'FN:Test3'.PHP_EOL.
'N:Test3;;;;'.PHP_EOL.
'END:VCARD';
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'UID:Test3'.PHP_EOL.
'FN:Test3'.PHP_EOL.
'N:Test3;;;;'.PHP_EOL.
'END:VCARD';


private $vcardTestNoUID = 'BEGIN:VCARD'.PHP_EOL. private $vcardTestNoUID = 'BEGIN:VCARD'.PHP_EOL.
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'FN:TestNoUID'.PHP_EOL.
'N:TestNoUID;;;;'.PHP_EOL.
'END:VCARD';
'VERSION:3.0'.PHP_EOL.
'PRODID:-//Sabre//Sabre VObject 4.1.2//EN'.PHP_EOL.
'FN:TestNoUID'.PHP_EOL.
'N:TestNoUID;;;;'.PHP_EOL.
'END:VCARD';


protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();

+ 3
- 3
apps/dav/tests/unit/Connector/Sabre/FileTest.php View File

* *
* @return null|string of the PUT operation which is usually the etag * @return null|string of the PUT operation which is usually the etag
*/ */
private function doPut($path, $viewRoot = null, Request $request = null) {
private function doPut($path, $viewRoot = null, ?Request $request = null) {
$view = \OC\Files\Filesystem::getView(); $view = \OC\Files\Filesystem::getView();
if (!is_null($viewRoot)) { if (!is_null($viewRoot)) {
$view = new \OC\Files\View($viewRoot); $view = new \OC\Files\View($viewRoot);
* *
* @return array list of part files * @return array list of part files
*/ */
private function listPartFiles(\OC\Files\View $userView = null, $path = '') {
private function listPartFiles(?\OC\Files\View $userView = null, $path = '') {
if ($userView === null) { if ($userView === null) {
$userView = \OC\Files\Filesystem::getView(); $userView = \OC\Files\Filesystem::getView();
} }
* @param View $userView * @param View $userView
* @return array * @return array
*/ */
private function getFileInfos($path = '', View $userView = null) {
private function getFileInfos($path = '', ?View $userView = null) {
if ($userView === null) { if ($userView === null) {
$userView = Filesystem::getView(); $userView = Filesystem::getView();
} }

+ 1
- 1
apps/dav/tests/unit/Files/MultipartRequestParserTest.php View File



namespace OCA\DAV\Tests\unit\DAV; namespace OCA\DAV\Tests\unit\DAV;


use \OCA\DAV\BulkUpload\MultipartRequestParser;
use OCA\DAV\BulkUpload\MultipartRequestParser;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Test\TestCase; use Test\TestCase;



+ 3
- 3
apps/encryption/lib/Hooks/UserHooks.php View File

$this->logger->error('Encryption could not update users encryption password'); $this->logger->error('Encryption could not update users encryption password');
} }


// NOTE: Session does not need to be updated as the
// private key has not changed, only the passphrase
// used to decrypt it has changed
// NOTE: Session does not need to be updated as the
// private key has not changed, only the passphrase
// used to decrypt it has changed
} else { // admin changed the password for a different user, create new keys and re-encrypt file keys } else { // admin changed the password for a different user, create new keys and re-encrypt file keys
$userId = $params['uid']; $userId = $params['uid'];
$this->initMountPoints($userId); $this->initMountPoints($userId);

+ 2
- 2
apps/files/lib/Activity/FavoriteProvider.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') { if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getSubject() === self::SUBJECT_ADDED) { if ($event->getSubject() === self::SUBJECT_ADDED) {
$subject = $this->l->t('You added {file} to your favorites'); $subject = $this->l->t('You added {file} to your favorites');
if ($this->activityManager->getRequirePNG()) { if ($this->activityManager->getRequirePNG()) {

+ 4
- 4
apps/files/lib/Activity/Provider.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'files') { if ($event->getApp() !== 'files') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseShortVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseShortVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParameters($event); $parsedParameters = $this->getParameters($event);


if ($event->getSubject() === 'created_by') { if ($event->getSubject() === 'created_by') {
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$this->fileIsEncrypted = false; $this->fileIsEncrypted = false;
$parsedParameters = $this->getParameters($event); $parsedParameters = $this->getParameters($event);


* @return array * @return array
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function getFile($parameter, IEvent $event = null) {
protected function getFile($parameter, ?IEvent $event = null) {
if (is_array($parameter)) { if (is_array($parameter)) {
$path = reset($parameter); $path = reset($parameter);
$id = (string) key($parameter); $id = (string) key($parameter);

+ 1
- 1
apps/files/lib/Collaboration/Resources/ResourceProvider.php View File

* @return bool * @return bool
* @since 16.0.0 * @since 16.0.0
*/ */
public function canAccessResource(IResource $resource, IUser $user = null): bool {
public function canAccessResource(IResource $resource, ?IUser $user = null): bool {
if (!$user instanceof IUser) { if (!$user instanceof IUser) {
return false; return false;
} }

+ 2
- 2
apps/files/lib/Controller/DirectEditingController.php View File

* 200: URL for direct editing returned * 200: URL for direct editing returned
* 403: Opening file is not allowed * 403: Opening file is not allowed
*/ */
public function create(string $path, string $editorId, string $creatorId, string $templateId = null): DataResponse {
public function create(string $path, string $editorId, string $creatorId, ?string $templateId = null): DataResponse {
if (!$this->directEditingManager->isEnabled()) { if (!$this->directEditingManager->isEnabled()) {
return new DataResponse(['message' => 'Direct editing is not enabled'], Http::STATUS_INTERNAL_SERVER_ERROR); return new DataResponse(['message' => 'Direct editing is not enabled'], Http::STATUS_INTERNAL_SERVER_ERROR);
} }
* 200: URL for direct editing returned * 200: URL for direct editing returned
* 403: Opening file is not allowed * 403: Opening file is not allowed
*/ */
public function open(string $path, string $editorId = null, ?int $fileId = null): DataResponse {
public function open(string $path, ?string $editorId = null, ?int $fileId = null): DataResponse {
if (!$this->directEditingManager->isEnabled()) { if (!$this->directEditingManager->isEnabled()) {
return new DataResponse(['message' => 'Direct editing is not enabled'], Http::STATUS_INTERNAL_SERVER_ERROR); return new DataResponse(['message' => 'Direct editing is not enabled'], Http::STATUS_INTERNAL_SERVER_ERROR);
} }

+ 1
- 1
apps/files/lib/Controller/ViewController.php View File

* @param string $fileid * @param string $fileid
* @return TemplateResponse|RedirectResponse * @return TemplateResponse|RedirectResponse
*/ */
public function showFile(string $fileid = null): Response {
public function showFile(?string $fileid = null): Response {
if (!$fileid) { if (!$fileid) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index')); return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index'));
} }

+ 1
- 1
apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php View File

]); ]);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) { if ($storage->getType() === StorageConfig::MOUNT_TYPE_ADMIN) {
$uid = ''; $uid = '';
} elseif (is_null($user)) { } elseif (is_null($user)) {

+ 1
- 1
apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php View File

return $credentials; return $credentials;
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
if (!isset($user)) { if (!isset($user)) {
throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved'); throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
} }

+ 1
- 1
apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php View File

->addParameters([]); ->addParameters([]);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
try { try {
$credentials = $this->credentialsStore->getLoginCredentials(); $credentials = $this->credentialsStore->getLoginCredentials();
} catch (CredentialsUnavailableException $e) { } catch (CredentialsUnavailableException $e) {

+ 1
- 1
apps/files_external/lib/Lib/Auth/Password/UserGlobalAuth.php View File

$this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials); $this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
if ($user === null) { if ($user === null) {
throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
} }

+ 1
- 1
apps/files_external/lib/Lib/Auth/Password/UserProvided.php View File

]); ]);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
if (!isset($user)) { if (!isset($user)) {
throw new InsufficientDataForMeaningfulAnswerException('No credentials saved'); throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
} }

+ 1
- 1
apps/files_external/lib/Lib/Auth/PublicKey/RSA.php View File

; ;
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
$auth = new RSACrypt(); $auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', '')); $auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) { if (!$auth->loadKey($storage->getBackendOption('private_key'))) {

+ 1
- 1
apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php View File

]); ]);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
$auth = new RSACrypt(); $auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', '')); $auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) { if (!$auth->loadKey($storage->getBackendOption('private_key'))) {

+ 1
- 1
apps/files_external/lib/Lib/Backend/InvalidBackend.php View File

return $this->invalidId; return $this->invalidId;
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
$storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR));
} }
} }

+ 1
- 1
apps/files_external/lib/Lib/Backend/Local.php View File

; ;
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null): void {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null): void {
$storage->setBackendOption('isExternal', true); $storage->setBackendOption('isExternal', true);
} }
} }

+ 1
- 1
apps/files_external/lib/Lib/Backend/SMB.php View File

->setLegacyAuthMechanism($legacyAuth); ->setLegacyAuthMechanism($legacyAuth);
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
$auth = $storage->getAuthMechanism(); $auth = $storage->getAuthMechanism();
if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) { if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) {
if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) { if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) {

+ 1
- 1
apps/files_external/lib/Lib/Backend/SMB_OC.php View File

; ;
} }


public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
$username_as_share = ($storage->getBackendOption('username_as_share') === true); $username_as_share = ($storage->getBackendOption('username_as_share') === true);


if ($username_as_share) { if ($username_as_share) {

+ 1
- 1
apps/files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php View File

* @param \Exception|null $previous * @param \Exception|null $previous
* @since 6.0.0 * @since 6.0.0
*/ */
public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
public function __construct($message = '', $code = self::STATUS_INDETERMINATE, ?\Exception $previous = null) {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }

+ 1
- 1
apps/files_external/lib/Lib/Storage/FTP.php View File

return false; return false;
} }


public function writeStream(string $path, $stream, int $size = null): int {
public function writeStream(string $path, $stream, ?int $size = null): int {
if ($size === null) { if ($size === null) {
$stream = CountWrapper::wrap($stream, function ($writtenSize) use (&$size) { $stream = CountWrapper::wrap($stream, function ($writtenSize) use (&$size) {
$size = $writtenSize; $size = $writtenSize;

+ 1
- 1
apps/files_external/lib/Lib/Storage/SFTP.php View File

} }
} }


public function writeStream(string $path, $stream, int $size = null): int {
public function writeStream(string $path, $stream, ?int $size = null): int {
if ($size === null) { if ($size === null) {
$stream = CountWrapper::wrap($stream, function (int $writtenSize) use (&$size) { $stream = CountWrapper::wrap($stream, function (int $writtenSize) use (&$size) {
$size = $writtenSize; $size = $writtenSize;

+ 1
- 1
apps/files_external/lib/Lib/StorageModifierTrait.php View File

* @throws InsufficientDataForMeaningfulAnswerException * @throws InsufficientDataForMeaningfulAnswerException
* @throws StorageNotAvailableException * @throws StorageNotAvailableException
*/ */
public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
} }


/** /**

+ 1
- 1
apps/files_external/lib/MountConfig.php View File

* @throws \OCP\AppFramework\QueryException * @throws \OCP\AppFramework\QueryException
* @since 16.0.0 * @since 16.0.0
*/ */
public static function substitutePlaceholdersInConfig($input, string $userId = null) {
public static function substitutePlaceholdersInConfig($input, ?string $userId = null) {
/** @var BackendService $backendService */ /** @var BackendService $backendService */
$backendService = \OC::$server->get(BackendService::class); $backendService = \OC::$server->get(BackendService::class);
/** @var IConfigHandler[] $handlers */ /** @var IConfigHandler[] $handlers */

+ 1
- 1
apps/files_external/lib/Service/UserGlobalStoragesService.php View File

* @param IUser|null $user user to get the storages for, if not set the currently logged in user will be used * @param IUser|null $user user to get the storages for, if not set the currently logged in user will be used
* @return StorageConfig[] array of storage configs * @return StorageConfig[] array of storage configs
*/ */
public function getAllStoragesForUser(IUser $user = null) {
public function getAllStoragesForUser(?IUser $user = null) {
if (is_null($user)) { if (is_null($user)) {
$user = $this->getUser(); $user = $this->getUser();
} }

+ 4
- 4
apps/files_external/templates/settings.php View File

<?php <?php
use \OCA\Files_External\Lib\Auth\AuthMechanism;
use \OCA\Files_External\Lib\Backend\Backend;
use \OCA\Files_External\Lib\DefinitionParameter;
use \OCA\Files_External\Service\BackendService;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Service\BackendService;


/** @var array $_ */ /** @var array $_ */



+ 3
- 3
apps/files_sharing/lib/Activity/Providers/Base.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'files_sharing') { if ($event->getApp() !== 'files_sharing') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
abstract protected function parseLongVersion(IEvent $event, IEvent $previousEvent = null);
abstract protected function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null);


/** /**
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return array * @return array
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
protected function getFile($parameter, IEvent $event = null) {
protected function getFile($parameter, ?IEvent $event = null) {
if (is_array($parameter)) { if (is_array($parameter)) {
$path = reset($parameter); $path = reset($parameter);
$id = (string) key($parameter); $id = (string) key($parameter);

+ 1
- 1
apps/files_sharing/lib/Activity/Providers/Downloads.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event); $parsedParameters = $this->getParsedParameters($event);


if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED || if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED ||

+ 1
- 1
apps/files_sharing/lib/Activity/Providers/Groups.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event); $parsedParameters = $this->getParsedParameters($event);


if ($event->getSubject() === self::SUBJECT_SHARED_GROUP_SELF) { if ($event->getSubject() === self::SUBJECT_SHARED_GROUP_SELF) {

+ 1
- 1
apps/files_sharing/lib/Activity/Providers/PublicLinks.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event); $parsedParameters = $this->getParsedParameters($event);


if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) { if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) {

+ 1
- 1
apps/files_sharing/lib/Activity/Providers/RemoteShares.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event); $parsedParameters = $this->getParsedParameters($event);


if ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_RECEIVED) { if ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_RECEIVED) {

+ 1
- 1
apps/files_sharing/lib/Activity/Providers/Users.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) {
public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
$parsedParameters = $this->getParsedParameters($event); $parsedParameters = $this->getParsedParameters($event);


if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) { if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) {

+ 16
- 16
apps/files_sharing/lib/Controller/ShareAPIController.php View File

IUserManager $userManager, IUserManager $userManager,
IRootFolder $rootFolder, IRootFolder $rootFolder,
IURLGenerator $urlGenerator, IURLGenerator $urlGenerator,
string $userId = null,
?string $userId = null,
IL10N $l10n, IL10N $l10n,
IConfig $config, IConfig $config,
IAppManager $appManager, IAppManager $appManager,
* *
* @suppress PhanUndeclaredClassMethod * @suppress PhanUndeclaredClassMethod
*/ */
protected function formatShare(IShare $share, Node $recipientNode = null): array {
protected function formatShare(IShare $share, ?Node $recipientNode = null): array {
$sharedBy = $this->userManager->get($share->getSharedBy()); $sharedBy = $this->userManager->get($share->getSharedBy());
$shareOwner = $this->userManager->get($share->getShareOwner()); $shareOwner = $this->userManager->get($share->getShareOwner());


* 200: Share created * 200: Share created
*/ */
public function createShare( public function createShare(
string $path = null,
int $permissions = null,
?string $path = null,
?int $permissions = null,
int $shareType = -1, int $shareType = -1,
string $shareWith = null,
?string $shareWith = null,
string $publicUpload = 'false', string $publicUpload = 'false',
string $password = '', string $password = '',
string $sendPasswordByTalk = null,
?string $sendPasswordByTalk = null,
string $expireDate = '', string $expireDate = '',
string $note = '', string $note = '',
string $label = '', string $label = '',
string $attributes = null
?string $attributes = null
): DataResponse { ): DataResponse {
$share = $this->shareManager->newShare(); $share = $this->shareManager->newShare();


*/ */
public function updateShare( public function updateShare(
string $id, string $id,
int $permissions = null,
string $password = null,
string $sendPasswordByTalk = null,
string $publicUpload = null,
string $expireDate = null,
string $note = null,
string $label = null,
string $hideDownload = null,
string $attributes = null
?int $permissions = null,
?string $password = null,
?string $sendPasswordByTalk = null,
?string $publicUpload = null,
?string $expireDate = null,
?string $note = null,
?string $label = null,
?string $hideDownload = null,
?string $attributes = null
): DataResponse { ): DataResponse {
try { try {
$share = $this->getShareById($id); $share = $this->getShareById($id);

+ 1
- 1
apps/files_sharing/lib/Controller/ShareesAPIController.php View File

* *
* 200: Sharees search result returned * 200: Sharees search result returned
*/ */
public function search(string $search = '', string $itemType = null, int $page = 1, int $perPage = 200, $shareType = null, bool $lookup = false): DataResponse {
public function search(string $search = '', ?string $itemType = null, int $page = 1, int $perPage = 200, $shareType = null, bool $lookup = false): DataResponse {


// only search for string larger than a given threshold // only search for string larger than a given threshold
$threshold = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0); $threshold = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0);

+ 1
- 1
apps/files_sharing/lib/External/Storage.php View File



$host = parse_url($remote, PHP_URL_HOST); $host = parse_url($remote, PHP_URL_HOST);
$port = parse_url($remote, PHP_URL_PORT); $port = parse_url($remote, PHP_URL_PORT);
$host .= (null === $port) ? '' : ':' . $port; // we add port if available
$host .= ($port === null) ? '' : ':' . $port; // we add port if available


// in case remote NC is on a sub folder and using deprecated ocm provider // in case remote NC is on a sub folder and using deprecated ocm provider
$tmpPath = rtrim(parse_url($this->cloudId->getRemote(), PHP_URL_PATH) ?? '', '/'); $tmpPath = rtrim(parse_url($this->cloudId->getRemote(), PHP_URL_PATH) ?? '', '/');

+ 1
- 1
apps/files_sharing/lib/Helper.php View File

* @param string|null $userId * @param string|null $userId
* @return string * @return string
*/ */
public static function getShareFolder(View $view = null, string $userId = null): string {
public static function getShareFolder(?View $view = null, ?string $userId = null): string {
if ($view === null) { if ($view === null) {
$view = Filesystem::getView(); $view = Filesystem::getView();
} }

+ 1
- 1
apps/files_sharing/lib/ShareBackend/File.php View File

/** @var FederatedShareProvider */ /** @var FederatedShareProvider */
private $federatedShareProvider; private $federatedShareProvider;


public function __construct(FederatedShareProvider $federatedShareProvider = null) {
public function __construct(?FederatedShareProvider $federatedShareProvider = null) {
if ($federatedShareProvider) { if ($federatedShareProvider) {
$this->federatedShareProvider = $federatedShareProvider; $this->federatedShareProvider = $federatedShareProvider;
} else { } else {

+ 2
- 2
apps/files_trashbin/lib/Command/ExpireTrash.php View File

* @param IUserManager|null $userManager * @param IUserManager|null $userManager
* @param Expiration|null $expiration * @param Expiration|null $expiration
*/ */
public function __construct(IUserManager $userManager = null,
Expiration $expiration = null) {
public function __construct(?IUserManager $userManager = null,
?Expiration $expiration = null) {
parent::__construct(); parent::__construct();


$this->userManager = $userManager; $this->userManager = $userManager;

+ 1
- 1
apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php View File

/** /**
* @return never * @return never
*/ */
public function abortOperation(\Throwable $ex = null) {
public function abortOperation(?\Throwable $ex = null) {
$this->stopPropagation(); $this->stopPropagation();
$this->run = false; $this->run = false;
if ($ex !== null) { if ($ex !== null) {

+ 5
- 5
apps/files_trashbin/lib/Storage.php View File

*/ */
public function __construct( public function __construct(
$parameters, $parameters,
ITrashManager $trashManager = null,
IUserManager $userManager = null,
LoggerInterface $logger = null,
IEventDispatcher $eventDispatcher = null,
IRootFolder $rootFolder = null
?ITrashManager $trashManager = null,
?IUserManager $userManager = null,
?LoggerInterface $logger = null,
?IEventDispatcher $eventDispatcher = null,
?IRootFolder $rootFolder = null
) { ) {
$this->mountPoint = $parameters['mountPoint']; $this->mountPoint = $parameters['mountPoint'];
$this->trashManager = $trashManager; $this->trashManager = $trashManager;

+ 1
- 1
apps/files_trashbin/lib/Trash/LegacyTrashBackend.php View File

* @param ITrashItem $parent * @param ITrashItem $parent
* @return ITrashItem[] * @return ITrashItem[]
*/ */
private function mapTrashItems(array $items, IUser $user, ITrashItem $parent = null): array {
private function mapTrashItems(array $items, IUser $user, ?ITrashItem $parent = null): array {
$parentTrashPath = ($parent instanceof ITrashItem) ? $parent->getTrashPath() : ''; $parentTrashPath = ($parent instanceof ITrashItem) ? $parent->getTrashPath() : '';
$isRoot = $parent === null; $isRoot = $parent === null;
return array_map(function (FileInfo $file) use ($parent, $parentTrashPath, $isRoot, $user) { return array_map(function (FileInfo $file) use ($parent, $parentTrashPath, $isRoot, $user) {

+ 2
- 2
apps/provisioning_api/lib/Controller/GroupsController.php View File

* *
* 200: Groups details returned * 200: Groups details returned
*/ */
public function getGroupsDetails(string $search = '', int $limit = null, int $offset = 0): DataResponse {
public function getGroupsDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset); $groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) { $groups = array_map(function ($group) {
/** @var IGroup $group */ /** @var IGroup $group */
* *
* 200: Group users details returned * 200: Group users details returned
*/ */
public function getGroupUsersDetails(string $groupId, string $search = '', int $limit = null, int $offset = 0): DataResponse {
public function getGroupUsersDetails(string $groupId, string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groupId = urldecode($groupId); $groupId = urldecode($groupId);
$currentUser = $this->userSession->getUser(); $currentUser = $this->userSession->getUser();



+ 2
- 2
apps/provisioning_api/lib/Controller/UsersController.php View File

* *
* 200: Users returned * 200: Users returned
*/ */
public function getUsers(string $search = '', int $limit = null, int $offset = 0): DataResponse {
public function getUsers(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$user = $this->userSession->getUser(); $user = $this->userSession->getUser();
$users = []; $users = [];


* *
* 200: Users details returned * 200: Users details returned
*/ */
public function getUsersDetails(string $search = '', int $limit = null, int $offset = 0): DataResponse {
public function getUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$currentUser = $this->userSession->getUser(); $currentUser = $this->userSession->getUser();
$users = []; $users = [];



+ 1
- 1
apps/settings/lib/Activity/GroupProvider.php View File

$this->groupManager = $groupManager; $this->groupManager = $groupManager;
} }


public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getType() !== 'group_settings') { if ($event->getType() !== 'group_settings') {
throw new InvalidArgumentException(); throw new InvalidArgumentException();
} }

+ 1
- 1
apps/settings/lib/Activity/Provider.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'settings') { if ($event->getApp() !== 'settings') {
throw new \InvalidArgumentException('Unknown app'); throw new \InvalidArgumentException('Unknown app');
} }

+ 1
- 1
apps/settings/lib/Activity/SecurityProvider.php View File

$this->activityManager = $activityManager; $this->activityManager = $activityManager;
} }


public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getType() !== 'security') { if ($event->getType() !== 'security') {
throw new InvalidArgumentException(); throw new InvalidArgumentException();
} }

+ 2
- 2
apps/settings/lib/Controller/ChangePasswordController.php View File

* @NoSubAdminRequired * @NoSubAdminRequired
* @BruteForceProtection(action=changePersonalPassword) * @BruteForceProtection(action=changePersonalPassword)
*/ */
public function changePersonalPassword(string $oldpassword = '', string $newpassword = null): JSONResponse {
public function changePersonalPassword(string $oldpassword = '', ?string $newpassword = null): JSONResponse {
$loginName = $this->userSession->getLoginName(); $loginName = $this->userSession->getLoginName();
/** @var IUser $user */ /** @var IUser $user */
$user = $this->userManager->checkPassword($loginName, $oldpassword); $user = $this->userManager->checkPassword($loginName, $oldpassword);
* @NoAdminRequired * @NoAdminRequired
* @PasswordConfirmationRequired * @PasswordConfirmationRequired
*/ */
public function changeUserPassword(string $username = null, string $password = null, string $recoveryPassword = null): JSONResponse {
public function changeUserPassword(?string $username = null, ?string $password = null, ?string $recoveryPassword = null): JSONResponse {
if ($username === null) { if ($username === null) {
return new JSONResponse([ return new JSONResponse([
'status' => 'error', 'status' => 'error',

+ 2
- 2
apps/settings/lib/Controller/UsersController.php View File

continue; continue;
} }
$property = $userAccount->getProperty($property); $property = $userAccount->getProperty($property);
if (null !== $data['value']) {
if ($data['value'] !== null) {
$property->setValue($data['value']); $property->setValue($data['value']);
} }
if (null !== $data['scope']) {
if ($data['scope'] !== null) {
$property->setScope($data['scope']); $property->setScope($data['scope']);
} }
} }

+ 1
- 1
apps/settings/lib/Mailer/NewUserMailHelper.php View File

ISecureRandom::CHAR_ALPHANUMERIC ISecureRandom::CHAR_ALPHANUMERIC
); );
$tokenValue = $this->timeFactory->getTime() . ':' . $token; $tokenValue = $this->timeFactory->getTime() . ':' . $token;
$mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : '';
$mailAddress = ($user->getEMailAddress() !== null) ? $user->getEMailAddress() : '';
$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret')); $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret'));
$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue); $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]); $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]);

+ 1
- 1
apps/settings/lib/SetupChecks/PhpOpcacheSetup.php View File



if ( if (
// Do not recommend to raise the interned strings buffer size above a quarter of the total OPcache size // Do not recommend to raise the interned strings buffer size above a quarter of the total OPcache size
($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') ?? 0 < $this->iniGetWrapper->getNumeric('opcache.memory_consumption') ?? 0 / 4) &&
($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') ?? $this->iniGetWrapper->getNumeric('opcache.memory_consumption') > 0 ?? 0 / 4) &&
( (
empty($status['interned_strings_usage']['free_memory']) || empty($status['interned_strings_usage']['free_memory']) ||
($status['interned_strings_usage']['used_memory'] / $status['interned_strings_usage']['free_memory'] > 9) ($status['interned_strings_usage']['used_memory'] / $status['interned_strings_usage']['free_memory'] > 9)

+ 1
- 2
apps/settings/templates/settings/personal/security/twofactor.php View File

//Handle 2FA provider icons and theme //Handle 2FA provider icons and theme
if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
$icon = $provider->getDarkIcon(); $icon = $provider->getDarkIcon();
//fallback icon if the 2factor provider doesn't provide an icon.
//fallback icon if the 2factor provider doesn't provide an icon.
} else { } else {
$icon = image_path('core', 'actions/password.svg'); $icon = image_path('core', 'actions/password.svg');
} }
<?php } ?> <?php } ?>
</ul> </ul>
</div> </div>


+ 1
- 1
apps/sharebymail/lib/Activity.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'sharebymail') { if ($event->getApp() !== 'sharebymail') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/systemtags/lib/Activity/Provider.php View File

* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @since 11.0.0 * @since 11.0.0
*/ */
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'systemtags') { if ($event->getApp() !== 'systemtags') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }

+ 1
- 1
apps/testing/lib/Controller/LockingController.php View File

throw new OCSException('', Http::STATUS_LOCKED); throw new OCSException('', Http::STATUS_LOCKED);
} }


public function releaseAll(int $type = null): DataResponse {
public function releaseAll(?int $type = null): DataResponse {
$lockingProvider = $this->getLockingProvider(); $lockingProvider = $this->getLockingProvider();


foreach ($this->config->getAppKeys('testing') as $lock) { foreach ($this->config->getAppKeys('testing') as $lock) {

+ 1
- 1
apps/theming/lib/Controller/UserThemeController.php View File

* 200: Background set successfully * 200: Background set successfully
* 400: Setting background is not possible * 400: Setting background is not possible
*/ */
public function setBackground(string $type = BackgroundService::BACKGROUND_DEFAULT, string $value = '', string $color = null): JSONResponse {
public function setBackground(string $type = BackgroundService::BACKGROUND_DEFAULT, string $value = '', ?string $color = null): JSONResponse {
$currentVersion = (int)$this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0'); $currentVersion = (int)$this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0');


// Set color if provided // Set color if provided

+ 1
- 1
apps/theming/lib/Service/ThemeInjectionService.php View File

* @param bool $plain request the :root syntax * @param bool $plain request the :root syntax
* @param string $media media query to use in the <link> element * @param string $media media query to use in the <link> element
*/ */
private function addThemeHeaders(ITheme $theme, bool $plain = true, string $media = null): void {
private function addThemeHeaders(ITheme $theme, bool $plain = true, ?string $media = null): void {
$linkToCSS = $this->urlGenerator->linkToRoute('theming.Theming.getThemeStylesheet', [ $linkToCSS = $this->urlGenerator->linkToRoute('theming.Theming.getThemeStylesheet', [
'themeId' => $theme->getId(), 'themeId' => $theme->getId(),
'plain' => $plain, 'plain' => $plain,

+ 2
- 2
apps/theming/tests/Controller/UserThemeControllerTest.php View File

* @param string $themeId * @param string $themeId
* @param string $exception * @param string $exception
*/ */
public function testEnableTheme($themeId, string $exception = null) {
public function testEnableTheme($themeId, ?string $exception = null) {
$this->themesService $this->themesService
->expects($this->any()) ->expects($this->any())
->method('getThemes') ->method('getThemes')
* @param string $themeId * @param string $themeId
* @param string $exception * @param string $exception
*/ */
public function testDisableTheme($themeId, string $exception = null) {
public function testDisableTheme($themeId, ?string $exception = null) {
$this->themesService $this->themesService
->expects($this->any()) ->expects($this->any())
->method('getThemes') ->method('getThemes')

+ 1
- 1
apps/twofactor_backupcodes/lib/Activity/Provider.php View File

$this->l10n = $l10n; $this->l10n = $l10n;
} }


public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'twofactor_backupcodes') { if ($event->getApp() !== 'twofactor_backupcodes') {
throw new InvalidArgumentException(); throw new InvalidArgumentException();
} }

+ 2
- 2
apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php View File

$total = count($codes); $total = count($codes);
$used = 0; $used = 0;
array_walk($codes, function (BackupCode $code) use (&$used) { array_walk($codes, function (BackupCode $code) use (&$used) {
if (1 === (int)$code->getUsed()) {
if ((int)$code->getUsed() === 1) {
$used++; $used++;
} }
}); });
$dbCodes = $this->mapper->getBackupCodes($user); $dbCodes = $this->mapper->getBackupCodes($user);


foreach ($dbCodes as $dbCode) { foreach ($dbCodes as $dbCode) {
if (0 === (int)$dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) {
if ((int)$dbCode->getUsed() === 0 && $this->hasher->verify($code, $dbCode->getCode())) {
$dbCode->setUsed(1); $dbCode->setUsed(1);
$this->mapper->update($dbCode); $this->mapper->update($dbCode);
return true; return true;

+ 16
- 16
apps/user_ldap/lib/Access.php View File

* @return false|string with with the name to use in Nextcloud * @return false|string with with the name to use in Nextcloud
* @throws \Exception * @throws \Exception
*/ */
public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, array $record = null) {
public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, ?array $record = null) {
static $intermediates = []; static $intermediates = [];
if (isset($intermediates[($isUser ? 'user-' : 'group-') . $fdn])) { if (isset($intermediates[($isUser ? 'user-' : 'group-') . $fdn])) {
return false; // is a known intermediate return false; // is a known intermediate
/** /**
* @throws \Exception * @throws \Exception
*/ */
public function fetchListOfUsers(string $filter, array $attr, int $limit = null, int $offset = null, bool $forceApplyAttributes = false): array {
public function fetchListOfUsers(string $filter, array $attr, ?int $limit = null, ?int $offset = null, bool $forceApplyAttributes = false): array {
$ldapRecords = $this->searchUsers($filter, $attr, $limit, $offset); $ldapRecords = $this->searchUsers($filter, $attr, $limit, $offset);
$recordsToUpdate = $ldapRecords; $recordsToUpdate = $ldapRecords;
if (!$forceApplyAttributes) { if (!$forceApplyAttributes) {
/** /**
* @return array[] * @return array[]
*/ */
public function fetchListOfGroups(string $filter, array $attr, int $limit = null, int $offset = null): array {
public function fetchListOfGroups(string $filter, array $attr, ?int $limit = null, ?int $offset = null): array {
$cacheKey = 'fetchListOfGroups_' . $filter . '_' . implode('-', $attr) . '_' . (string)$limit . '_' . (string)$offset; $cacheKey = 'fetchListOfGroups_' . $filter . '_' . implode('-', $attr) . '_' . (string)$limit . '_' . (string)$offset;
$listOfGroups = $this->connection->getFromCache($cacheKey); $listOfGroups = $this->connection->getFromCache($cacheKey);
if (!is_null($listOfGroups)) { if (!is_null($listOfGroups)) {
/** /**
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function searchUsers(string $filter, array $attr = null, int $limit = null, int $offset = null): array {
public function searchUsers(string $filter, ?array $attr = null, ?int $limit = null, ?int $offset = null): array {
$result = []; $result = [];
foreach ($this->connection->ldapBaseUsers as $base) { foreach ($this->connection->ldapBaseUsers as $base) {
$result = array_merge($result, $this->search($filter, $base, $attr, $limit, $offset)); $result = array_merge($result, $this->search($filter, $base, $attr, $limit, $offset));
* @return false|int * @return false|int
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function countUsers(string $filter, array $attr = ['dn'], int $limit = null, int $offset = null) {
public function countUsers(string $filter, array $attr = ['dn'], ?int $limit = null, ?int $offset = null) {
$result = false; $result = false;
foreach ($this->connection->ldapBaseUsers as $base) { foreach ($this->connection->ldapBaseUsers as $base) {
$count = $this->count($filter, [$base], $attr, $limit ?? 0, $offset ?? 0); $count = $this->count($filter, [$base], $attr, $limit ?? 0, $offset ?? 0);
* Executes an LDAP search * Executes an LDAP search
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function searchGroups(string $filter, array $attr = null, int $limit = null, int $offset = null): array {
public function searchGroups(string $filter, ?array $attr = null, ?int $limit = null, ?int $offset = null): array {
$result = []; $result = [];
foreach ($this->connection->ldapBaseGroups as $base) { foreach ($this->connection->ldapBaseGroups as $base) {
$result = array_merge($result, $this->search($filter, $base, $attr, $limit, $offset)); $result = array_merge($result, $this->search($filter, $base, $attr, $limit, $offset));
* @return int|bool * @return int|bool
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function countGroups(string $filter, array $attr = ['dn'], int $limit = null, int $offset = null) {
public function countGroups(string $filter, array $attr = ['dn'], ?int $limit = null, ?int $offset = null) {
$result = false; $result = false;
foreach ($this->connection->ldapBaseGroups as $base) { foreach ($this->connection->ldapBaseGroups as $base) {
$count = $this->count($filter, [$base], $attr, $limit ?? 0, $offset ?? 0); $count = $this->count($filter, [$base], $attr, $limit ?? 0, $offset ?? 0);
* @return int|bool * @return int|bool
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function countObjects(int $limit = null, int $offset = null) {
public function countObjects(?int $limit = null, ?int $offset = null) {
$result = false; $result = false;
foreach ($this->connection->ldapBase as $base) { foreach ($this->connection->ldapBase as $base) {
$count = $this->count('objectclass=*', [$base], ['dn'], $limit ?? 0, $offset ?? 0); $count = $this->count('objectclass=*', [$base], ['dn'], $limit ?? 0, $offset ?? 0);
private function count( private function count(
string $filter, string $filter,
array $bases, array $bases,
array $attr = null,
?array $attr = null,
int $limit = 0, int $limit = 0,
int $offset = 0, int $offset = 0,
bool $skipHandling = false bool $skipHandling = false
* @return false|string * @return false|string
* @throws ServerNotAvailableException * @throws ServerNotAvailableException
*/ */
public function getUUID(string $dn, bool $isUser = true, array $ldapRecord = null) {
public function getUUID(string $dn, bool $isUser = true, ?array $ldapRecord = null) {
if ($isUser) { if ($isUser) {
$uuidAttr = 'ldapUuidUserAttribute'; $uuidAttr = 'ldapUuidUserAttribute';
$uuidOverride = $this->connection->ldapExpertUUIDUserAttr; $uuidOverride = $this->connection->ldapExpertUUIDUserAttr;
} }
$this->logger->debug('Ready for a paged search', ['app' => 'user_ldap']); $this->logger->debug('Ready for a paged search', ['app' => 'user_ldap']);
return [true, $pageSize, $this->lastCookie]; return [true, $pageSize, $this->lastCookie];
/* ++ Fixing RHDS searches with pages with zero results ++
* We couldn't get paged searches working with our RHDS for login ($limit = 0),
* due to pages with zero results.
* So we added "&& !empty($this->lastCookie)" to this test to ignore pagination
* if we don't have a previous paged search.
*/
/* ++ Fixing RHDS searches with pages with zero results ++
* We couldn't get paged searches working with our RHDS for login ($limit = 0),
* due to pages with zero results.
* So we added "&& !empty($this->lastCookie)" to this test to ignore pagination
* if we don't have a previous paged search.
*/
} elseif ($this->lastCookie !== '') { } elseif ($this->lastCookie !== '') {
// a search without limit was requested. However, if we do use // a search without limit was requested. However, if we do use
// Paged Search once, we always must do it. This requires us to // Paged Search once, we always must do it. This requires us to

+ 1
- 1
apps/user_ldap/lib/Configuration.php View File

* array * array
* @param array &$applied optional; array where the set fields will be given to * @param array &$applied optional; array where the set fields will be given to
*/ */
public function setConfiguration(array $config, array &$applied = null): void {
public function setConfiguration(array $config, ?array &$applied = null): void {
$cta = $this->getConfigTranslationArray(); $cta = $this->getConfigTranslationArray();
foreach ($config as $inputKey => $val) { foreach ($config as $inputKey => $val) {
if (str_contains($inputKey, '_') && array_key_exists($inputKey, $cta)) { if (str_contains($inputKey, '_') && array_key_exists($inputKey, $cta)) {

+ 1
- 1
apps/user_ldap/lib/Connection.php View File

* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
public function writeToCache($key, $value, int $ttlOverride = null): void {
public function writeToCache($key, $value, ?int $ttlOverride = null): void {
if (!$this->configured) { if (!$this->configured) {
$this->readConfiguration(); $this->readConfiguration();
} }

+ 1
- 1
apps/user_ldap/lib/DataCollector/LdapDataCollector.php View File

return 'ldap'; return 'ldap';
} }


public function collect(Request $request, Response $response, \Throwable $exception = null): void {
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void {
} }
} }

+ 1
- 1
apps/user_ldap/lib/Jobs/Sync.php View File

* @param array|null $cycleData the old cycle * @param array|null $cycleData the old cycle
* @return array|null * @return array|null
*/ */
public function determineNextCycle(array $cycleData = null) {
public function determineNextCycle(?array $cycleData = null) {
$prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true); $prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true);
if (count($prefixes) === 0) { if (count($prefixes) === 0) {
return null; return null;

+ 1
- 1
apps/user_ldap/lib/Mapping/AbstractMapping.php View File

return $this->getXbyY('directory_uuid', 'ldap_dn_hash', $this->getDNHash($dn)); return $this->getXbyY('directory_uuid', 'ldap_dn_hash', $this->getDNHash($dn));
} }


public function getList(int $offset = 0, int $limit = null, bool $invalidatedOnly = false): array {
public function getList(int $offset = 0, ?int $limit = null, bool $invalidatedOnly = false): array {
$select = $this->dbc->getQueryBuilder(); $select = $this->dbc->getQueryBuilder();
$select->selectAlias('ldap_dn', 'dn') $select->selectAlias('ldap_dn', 'dn')
->selectAlias('owncloud_name', 'name') ->selectAlias('owncloud_name', 'name')

+ 6
- 6
apps/user_ldap/lib/User/User.php View File

($profileCached === null) && // no cache or TTL not expired ($profileCached === null) && // no cache or TTL not expired
!$this->wasRefreshed('profile')) { !$this->wasRefreshed('profile')) {
// check current data // check current data
$profileValues = array();
$profileValues = [];
//User Profile Field - Phone number //User Profile Field - Phone number
$attr = strtolower($this->connection->ldapAttributePhone); $attr = strtolower($this->connection->ldapAttributePhone);
if (!empty($attr)) { // attribute configured if (!empty($attr)) { // attribute configured
if (str_contains($ldapEntry[$attr][0], '\r')) { if (str_contains($ldapEntry[$attr][0], '\r')) {
// convert line endings // convert line endings
$profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY] $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY]
= str_replace(array("\r\n","\r"), "\n", $ldapEntry[$attr][0]);
= str_replace(["\r\n","\r"], "\n", $ldapEntry[$attr][0]);
} else { } else {
$profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY] $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY]
= $ldapEntry[$attr][0]; = $ldapEntry[$attr][0];
if ($path !== '') { if ($path !== '') {
//if attribute's value is an absolute path take this, otherwise append it to data dir //if attribute's value is an absolute path take this, otherwise append it to data dir
//check for / at the beginning or pattern c:\ resp. c:/ //check for / at the beginning or pattern c:\ resp. c:/
if ('/' !== $path[0]
&& !(3 < strlen($path) && ctype_alpha($path[0])
&& $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2]))
if ($path[0] !== '/'
&& !(strlen($path) > 3 && ctype_alpha($path[0])
&& $path[1] === ':' && ($path[2] === '\\' || $path[2] === '/'))
) { ) {
$path = $this->config->getSystemValue('datadirectory', $path = $this->config->getSystemValue('datadirectory',
\OC::$SERVERROOT.'/data') . '/' . $path; \OC::$SERVERROOT.'/data') . '/' . $path;
* @throws \OCP\PreConditionNotMetException * @throws \OCP\PreConditionNotMetException
* @throws \OC\ServerNotAvailableException * @throws \OC\ServerNotAvailableException
*/ */
public function updateExtStorageHome(string $valueFromLDAP = null):string {
public function updateExtStorageHome(?string $valueFromLDAP = null):string {
if ($valueFromLDAP === null) { if ($valueFromLDAP === null) {
$extHomeValues = $this->access->readAttribute($this->getDN(), $this->connection->ldapExtStorageHomeAttribute); $extHomeValues = $this->access->readAttribute($this->getDN(), $this->connection->ldapExtStorageHomeAttribute);
} else { } else {

+ 1
- 1
apps/user_ldap/tests/Group_LDAPTest.php View File

* @param string[] $expectedMembers * @param string[] $expectedMembers
* @dataProvider groupMemberProvider * @dataProvider groupMemberProvider
*/ */
public function testGroupMembers(array $expectedResult, array $groupsInfo = null) {
public function testGroupMembers(array $expectedResult, ?array $groupsInfo = null) {
$this->access->expects($this->any()) $this->access->expects($this->any())
->method('readAttribute') ->method('readAttribute')
->willReturnCallback(function ($group) use ($groupsInfo) { ->willReturnCallback(function ($group) use ($groupsInfo) {

+ 1
- 1
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserCleanUp.php View File

} }
$user->delete(); $user->delete();


return null === \OC::$server->getUserManager()->get($username);
return \OC::$server->getUserManager()->get($username) === null;
} }
} }



+ 0
- 0
apps/user_ldap/tests/User/UserTest.php View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save