Passed
Push — master ( 078203...c81798 )
by Joas
14:40 queued 14s
created
apps/oauth2/lib/Controller/LoginRedirectorController.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -39,72 +39,72 @@
 block discarded – undo
39 39
 use OCP\IURLGenerator;
40 40
 
41 41
 class LoginRedirectorController extends Controller {
42
-	/** @var IURLGenerator */
43
-	private $urlGenerator;
44
-	/** @var ClientMapper */
45
-	private $clientMapper;
46
-	/** @var ISession */
47
-	private $session;
48
-	/** @var IL10N */
49
-	private $l;
42
+    /** @var IURLGenerator */
43
+    private $urlGenerator;
44
+    /** @var ClientMapper */
45
+    private $clientMapper;
46
+    /** @var ISession */
47
+    private $session;
48
+    /** @var IL10N */
49
+    private $l;
50 50
 
51
-	/**
52
-	 * @param string $appName
53
-	 * @param IRequest $request
54
-	 * @param IURLGenerator $urlGenerator
55
-	 * @param ClientMapper $clientMapper
56
-	 * @param ISession $session
57
-	 * @param IL10N $l
58
-	 */
59
-	public function __construct(string $appName,
60
-								IRequest $request,
61
-								IURLGenerator $urlGenerator,
62
-								ClientMapper $clientMapper,
63
-								ISession $session,
64
-								IL10N $l) {
65
-		parent::__construct($appName, $request);
66
-		$this->urlGenerator = $urlGenerator;
67
-		$this->clientMapper = $clientMapper;
68
-		$this->session = $session;
69
-		$this->l = $l;
70
-	}
51
+    /**
52
+     * @param string $appName
53
+     * @param IRequest $request
54
+     * @param IURLGenerator $urlGenerator
55
+     * @param ClientMapper $clientMapper
56
+     * @param ISession $session
57
+     * @param IL10N $l
58
+     */
59
+    public function __construct(string $appName,
60
+                                IRequest $request,
61
+                                IURLGenerator $urlGenerator,
62
+                                ClientMapper $clientMapper,
63
+                                ISession $session,
64
+                                IL10N $l) {
65
+        parent::__construct($appName, $request);
66
+        $this->urlGenerator = $urlGenerator;
67
+        $this->clientMapper = $clientMapper;
68
+        $this->session = $session;
69
+        $this->l = $l;
70
+    }
71 71
 
72
-	/**
73
-	 * @PublicPage
74
-	 * @NoCSRFRequired
75
-	 * @UseSession
76
-	 *
77
-	 * @param string $client_id
78
-	 * @param string $state
79
-	 * @param string $response_type
80
-	 * @return Response
81
-	 */
82
-	public function authorize($client_id,
83
-							  $state,
84
-							  $response_type): Response {
85
-		try {
86
-			$client = $this->clientMapper->getByIdentifier($client_id);
87
-		} catch (ClientNotFoundException $e) {
88
-			$params = [
89
-				'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'),
90
-			];
91
-			return new TemplateResponse('core', '404', $params, 'guest');
92
-		}
72
+    /**
73
+     * @PublicPage
74
+     * @NoCSRFRequired
75
+     * @UseSession
76
+     *
77
+     * @param string $client_id
78
+     * @param string $state
79
+     * @param string $response_type
80
+     * @return Response
81
+     */
82
+    public function authorize($client_id,
83
+                                $state,
84
+                                $response_type): Response {
85
+        try {
86
+            $client = $this->clientMapper->getByIdentifier($client_id);
87
+        } catch (ClientNotFoundException $e) {
88
+            $params = [
89
+                'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'),
90
+            ];
91
+            return new TemplateResponse('core', '404', $params, 'guest');
92
+        }
93 93
 
94
-		if ($response_type !== 'code') {
95
-			//Fail
96
-			$url = $client->getRedirectUri() . '?error=unsupported_response_type&state=' . $state;
97
-			return new RedirectResponse($url);
98
-		}
94
+        if ($response_type !== 'code') {
95
+            //Fail
96
+            $url = $client->getRedirectUri() . '?error=unsupported_response_type&state=' . $state;
97
+            return new RedirectResponse($url);
98
+        }
99 99
 
100
-		$this->session->set('oauth.state', $state);
100
+        $this->session->set('oauth.state', $state);
101 101
 
102
-		$targetUrl = $this->urlGenerator->linkToRouteAbsolute(
103
-			'core.ClientFlowLogin.showAuthPickerPage',
104
-			[
105
-				'clientIdentifier' => $client->getClientIdentifier(),
106
-			]
107
-		);
108
-		return new RedirectResponse($targetUrl);
109
-	}
102
+        $targetUrl = $this->urlGenerator->linkToRouteAbsolute(
103
+            'core.ClientFlowLogin.showAuthPickerPage',
104
+            [
105
+                'clientIdentifier' => $client->getClientIdentifier(),
106
+            ]
107
+        );
108
+        return new RedirectResponse($targetUrl);
109
+    }
110 110
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/Migration/Version010000Date20200304152605.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,61 +33,61 @@
 block discarded – undo
33 33
 
34 34
 class Version010000Date20200304152605 extends SimpleMigrationStep {
35 35
 
36
-	/**
37
-	 * @param IOutput $output
38
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
-	 * @param array $options
40
-	 *
41
-	 * @return ISchemaWrapper
42
-	 */
43
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
44
-		/** @var ISchemaWrapper $schema */
45
-		$schema = $schemaClosure();
36
+    /**
37
+     * @param IOutput $output
38
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
+     * @param array $options
40
+     *
41
+     * @return ISchemaWrapper
42
+     */
43
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
44
+        /** @var ISchemaWrapper $schema */
45
+        $schema = $schemaClosure();
46 46
 
47
-		$table = $schema->createTable(RecentContactMapper::TABLE_NAME);
48
-		$table->addColumn('id', 'integer', [
49
-			'autoincrement' => true,
50
-			'notnull' => true,
51
-			'length' => 4,
52
-		]);
53
-		$table->addColumn('actor_uid', 'string', [
54
-			'notnull' => true,
55
-			'length' => 64,
56
-		]);
57
-		$table->addColumn('uid', 'string', [
58
-			'notnull' => false,
59
-			'length' => 64,
60
-		]);
61
-		$table->addColumn('email', 'string', [
62
-			'notnull' => false,
63
-			'length' => 255,
64
-		]);
65
-		$table->addColumn('federated_cloud_id', 'string', [
66
-			'notnull' => false,
67
-			'length' => 255,
68
-		]);
69
-		$table->addColumn('card', 'blob', [
70
-			'notnull' => true,
71
-		]);
72
-		$table->addColumn('last_contact', 'integer', [
73
-			'notnull' => true,
74
-			'length' => 4,
75
-		]);
76
-		$table->setPrimaryKey(['id']);
77
-		// To find all recent entries
78
-		$table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid');
79
-		// To find a specific entry
80
-		$table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid');
81
-		// To find all recent entries with a given UID
82
-		$table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid');
83
-		// To find all recent entries with a given email address
84
-		$table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email');
85
-		// To find all recent entries with a give federated cloud id
86
-		$table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id');
87
-		// For the cleanup
88
-		$table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact');
47
+        $table = $schema->createTable(RecentContactMapper::TABLE_NAME);
48
+        $table->addColumn('id', 'integer', [
49
+            'autoincrement' => true,
50
+            'notnull' => true,
51
+            'length' => 4,
52
+        ]);
53
+        $table->addColumn('actor_uid', 'string', [
54
+            'notnull' => true,
55
+            'length' => 64,
56
+        ]);
57
+        $table->addColumn('uid', 'string', [
58
+            'notnull' => false,
59
+            'length' => 64,
60
+        ]);
61
+        $table->addColumn('email', 'string', [
62
+            'notnull' => false,
63
+            'length' => 255,
64
+        ]);
65
+        $table->addColumn('federated_cloud_id', 'string', [
66
+            'notnull' => false,
67
+            'length' => 255,
68
+        ]);
69
+        $table->addColumn('card', 'blob', [
70
+            'notnull' => true,
71
+        ]);
72
+        $table->addColumn('last_contact', 'integer', [
73
+            'notnull' => true,
74
+            'length' => 4,
75
+        ]);
76
+        $table->setPrimaryKey(['id']);
77
+        // To find all recent entries
78
+        $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid');
79
+        // To find a specific entry
80
+        $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid');
81
+        // To find all recent entries with a given UID
82
+        $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid');
83
+        // To find all recent entries with a given email address
84
+        $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email');
85
+        // To find all recent entries with a give federated cloud id
86
+        $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id');
87
+        // For the cleanup
88
+        $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact');
89 89
 
90
-		return $schema;
91
-	}
90
+        return $schema;
91
+    }
92 92
 
93 93
 }
Please login to merge, or discard this patch.
apps/contactsinteraction/lib/AddressBookProvider.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -33,49 +33,49 @@
 block discarded – undo
33 33
 
34 34
 class AddressBookProvider implements IAddressBookProvider {
35 35
 
36
-	/** @var RecentContactMapper */
37
-	private $mapper;
36
+    /** @var RecentContactMapper */
37
+    private $mapper;
38 38
 
39
-	/** @var IL10N */
40
-	private $l10n;
39
+    /** @var IL10N */
40
+    private $l10n;
41 41
 
42
-	public function __construct(RecentContactMapper $mapper, IL10N $l10n) {
43
-		$this->mapper = $mapper;
44
-		$this->l10n = $l10n;
45
-	}
42
+    public function __construct(RecentContactMapper $mapper, IL10N $l10n) {
43
+        $this->mapper = $mapper;
44
+        $this->l10n = $l10n;
45
+    }
46 46
 
47
-	/**
48
-	 * @inheritDoc
49
-	 */
50
-	public function getAppId(): string {
51
-		return Application::APP_ID;
52
-	}
47
+    /**
48
+     * @inheritDoc
49
+     */
50
+    public function getAppId(): string {
51
+        return Application::APP_ID;
52
+    }
53 53
 
54
-	/**
55
-	 * @inheritDoc
56
-	 */
57
-	public function fetchAllForAddressBookHome(string $principalUri): array {
58
-		return [
59
-			new AddressBook($this->mapper, $this->l10n, $principalUri)
60
-		];
61
-	}
54
+    /**
55
+     * @inheritDoc
56
+     */
57
+    public function fetchAllForAddressBookHome(string $principalUri): array {
58
+        return [
59
+            new AddressBook($this->mapper, $this->l10n, $principalUri)
60
+        ];
61
+    }
62 62
 
63
-	/**
64
-	 * @inheritDoc
65
-	 */
66
-	public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool {
67
-		return $uri === AddressBook::URI;
68
-	}
63
+    /**
64
+     * @inheritDoc
65
+     */
66
+    public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool {
67
+        return $uri === AddressBook::URI;
68
+    }
69 69
 
70
-	/**
71
-	 * @inheritDoc
72
-	 */
73
-	public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook {
74
-		if ($uri === AddressBook::URI) {
75
-			return new AddressBook($this->mapper, $this->l10n, $principalUri);
76
-		}
70
+    /**
71
+     * @inheritDoc
72
+     */
73
+    public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook {
74
+        if ($uri === AddressBook::URI) {
75
+            return new AddressBook($this->mapper, $this->l10n, $principalUri);
76
+        }
77 77
 
78
-		return null;
79
-	}
78
+        return null;
79
+    }
80 80
 
81 81
 }
Please login to merge, or discard this patch.
apps/files/lib/Service/TagService.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -38,110 +38,110 @@
 block discarded – undo
38 38
  */
39 39
 class TagService {
40 40
 
41
-	/** @var IUserSession */
42
-	private $userSession;
43
-	/** @var IManager */
44
-	private $activityManager;
45
-	/** @var ITags */
46
-	private $tagger;
47
-	/** @var Folder */
48
-	private $homeFolder;
49
-	/** @var EventDispatcherInterface */
50
-	private $dispatcher;
41
+    /** @var IUserSession */
42
+    private $userSession;
43
+    /** @var IManager */
44
+    private $activityManager;
45
+    /** @var ITags */
46
+    private $tagger;
47
+    /** @var Folder */
48
+    private $homeFolder;
49
+    /** @var EventDispatcherInterface */
50
+    private $dispatcher;
51 51
 
52
-	/**
53
-	 * @param IUserSession $userSession
54
-	 * @param IManager $activityManager
55
-	 * @param ITags $tagger
56
-	 * @param Folder $homeFolder
57
-	 * @param EventDispatcherInterface $dispatcher
58
-	 */
59
-	public function __construct(
60
-		IUserSession $userSession,
61
-		IManager $activityManager,
62
-		ITags $tagger,
63
-		Folder $homeFolder,
64
-		EventDispatcherInterface $dispatcher
65
-	) {
66
-		$this->userSession = $userSession;
67
-		$this->activityManager = $activityManager;
68
-		$this->tagger = $tagger;
69
-		$this->homeFolder = $homeFolder;
70
-		$this->dispatcher = $dispatcher;
71
-	}
52
+    /**
53
+     * @param IUserSession $userSession
54
+     * @param IManager $activityManager
55
+     * @param ITags $tagger
56
+     * @param Folder $homeFolder
57
+     * @param EventDispatcherInterface $dispatcher
58
+     */
59
+    public function __construct(
60
+        IUserSession $userSession,
61
+        IManager $activityManager,
62
+        ITags $tagger,
63
+        Folder $homeFolder,
64
+        EventDispatcherInterface $dispatcher
65
+    ) {
66
+        $this->userSession = $userSession;
67
+        $this->activityManager = $activityManager;
68
+        $this->tagger = $tagger;
69
+        $this->homeFolder = $homeFolder;
70
+        $this->dispatcher = $dispatcher;
71
+    }
72 72
 
73
-	/**
74
-	 * Updates the tags of the specified file path.
75
-	 * The passed tags are absolute, which means they will
76
-	 * replace the actual tag selection.
77
-	 *
78
-	 * @param string $path path
79
-	 * @param array  $tags array of tags
80
-	 * @return array list of tags
81
-	 * @throws \OCP\Files\NotFoundException if the file does not exist
82
-	 */
83
-	public function updateFileTags($path, $tags) {
84
-		$fileId = $this->homeFolder->get($path)->getId();
73
+    /**
74
+     * Updates the tags of the specified file path.
75
+     * The passed tags are absolute, which means they will
76
+     * replace the actual tag selection.
77
+     *
78
+     * @param string $path path
79
+     * @param array  $tags array of tags
80
+     * @return array list of tags
81
+     * @throws \OCP\Files\NotFoundException if the file does not exist
82
+     */
83
+    public function updateFileTags($path, $tags) {
84
+        $fileId = $this->homeFolder->get($path)->getId();
85 85
 
86
-		$currentTags = $this->tagger->getTagsForObjects([$fileId]);
86
+        $currentTags = $this->tagger->getTagsForObjects([$fileId]);
87 87
 
88
-		if (!empty($currentTags)) {
89
-			$currentTags = current($currentTags);
90
-		}
88
+        if (!empty($currentTags)) {
89
+            $currentTags = current($currentTags);
90
+        }
91 91
 
92
-		$newTags = array_diff($tags, $currentTags);
93
-		foreach ($newTags as $tag) {
94
-			if ($tag === ITags::TAG_FAVORITE) {
95
-				$this->addActivity(true, $fileId, $path);
96
-			}
97
-			$this->tagger->tagAs($fileId, $tag);
98
-		}
99
-		$deletedTags = array_diff($currentTags, $tags);
100
-		foreach ($deletedTags as $tag) {
101
-			if ($tag === ITags::TAG_FAVORITE) {
102
-				$this->addActivity(false, $fileId, $path);
103
-			}
104
-			$this->tagger->unTag($fileId, $tag);
105
-		}
92
+        $newTags = array_diff($tags, $currentTags);
93
+        foreach ($newTags as $tag) {
94
+            if ($tag === ITags::TAG_FAVORITE) {
95
+                $this->addActivity(true, $fileId, $path);
96
+            }
97
+            $this->tagger->tagAs($fileId, $tag);
98
+        }
99
+        $deletedTags = array_diff($currentTags, $tags);
100
+        foreach ($deletedTags as $tag) {
101
+            if ($tag === ITags::TAG_FAVORITE) {
102
+                $this->addActivity(false, $fileId, $path);
103
+            }
104
+            $this->tagger->unTag($fileId, $tag);
105
+        }
106 106
 
107
-		// TODO: re-read from tagger to make sure the
108
-		// list is up to date, in case of concurrent changes ?
109
-		return $tags;
110
-	}
107
+        // TODO: re-read from tagger to make sure the
108
+        // list is up to date, in case of concurrent changes ?
109
+        return $tags;
110
+    }
111 111
 
112
-	/**
113
-	 * @param bool $addToFavorite
114
-	 * @param int $fileId
115
-	 * @param string $path
116
-	 */
117
-	protected function addActivity($addToFavorite, $fileId, $path) {
118
-		$user = $this->userSession->getUser();
119
-		if (!$user instanceof IUser) {
120
-			return;
121
-		}
112
+    /**
113
+     * @param bool $addToFavorite
114
+     * @param int $fileId
115
+     * @param string $path
116
+     */
117
+    protected function addActivity($addToFavorite, $fileId, $path) {
118
+        $user = $this->userSession->getUser();
119
+        if (!$user instanceof IUser) {
120
+            return;
121
+        }
122 122
 
123
-		$eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite';
124
-		$this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [
125
-			'userId' => $user->getUID(),
126
-			'fileId' => $fileId,
127
-			'path' => $path,
128
-		]));
123
+        $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite';
124
+        $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [
125
+            'userId' => $user->getUID(),
126
+            'fileId' => $fileId,
127
+            'path' => $path,
128
+        ]));
129 129
 
130
-		$event = $this->activityManager->generateEvent();
131
-		try {
132
-			$event->setApp('files')
133
-				->setObject('files', $fileId, $path)
134
-				->setType('favorite')
135
-				->setAuthor($user->getUID())
136
-				->setAffectedUser($user->getUID())
137
-				->setTimestamp(time())
138
-				->setSubject(
139
-					$addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED,
140
-					['id' => $fileId, 'path' => $path]
141
-				);
142
-			$this->activityManager->publish($event);
143
-		} catch (\InvalidArgumentException $e) {
144
-		} catch (\BadMethodCallException $e) {
145
-		}
146
-	}
130
+        $event = $this->activityManager->generateEvent();
131
+        try {
132
+            $event->setApp('files')
133
+                ->setObject('files', $fileId, $path)
134
+                ->setType('favorite')
135
+                ->setAuthor($user->getUID())
136
+                ->setAffectedUser($user->getUID())
137
+                ->setTimestamp(time())
138
+                ->setSubject(
139
+                    $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED,
140
+                    ['id' => $fileId, 'path' => $path]
141
+                );
142
+            $this->activityManager->publish($event);
143
+        } catch (\InvalidArgumentException $e) {
144
+        } catch (\BadMethodCallException $e) {
145
+        }
146
+    }
147 147
 }
Please login to merge, or discard this patch.
apps/files_external/ajax/applicable.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
 $limit = null;
33 33
 $offset = null;
34 34
 if (isset($_GET['pattern'])) {
35
-	$pattern = (string)$_GET['pattern'];
35
+    $pattern = (string)$_GET['pattern'];
36 36
 }
37 37
 if (isset($_GET['limit'])) {
38
-	$limit = (int)$_GET['limit'];
38
+    $limit = (int)$_GET['limit'];
39 39
 }
40 40
 if (isset($_GET['offset'])) {
41
-	$offset = (int)$_GET['offset'];
41
+    $offset = (int)$_GET['offset'];
42 42
 }
43 43
 
44 44
 $groups = [];
45 45
 foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) {
46
-	$groups[$group->getGID()] = $group->getDisplayName();
46
+    $groups[$group->getGID()] = $group->getDisplayName();
47 47
 }
48 48
 
49 49
 $users = [];
50 50
 foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) {
51
-	$users[$user->getUID()] = $user->getDisplayName();
51
+    $users[$user->getUID()] = $user->getDisplayName();
52 52
 }
53 53
 
54 54
 $results = ['groups' => $groups, 'users' => $users];
Please login to merge, or discard this patch.
apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -35,76 +35,76 @@
 block discarded – undo
35 35
 
36 36
 class RemoveOrphanEventsAndContacts implements IRepairStep {
37 37
 
38
-	/** @var IDBConnection */
39
-	private $connection;
40
-
41
-	public function __construct(IDBConnection $connection) {
42
-		$this->connection = $connection;
43
-	}
44
-
45
-	/**
46
-	 * @inheritdoc
47
-	 */
48
-	public function getName(): string {
49
-		return 'Clean up orphan event and contact data';
50
-	}
51
-
52
-	/**
53
-	 * @inheritdoc
54
-	 */
55
-	public function run(IOutput $output) {
56
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars',  'calendarid');
57
-		$output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
58
-		$orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects',  'objectid');
59
-		$output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
60
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars',  'calendarid');
61
-		$output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
62
-
63
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions',  'calendarid');
64
-		$output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
65
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions',  'calendarid');
66
-		$output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
67
-
68
-		$orphanItems = $this->removeOrphanChildren('cards', 'addressbooks',  'addressbookid');
69
-		$output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
70
-		$orphanItems = $this->removeOrphanChildren('cards_properties', 'cards',  'cardid');
71
-		$output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
72
-		$orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks',  'addressbookid');
73
-		$output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
74
-	}
75
-
76
-	protected function removeOrphanChildren($childTable, $parentTable, $parentId): int {
77
-		$qb = $this->connection->getQueryBuilder();
78
-
79
-		$qb->select('c.id')
80
-			->from($childTable, 'c')
81
-			->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
82
-			->where($qb->expr()->isNull('p.id'));
83
-
84
-		if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
85
-			$calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR;
86
-			$qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
87
-		}
88
-
89
-		$result = $qb->execute();
90
-
91
-		$orphanItems = [];
92
-		while ($row = $result->fetch()) {
93
-			$orphanItems[] = (int) $row['id'];
94
-		}
95
-		$result->closeCursor();
96
-
97
-		if (!empty($orphanItems)) {
98
-			$qb->delete($childTable)
99
-				->where($qb->expr()->in('id', $qb->createParameter('ids')));
100
-
101
-			$orphanItemsBatch = array_chunk($orphanItems, 200);
102
-			foreach ($orphanItemsBatch as $items) {
103
-				$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
104
-				$qb->execute();
105
-			}
106
-		}
107
-
108
-		return count($orphanItems);
109
-	}
38
+    /** @var IDBConnection */
39
+    private $connection;
40
+
41
+    public function __construct(IDBConnection $connection) {
42
+        $this->connection = $connection;
43
+    }
44
+
45
+    /**
46
+     * @inheritdoc
47
+     */
48
+    public function getName(): string {
49
+        return 'Clean up orphan event and contact data';
50
+    }
51
+
52
+    /**
53
+     * @inheritdoc
54
+     */
55
+    public function run(IOutput $output) {
56
+        $orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars',  'calendarid');
57
+        $output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
58
+        $orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects',  'objectid');
59
+        $output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
60
+        $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars',  'calendarid');
61
+        $output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
62
+
63
+        $orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions',  'calendarid');
64
+        $output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
65
+        $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions',  'calendarid');
66
+        $output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
67
+
68
+        $orphanItems = $this->removeOrphanChildren('cards', 'addressbooks',  'addressbookid');
69
+        $output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
70
+        $orphanItems = $this->removeOrphanChildren('cards_properties', 'cards',  'cardid');
71
+        $output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
72
+        $orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks',  'addressbookid');
73
+        $output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
74
+    }
75
+
76
+    protected function removeOrphanChildren($childTable, $parentTable, $parentId): int {
77
+        $qb = $this->connection->getQueryBuilder();
78
+
79
+        $qb->select('c.id')
80
+            ->from($childTable, 'c')
81
+            ->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
82
+            ->where($qb->expr()->isNull('p.id'));
83
+
84
+        if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
85
+            $calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR;
86
+            $qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
87
+        }
88
+
89
+        $result = $qb->execute();
90
+
91
+        $orphanItems = [];
92
+        while ($row = $result->fetch()) {
93
+            $orphanItems[] = (int) $row['id'];
94
+        }
95
+        $result->closeCursor();
96
+
97
+        if (!empty($orphanItems)) {
98
+            $qb->delete($childTable)
99
+                ->where($qb->expr()->in('id', $qb->createParameter('ids')));
100
+
101
+            $orphanItemsBatch = array_chunk($orphanItems, 200);
102
+            foreach ($orphanItemsBatch as $items) {
103
+                $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
104
+                $qb->execute();
105
+            }
106
+        }
107
+
108
+        return count($orphanItems);
109
+    }
110 110
 }
Please login to merge, or discard this patch.
apps/files_sharing/public.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@
 block discarded – undo
28 28
 $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare';
29 29
 
30 30
 if ($token !== '') {
31
-	$protocol = \OC::$server->getRequest()->getHttpProtocol();
32
-	if ($protocol == 'HTTP/1.0') {
33
-		http_response_code(302);
34
-	} else {
35
-		http_response_code(307);
36
-	}
37
-	header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token]));
31
+    $protocol = \OC::$server->getRequest()->getHttpProtocol();
32
+    if ($protocol == 'HTTP/1.0') {
33
+        http_response_code(302);
34
+    } else {
35
+        http_response_code(307);
36
+    }
37
+    header('Location: ' . $urlGenerator->linkToRoute($route, ['token' => $token]));
38 38
 } else {
39
-	http_response_code(404);
40
-	$tmpl = new OCP\Template('', '404', 'guest');
41
-	print_unescaped($tmpl->fetchPage());
39
+    http_response_code(404);
40
+    $tmpl = new OCP\Template('', '404', 'guest');
41
+    print_unescaped($tmpl->fetchPage());
42 42
 }
Please login to merge, or discard this patch.
apps/user_ldap/ajax/getConfiguration.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix);
36 36
 $configuration = $connection->getConfiguration();
37 37
 if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') {
38
-	// hide password
39
-	$configuration['ldap_agent_password'] = '**PASSWORD SET**';
38
+    // hide password
39
+    $configuration['ldap_agent_password'] = '**PASSWORD SET**';
40 40
 }
41 41
 \OC_JSON::success(['configuration' => $configuration]);
Please login to merge, or discard this patch.
lib/private/Files/Type/TemplateManager.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,40 +29,40 @@
 block discarded – undo
29 29
  * @deprecated 18.0.0
30 30
  */
31 31
 class TemplateManager {
32
-	protected $templates = [];
32
+    protected $templates = [];
33 33
 
34
-	public function registerTemplate($mimetype, $path) {
35
-		$this->templates[$mimetype] = $path;
36
-	}
34
+    public function registerTemplate($mimetype, $path) {
35
+        $this->templates[$mimetype] = $path;
36
+    }
37 37
 
38
-	/**
39
-	 * get the path of the template for a mimetype
40
-	 *
41
-	 * @deprecated 18.0.0
42
-	 * @param string $mimetype
43
-	 * @return string|null
44
-	 */
45
-	public function getTemplatePath($mimetype) {
46
-		if (isset($this->templates[$mimetype])) {
47
-			return $this->templates[$mimetype];
48
-		} else {
49
-			return null;
50
-		}
51
-	}
38
+    /**
39
+     * get the path of the template for a mimetype
40
+     *
41
+     * @deprecated 18.0.0
42
+     * @param string $mimetype
43
+     * @return string|null
44
+     */
45
+    public function getTemplatePath($mimetype) {
46
+        if (isset($this->templates[$mimetype])) {
47
+            return $this->templates[$mimetype];
48
+        } else {
49
+            return null;
50
+        }
51
+    }
52 52
 
53
-	/**
54
-	 * get the template content for a mimetype
55
-	 *
56
-	 * @deprecated 18.0.0
57
-	 * @param string $mimetype
58
-	 * @return string
59
-	 */
60
-	public function getTemplate($mimetype) {
61
-		$path = $this->getTemplatePath($mimetype);
62
-		if ($path) {
63
-			return file_get_contents($path);
64
-		} else {
65
-			return '';
66
-		}
67
-	}
53
+    /**
54
+     * get the template content for a mimetype
55
+     *
56
+     * @deprecated 18.0.0
57
+     * @param string $mimetype
58
+     * @return string
59
+     */
60
+    public function getTemplate($mimetype) {
61
+        $path = $this->getTemplatePath($mimetype);
62
+        if ($path) {
63
+            return file_get_contents($path);
64
+        } else {
65
+            return '';
66
+        }
67
+    }
68 68
 }
Please login to merge, or discard this patch.