Passed
Push — master ( c5c14d...18b673 )
by Morris
10:52 queued 10s
created
lib/public/Collaboration/Collaborators/ISearchResult.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,44 +30,44 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchResult {
33
-	/**
34
-	 * @param SearchResultType $type
35
-	 * @param array $matches
36
-	 * @param array|null $exactMatches
37
-	 * @since 13.0.0
38
-	 */
39
-	public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
33
+    /**
34
+     * @param SearchResultType $type
35
+     * @param array $matches
36
+     * @param array|null $exactMatches
37
+     * @since 13.0.0
38
+     */
39
+    public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
40 40
 
41
-	/**
42
-	 * @param SearchResultType $type
43
-	 * @param string $collaboratorId
44
-	 * @return bool
45
-	 * @since 13.0.0
46
-	 */
47
-	public function hasResult(SearchResultType $type, $collaboratorId);
41
+    /**
42
+     * @param SearchResultType $type
43
+     * @param string $collaboratorId
44
+     * @return bool
45
+     * @since 13.0.0
46
+     */
47
+    public function hasResult(SearchResultType $type, $collaboratorId);
48 48
 
49
-	/**
50
-	 * @param SearchResultType $type
51
-	 * @since 13.0.0
52
-	 */
53
-	public function unsetResult(SearchResultType $type);
49
+    /**
50
+     * @param SearchResultType $type
51
+     * @since 13.0.0
52
+     */
53
+    public function unsetResult(SearchResultType $type);
54 54
 
55
-	/**
56
-	 * @param SearchResultType $type
57
-	 * @since 13.0.0
58
-	 */
59
-	public function markExactIdMatch(SearchResultType $type);
55
+    /**
56
+     * @param SearchResultType $type
57
+     * @since 13.0.0
58
+     */
59
+    public function markExactIdMatch(SearchResultType $type);
60 60
 
61
-	/**
62
-	 * @param SearchResultType $type
63
-	 * @return bool
64
-	 * @since 13.0.0
65
-	 */
66
-	public function hasExactIdMatch(SearchResultType $type);
61
+    /**
62
+     * @param SearchResultType $type
63
+     * @return bool
64
+     * @since 13.0.0
65
+     */
66
+    public function hasExactIdMatch(SearchResultType $type);
67 67
 
68
-	/**
69
-	 * @return array
70
-	 * @since 13.0.0
71
-	 */
72
-	public function asArray();
68
+    /**
69
+     * @return array
70
+     * @since 13.0.0
71
+     */
72
+    public function asArray();
73 73
 }
Please login to merge, or discard this patch.
lib/private/Repair/Owncloud/SaveAccountsTableData.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -38,137 +38,137 @@
 block discarded – undo
38 38
  */
39 39
 class SaveAccountsTableData implements IRepairStep {
40 40
 
41
-	const BATCH_SIZE = 75;
42
-
43
-	/** @var IDBConnection */
44
-	protected $db;
45
-
46
-	/** @var IConfig */
47
-	protected $config;
48
-
49
-	/**
50
-	 * @param IDBConnection $db
51
-	 * @param IConfig $config
52
-	 */
53
-	public function __construct(IDBConnection $db, IConfig $config) {
54
-		$this->db = $db;
55
-		$this->config = $config;
56
-	}
57
-
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return 'Copy data from accounts table when migrating from ownCloud';
63
-	}
64
-
65
-	/**
66
-	 * @param IOutput $output
67
-	 */
68
-	public function run(IOutput $output) {
69
-		if (!$this->shouldRun()) {
70
-			return;
71
-		}
72
-
73
-		$offset = 0;
74
-		$numUsers = $this->runStep($offset);
75
-
76
-		while ($numUsers === self::BATCH_SIZE) {
77
-			$offset += $numUsers;
78
-			$numUsers = $this->runStep($offset);
79
-		}
80
-
81
-		// Remove the table
82
-		$this->db->dropTable('accounts');
83
-	}
84
-
85
-	/**
86
-	 * @return bool
87
-	 */
88
-	protected function shouldRun() {
89
-		$schema = $this->db->createSchema();
90
-
91
-		$tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
92
-		if (!$schema->hasTable($tableName)) {
93
-			return false;
94
-		}
95
-
96
-		$table = $schema->getTable($tableName);
97
-		return $table->hasColumn('user_id');
98
-	}
99
-
100
-	/**
101
-	 * @param int $offset
102
-	 * @return int Number of copied users
103
-	 */
104
-	protected function runStep($offset) {
105
-		$query = $this->db->getQueryBuilder();
106
-		$query->select('*')
107
-			->from('accounts')
108
-			->orderBy('id')
109
-			->setMaxResults(self::BATCH_SIZE);
110
-
111
-		if ($offset > 0) {
112
-			$query->setFirstResult($offset);
113
-		}
114
-
115
-		$result = $query->execute();
116
-
117
-		$update = $this->db->getQueryBuilder();
118
-		$update->update('users')
119
-			->set('displayname', $update->createParameter('displayname'))
120
-			->where($update->expr()->eq('uid', $update->createParameter('userid')));
121
-
122
-		$updatedUsers = 0;
123
-		while ($row = $result->fetch()) {
124
-			try {
125
-				$this->migrateUserInfo($update, $row);
126
-			} catch (PreConditionNotMetException $e) {
127
-				// Ignore and continue
128
-			} catch (\UnexpectedValueException $e) {
129
-				// Ignore and continue
130
-			}
131
-			$updatedUsers++;
132
-		}
133
-		$result->closeCursor();
134
-
135
-		return $updatedUsers;
136
-	}
137
-
138
-	/**
139
-	 * @param IQueryBuilder $update
140
-	 * @param array $userdata
141
-	 * @throws PreConditionNotMetException
142
-	 * @throws \UnexpectedValueException
143
-	 */
144
-	protected function migrateUserInfo(IQueryBuilder $update, $userdata) {
145
-		$state = (int) $userdata['state'];
146
-		if ($state === 3) {
147
-			// Deleted user, ignore
148
-			return;
149
-		}
150
-
151
-		if ($userdata['email'] !== null) {
152
-			$this->config->setUserValue($userdata['user_id'], 'settings', 'email', $userdata['email']);
153
-		}
154
-		if ($userdata['quota'] !== null) {
155
-			$this->config->setUserValue($userdata['user_id'], 'files', 'quota', $userdata['quota']);
156
-		}
157
-		if ($userdata['last_login'] !== null) {
158
-			$this->config->setUserValue($userdata['user_id'], 'login', 'lastLogin', $userdata['last_login']);
159
-		}
160
-		if ($state === 1) {
161
-			$this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'true');
162
-		} else if ($state === 2) {
163
-			$this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'false');
164
-		}
165
-
166
-		if ($userdata['display_name'] !== null) {
167
-			$update->setParameter('displayname', $userdata['display_name'])
168
-				->setParameter('userid', $userdata['user_id']);
169
-			$update->execute();
170
-		}
171
-
172
-	}
41
+    const BATCH_SIZE = 75;
42
+
43
+    /** @var IDBConnection */
44
+    protected $db;
45
+
46
+    /** @var IConfig */
47
+    protected $config;
48
+
49
+    /**
50
+     * @param IDBConnection $db
51
+     * @param IConfig $config
52
+     */
53
+    public function __construct(IDBConnection $db, IConfig $config) {
54
+        $this->db = $db;
55
+        $this->config = $config;
56
+    }
57
+
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return 'Copy data from accounts table when migrating from ownCloud';
63
+    }
64
+
65
+    /**
66
+     * @param IOutput $output
67
+     */
68
+    public function run(IOutput $output) {
69
+        if (!$this->shouldRun()) {
70
+            return;
71
+        }
72
+
73
+        $offset = 0;
74
+        $numUsers = $this->runStep($offset);
75
+
76
+        while ($numUsers === self::BATCH_SIZE) {
77
+            $offset += $numUsers;
78
+            $numUsers = $this->runStep($offset);
79
+        }
80
+
81
+        // Remove the table
82
+        $this->db->dropTable('accounts');
83
+    }
84
+
85
+    /**
86
+     * @return bool
87
+     */
88
+    protected function shouldRun() {
89
+        $schema = $this->db->createSchema();
90
+
91
+        $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
92
+        if (!$schema->hasTable($tableName)) {
93
+            return false;
94
+        }
95
+
96
+        $table = $schema->getTable($tableName);
97
+        return $table->hasColumn('user_id');
98
+    }
99
+
100
+    /**
101
+     * @param int $offset
102
+     * @return int Number of copied users
103
+     */
104
+    protected function runStep($offset) {
105
+        $query = $this->db->getQueryBuilder();
106
+        $query->select('*')
107
+            ->from('accounts')
108
+            ->orderBy('id')
109
+            ->setMaxResults(self::BATCH_SIZE);
110
+
111
+        if ($offset > 0) {
112
+            $query->setFirstResult($offset);
113
+        }
114
+
115
+        $result = $query->execute();
116
+
117
+        $update = $this->db->getQueryBuilder();
118
+        $update->update('users')
119
+            ->set('displayname', $update->createParameter('displayname'))
120
+            ->where($update->expr()->eq('uid', $update->createParameter('userid')));
121
+
122
+        $updatedUsers = 0;
123
+        while ($row = $result->fetch()) {
124
+            try {
125
+                $this->migrateUserInfo($update, $row);
126
+            } catch (PreConditionNotMetException $e) {
127
+                // Ignore and continue
128
+            } catch (\UnexpectedValueException $e) {
129
+                // Ignore and continue
130
+            }
131
+            $updatedUsers++;
132
+        }
133
+        $result->closeCursor();
134
+
135
+        return $updatedUsers;
136
+    }
137
+
138
+    /**
139
+     * @param IQueryBuilder $update
140
+     * @param array $userdata
141
+     * @throws PreConditionNotMetException
142
+     * @throws \UnexpectedValueException
143
+     */
144
+    protected function migrateUserInfo(IQueryBuilder $update, $userdata) {
145
+        $state = (int) $userdata['state'];
146
+        if ($state === 3) {
147
+            // Deleted user, ignore
148
+            return;
149
+        }
150
+
151
+        if ($userdata['email'] !== null) {
152
+            $this->config->setUserValue($userdata['user_id'], 'settings', 'email', $userdata['email']);
153
+        }
154
+        if ($userdata['quota'] !== null) {
155
+            $this->config->setUserValue($userdata['user_id'], 'files', 'quota', $userdata['quota']);
156
+        }
157
+        if ($userdata['last_login'] !== null) {
158
+            $this->config->setUserValue($userdata['user_id'], 'login', 'lastLogin', $userdata['last_login']);
159
+        }
160
+        if ($state === 1) {
161
+            $this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'true');
162
+        } else if ($state === 2) {
163
+            $this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'false');
164
+        }
165
+
166
+        if ($userdata['display_name'] !== null) {
167
+            $update->setParameter('displayname', $userdata['display_name'])
168
+                ->setParameter('userid', $userdata['user_id']);
169
+            $update->execute();
170
+        }
171
+
172
+    }
173 173
 }
174 174
 
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Events/MoveToTrashEvent.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -35,39 +35,39 @@
 block discarded – undo
35 35
  */
36 36
 class MoveToTrashEvent extends Event {
37 37
 
38
-	/** @var bool */
39
-	private $moveToTrashBin;
38
+    /** @var bool */
39
+    private $moveToTrashBin;
40 40
 
41
-	/** @var Node */
42
-	private $node;
41
+    /** @var Node */
42
+    private $node;
43 43
 
44
-	public function __construct(Node $node) {
45
-		$this->moveToTrashBin = true;
46
-		$this->node = $node;
47
-	}
44
+    public function __construct(Node $node) {
45
+        $this->moveToTrashBin = true;
46
+        $this->node = $node;
47
+    }
48 48
 
49
-	/**
50
-	 * get Node which will be deleted
51
-	 *
52
-	 * @return Node
53
-	 */
54
-	public function getNode() {
55
-		return $this->node;
56
-	}
49
+    /**
50
+     * get Node which will be deleted
51
+     *
52
+     * @return Node
53
+     */
54
+    public function getNode() {
55
+        return $this->node;
56
+    }
57 57
 
58
-	/**
59
-	 * disable trash bin for this operation
60
-	 */
61
-	public function disableTrashBin() {
62
-		$this->moveToTrashBin = false;
63
-	}
58
+    /**
59
+     * disable trash bin for this operation
60
+     */
61
+    public function disableTrashBin() {
62
+        $this->moveToTrashBin = false;
63
+    }
64 64
 
65
-	/**
66
-	 * should the file be moved to the trash bin?
67
-	 *
68
-	 * @return bool
69
-	 */
70
-	public function shouldMoveToTrashBin() {
71
-		return $this->moveToTrashBin;
72
-	}
65
+    /**
66
+     * should the file be moved to the trash bin?
67
+     *
68
+     * @return bool
69
+     */
70
+    public function shouldMoveToTrashBin() {
71
+        return $this->moveToTrashBin;
72
+    }
73 73
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Events/CreateVersionEvent.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@
 block discarded – undo
37 37
 class CreateVersionEvent extends Event {
38 38
 
39 39
 
40
-	/** @var bool */
41
-	private $createVersion;
40
+    /** @var bool */
41
+    private $createVersion;
42 42
 
43
-	/** @var Node */
44
-	private $node;
43
+    /** @var Node */
44
+    private $node;
45 45
 
46
-	/**
47
-	 * CreateVersionEvent constructor.
48
-	 *
49
-	 * @param Node $node
50
-	 */
51
-	public function __construct(Node $node) {
52
-		$this->createVersion = true;
53
-		$this->node = $node;
54
-	}
46
+    /**
47
+     * CreateVersionEvent constructor.
48
+     *
49
+     * @param Node $node
50
+     */
51
+    public function __construct(Node $node) {
52
+        $this->createVersion = true;
53
+        $this->node = $node;
54
+    }
55 55
 
56
-	/**
57
-	 * get Node of the file which should be versioned
58
-	 *
59
-	 * @return Node
60
-	 */
61
-	public function getNode() {
62
-		return $this->node;
63
-	}
56
+    /**
57
+     * get Node of the file which should be versioned
58
+     *
59
+     * @return Node
60
+     */
61
+    public function getNode() {
62
+        return $this->node;
63
+    }
64 64
 
65
-	/**
66
-	 * disable versions for this file
67
-	 */
68
-	public function disableVersions() {
69
-		$this->createVersion = false;
70
-	}
65
+    /**
66
+     * disable versions for this file
67
+     */
68
+    public function disableVersions() {
69
+        $this->createVersion = false;
70
+    }
71 71
 
72
-	/**
73
-	 * should a version be created for this file?
74
-	 *
75
-	 * @return bool
76
-	 */
77
-	public function shouldCreateVersion() {
78
-		return $this->createVersion;
79
-	}
72
+    /**
73
+     * should a version be created for this file?
74
+     *
75
+     * @return bool
76
+     */
77
+    public function shouldCreateVersion() {
78
+        return $this->createVersion;
79
+    }
80 80
 
81 81
 }
Please login to merge, or discard this patch.
apps/files_trashbin/appinfo/app.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
 \OCA\Files_Trashbin\Trashbin::registerHooks();
30 30
 
31 31
 \OCA\Files\App::getNavigationManager()->add(function () {
32
-	$l = \OC::$server->getL10N('files_trashbin');
33
-	return [
34
-		'id' => 'trashbin',
35
-		'appname' => 'files_trashbin',
36
-		'script' => 'list.php',
37
-		'order' => 50,
38
-		'name' => $l->t('Deleted files'),
39
-		'classes' => 'pinned',
40
-	];
32
+    $l = \OC::$server->getL10N('files_trashbin');
33
+    return [
34
+        'id' => 'trashbin',
35
+        'appname' => 'files_trashbin',
36
+        'script' => 'list.php',
37
+        'order' => 50,
38
+        'name' => $l->t('Deleted files'),
39
+        'classes' => 'pinned',
40
+    ];
41 41
 });
Please login to merge, or discard this patch.
lib/private/Template/ResourceLocator.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -27,173 +27,173 @@
 block discarded – undo
27 27
 namespace OC\Template;
28 28
 
29 29
 abstract class ResourceLocator {
30
-	protected $theme;
31
-
32
-	protected $mapping;
33
-	protected $serverroot;
34
-	protected $thirdpartyroot;
35
-	protected $webroot;
36
-
37
-	protected $resources = array();
38
-
39
-	/** @var \OCP\ILogger */
40
-	protected $logger;
41
-
42
-	/**
43
-	 * @param \OCP\ILogger $logger
44
-	 * @param string $theme
45
-	 * @param array $core_map
46
-	 * @param array $party_map
47
-	 */
48
-	public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
49
-		$this->logger = $logger;
50
-		$this->theme = $theme;
51
-		$this->mapping = $core_map + $party_map;
52
-		$this->serverroot = key($core_map);
53
-		$this->thirdpartyroot = key($party_map);
54
-		$this->webroot = $this->mapping[$this->serverroot];
55
-	}
56
-
57
-	/**
58
-	 * @param string $resource
59
-	 */
60
-	abstract public function doFind($resource);
61
-
62
-	/**
63
-	 * @param string $resource
64
-	 */
65
-	abstract public function doFindTheme($resource);
66
-
67
-	/**
68
-	 * Finds the resources and adds them to the list
69
-	 *
70
-	 * @param array $resources
71
-	 */
72
-	public function find($resources) {
73
-		foreach ($resources as $resource) {
74
-			try {
75
-				$this->doFind($resource);
76
-			} catch (ResourceNotFoundException $e) {
77
-				$resourceApp = substr($resource, 0, strpos($resource, '/'));
78
-				$this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
79
-			}
80
-		}
81
-		if (!empty($this->theme)) {
82
-			foreach ($resources as $resource) {
83
-				try {
84
-					$this->doFindTheme($resource);
85
-				} catch (ResourceNotFoundException $e) {
86
-					$resourceApp = substr($resource, 0, strpos($resource, '/'));
87
-					$this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
88
-				}
89
-			}
90
-		}
91
-	}
92
-
93
-	/**
94
-	 * append the $file resource if exist at $root
95
-	 *
96
-	 * @param string $root path to check
97
-	 * @param string $file the filename
98
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
99
-	 * @return bool True if the resource was found, false otherwise
100
-	 */
101
-	protected function appendIfExist($root, $file, $webRoot = null) {
102
-		if (is_file($root.'/'.$file)) {
103
-			$this->append($root, $file, $webRoot, false);
104
-			return true;
105
-		}
106
-		return false;
107
-	}
108
-
109
-	/**
110
-	 * Attempt to find the webRoot
111
-	 *
112
-	 * traverse the potential web roots upwards in the path
113
-	 *
114
-	 * example:
115
-	 *   - root: /srv/www/apps/myapp
116
-	 *   - available mappings: ['/srv/www']
117
-	 *
118
-	 * First we check if a mapping for /srv/www/apps/myapp is available,
119
-	 * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
120
-	 * valid web root
121
-	 *
122
-	 * @param string $root
123
-	 * @return string|null The web root or null on failure
124
-	 */
125
-	protected function findWebRoot($root) {
126
-		$webRoot = null;
127
-		$tmpRoot = $root;
128
-
129
-		while ($webRoot === null) {
130
-			if (isset($this->mapping[$tmpRoot])) {
131
-				$webRoot = $this->mapping[$tmpRoot];
132
-				break;
133
-			}
134
-
135
-			if ($tmpRoot === '/') {
136
-				break;
137
-			}
138
-
139
-			$tmpRoot = dirname($tmpRoot);
140
-		}
141
-
142
-		if ($webRoot === null) {
143
-			$realpath = realpath($root);
144
-
145
-			if ($realpath && ($realpath !== $root)) {
146
-				return $this->findWebRoot($realpath);
147
-			}
148
-		}
149
-
150
-		return $webRoot;
151
-	}
152
-
153
-	/**
154
-	 * append the $file resource at $root
155
-	 *
156
-	 * @param string $root path to check
157
-	 * @param string $file the filename
158
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
159
-	 * @param bool $throw Throw an exception, when the route does not exist
160
-	 * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
161
-	 */
162
-	protected function append($root, $file, $webRoot = null, $throw = true) {
163
-
164
-		if (!is_string($root)) {
165
-			if ($throw) {
166
-				throw new ResourceNotFoundException($file, $webRoot);
167
-			}
168
-			return;
169
-		}
170
-
171
-		if (!$webRoot) {
172
-			$webRoot = $this->findWebRoot($root);
173
-
174
-			if ($webRoot === null) {
175
-				$webRoot = '';
176
-				$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
177
-					'app' => 'lib',
178
-					'root' => $root,
179
-					'file' => $file,
180
-					'webRoot' => $webRoot,
181
-					'throw' => $throw ? 'true' : 'false'
182
-				]);
183
-			}
184
-		}
185
-		$this->resources[] = array($root, $webRoot, $file);
186
-
187
-		if ($throw && !is_file($root . '/' . $file)) {
188
-			throw new ResourceNotFoundException($file, $webRoot);
189
-		}
190
-	}
191
-
192
-	/**
193
-	 * Returns the list of all resources that should be loaded
194
-	 * @return array
195
-	 */
196
-	public function getResources() {
197
-		return $this->resources;
198
-	}
30
+    protected $theme;
31
+
32
+    protected $mapping;
33
+    protected $serverroot;
34
+    protected $thirdpartyroot;
35
+    protected $webroot;
36
+
37
+    protected $resources = array();
38
+
39
+    /** @var \OCP\ILogger */
40
+    protected $logger;
41
+
42
+    /**
43
+     * @param \OCP\ILogger $logger
44
+     * @param string $theme
45
+     * @param array $core_map
46
+     * @param array $party_map
47
+     */
48
+    public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
49
+        $this->logger = $logger;
50
+        $this->theme = $theme;
51
+        $this->mapping = $core_map + $party_map;
52
+        $this->serverroot = key($core_map);
53
+        $this->thirdpartyroot = key($party_map);
54
+        $this->webroot = $this->mapping[$this->serverroot];
55
+    }
56
+
57
+    /**
58
+     * @param string $resource
59
+     */
60
+    abstract public function doFind($resource);
61
+
62
+    /**
63
+     * @param string $resource
64
+     */
65
+    abstract public function doFindTheme($resource);
66
+
67
+    /**
68
+     * Finds the resources and adds them to the list
69
+     *
70
+     * @param array $resources
71
+     */
72
+    public function find($resources) {
73
+        foreach ($resources as $resource) {
74
+            try {
75
+                $this->doFind($resource);
76
+            } catch (ResourceNotFoundException $e) {
77
+                $resourceApp = substr($resource, 0, strpos($resource, '/'));
78
+                $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
79
+            }
80
+        }
81
+        if (!empty($this->theme)) {
82
+            foreach ($resources as $resource) {
83
+                try {
84
+                    $this->doFindTheme($resource);
85
+                } catch (ResourceNotFoundException $e) {
86
+                    $resourceApp = substr($resource, 0, strpos($resource, '/'));
87
+                    $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
88
+                }
89
+            }
90
+        }
91
+    }
92
+
93
+    /**
94
+     * append the $file resource if exist at $root
95
+     *
96
+     * @param string $root path to check
97
+     * @param string $file the filename
98
+     * @param string|null $webRoot base for path, default map $root to $webRoot
99
+     * @return bool True if the resource was found, false otherwise
100
+     */
101
+    protected function appendIfExist($root, $file, $webRoot = null) {
102
+        if (is_file($root.'/'.$file)) {
103
+            $this->append($root, $file, $webRoot, false);
104
+            return true;
105
+        }
106
+        return false;
107
+    }
108
+
109
+    /**
110
+     * Attempt to find the webRoot
111
+     *
112
+     * traverse the potential web roots upwards in the path
113
+     *
114
+     * example:
115
+     *   - root: /srv/www/apps/myapp
116
+     *   - available mappings: ['/srv/www']
117
+     *
118
+     * First we check if a mapping for /srv/www/apps/myapp is available,
119
+     * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
120
+     * valid web root
121
+     *
122
+     * @param string $root
123
+     * @return string|null The web root or null on failure
124
+     */
125
+    protected function findWebRoot($root) {
126
+        $webRoot = null;
127
+        $tmpRoot = $root;
128
+
129
+        while ($webRoot === null) {
130
+            if (isset($this->mapping[$tmpRoot])) {
131
+                $webRoot = $this->mapping[$tmpRoot];
132
+                break;
133
+            }
134
+
135
+            if ($tmpRoot === '/') {
136
+                break;
137
+            }
138
+
139
+            $tmpRoot = dirname($tmpRoot);
140
+        }
141
+
142
+        if ($webRoot === null) {
143
+            $realpath = realpath($root);
144
+
145
+            if ($realpath && ($realpath !== $root)) {
146
+                return $this->findWebRoot($realpath);
147
+            }
148
+        }
149
+
150
+        return $webRoot;
151
+    }
152
+
153
+    /**
154
+     * append the $file resource at $root
155
+     *
156
+     * @param string $root path to check
157
+     * @param string $file the filename
158
+     * @param string|null $webRoot base for path, default map $root to $webRoot
159
+     * @param bool $throw Throw an exception, when the route does not exist
160
+     * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
161
+     */
162
+    protected function append($root, $file, $webRoot = null, $throw = true) {
163
+
164
+        if (!is_string($root)) {
165
+            if ($throw) {
166
+                throw new ResourceNotFoundException($file, $webRoot);
167
+            }
168
+            return;
169
+        }
170
+
171
+        if (!$webRoot) {
172
+            $webRoot = $this->findWebRoot($root);
173
+
174
+            if ($webRoot === null) {
175
+                $webRoot = '';
176
+                $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
177
+                    'app' => 'lib',
178
+                    'root' => $root,
179
+                    'file' => $file,
180
+                    'webRoot' => $webRoot,
181
+                    'throw' => $throw ? 'true' : 'false'
182
+                ]);
183
+            }
184
+        }
185
+        $this->resources[] = array($root, $webRoot, $file);
186
+
187
+        if ($throw && !is_file($root . '/' . $file)) {
188
+            throw new ResourceNotFoundException($file, $webRoot);
189
+        }
190
+    }
191
+
192
+    /**
193
+     * Returns the list of all resources that should be loaded
194
+     * @return array
195
+     */
196
+    public function getResources() {
197
+        return $this->resources;
198
+    }
199 199
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -31,76 +31,76 @@
 block discarded – undo
31 31
 
32 32
 class SameSiteCookieMiddleware extends Middleware {
33 33
 
34
-	/** @var Request */
35
-	private $request;
36
-
37
-	/** @var ControllerMethodReflector */
38
-	private $reflector;
39
-
40
-	public function __construct(Request $request,
41
-								ControllerMethodReflector $reflector) {
42
-		$this->request = $request;
43
-		$this->reflector = $reflector;
44
-	}
45
-
46
-	public function beforeController($controller, $methodName) {
47
-		$requestUri = $this->request->getScriptName();
48
-		$processingScript = explode('/', $requestUri);
49
-		$processingScript = $processingScript[count($processingScript)-1];
50
-
51
-		if ($processingScript !== 'index.php') {
52
-			return;
53
-		}
54
-
55
-		$noSSC = $this->reflector->hasAnnotation('NoSameSiteCookieRequired');
56
-		if ($noSSC) {
57
-			return;
58
-		}
59
-
60
-		if (!$this->request->passesLaxCookieCheck()) {
61
-			throw new LaxSameSiteCookieFailedException();
62
-		}
63
-	}
64
-
65
-	public function afterException($controller, $methodName, \Exception $exception) {
66
-		if ($exception instanceof LaxSameSiteCookieFailedException) {
67
-			$respone = new Response();
68
-			$respone->setStatus(Http::STATUS_FOUND);
69
-			$respone->addHeader('Location', $this->request->getRequestUri());
70
-
71
-			$this->setSameSiteCookie();
72
-
73
-			return $respone;
74
-		}
75
-
76
-		throw $exception;
77
-	}
78
-
79
-	protected function setSameSiteCookie() {
80
-		$cookieParams = $this->request->getCookieParams();
81
-		$secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : '';
82
-		$policies = [
83
-			'lax',
84
-			'strict',
85
-		];
86
-
87
-		// Append __Host to the cookie if it meets the requirements
88
-		$cookiePrefix = '';
89
-		if($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
90
-			$cookiePrefix = '__Host-';
91
-		}
92
-
93
-		foreach($policies as $policy) {
94
-			header(
95
-				sprintf(
96
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
97
-					$cookiePrefix,
98
-					$policy,
99
-					$cookieParams['path'],
100
-					$policy
101
-				),
102
-				false
103
-			);
104
-		}
105
-	}
34
+    /** @var Request */
35
+    private $request;
36
+
37
+    /** @var ControllerMethodReflector */
38
+    private $reflector;
39
+
40
+    public function __construct(Request $request,
41
+                                ControllerMethodReflector $reflector) {
42
+        $this->request = $request;
43
+        $this->reflector = $reflector;
44
+    }
45
+
46
+    public function beforeController($controller, $methodName) {
47
+        $requestUri = $this->request->getScriptName();
48
+        $processingScript = explode('/', $requestUri);
49
+        $processingScript = $processingScript[count($processingScript)-1];
50
+
51
+        if ($processingScript !== 'index.php') {
52
+            return;
53
+        }
54
+
55
+        $noSSC = $this->reflector->hasAnnotation('NoSameSiteCookieRequired');
56
+        if ($noSSC) {
57
+            return;
58
+        }
59
+
60
+        if (!$this->request->passesLaxCookieCheck()) {
61
+            throw new LaxSameSiteCookieFailedException();
62
+        }
63
+    }
64
+
65
+    public function afterException($controller, $methodName, \Exception $exception) {
66
+        if ($exception instanceof LaxSameSiteCookieFailedException) {
67
+            $respone = new Response();
68
+            $respone->setStatus(Http::STATUS_FOUND);
69
+            $respone->addHeader('Location', $this->request->getRequestUri());
70
+
71
+            $this->setSameSiteCookie();
72
+
73
+            return $respone;
74
+        }
75
+
76
+        throw $exception;
77
+    }
78
+
79
+    protected function setSameSiteCookie() {
80
+        $cookieParams = $this->request->getCookieParams();
81
+        $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : '';
82
+        $policies = [
83
+            'lax',
84
+            'strict',
85
+        ];
86
+
87
+        // Append __Host to the cookie if it meets the requirements
88
+        $cookiePrefix = '';
89
+        if($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
90
+            $cookiePrefix = '__Host-';
91
+        }
92
+
93
+        foreach($policies as $policy) {
94
+            header(
95
+                sprintf(
96
+                    'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
97
+                    $cookiePrefix,
98
+                    $policy,
99
+                    $cookieParams['path'],
100
+                    $policy
101
+                ),
102
+                false
103
+            );
104
+        }
105
+    }
106 106
 }
Please login to merge, or discard this patch.
Middleware/Security/Exceptions/LaxSameSiteCookieFailedException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
  * @package OC\AppFramework\Middleware\Security\Exceptions
33 33
  */
34 34
 class LaxSameSiteCookieFailedException extends SecurityException {
35
-	public function __construct() {
36
-		parent::__construct('Lax Same Site Cookie is invalid in request.', Http::STATUS_PRECONDITION_FAILED);
37
-	}
35
+    public function __construct() {
36
+        parent::__construct('Lax Same Site Cookie is invalid in request.', Http::STATUS_PRECONDITION_FAILED);
37
+    }
38 38
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/ContactsManager.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,60 +29,60 @@
 block discarded – undo
29 29
 use OCP\IURLGenerator;
30 30
 
31 31
 class ContactsManager {
32
-	/** @var CardDavBackend  */
33
-	private $backend;
32
+    /** @var CardDavBackend  */
33
+    private $backend;
34 34
 
35
-	/** @var IL10N  */
36
-	private $l10n;
35
+    /** @var IL10N  */
36
+    private $l10n;
37 37
 
38
-	/**
39
-	 * ContactsManager constructor.
40
-	 *
41
-	 * @param CardDavBackend $backend
42
-	 * @param IL10N $l10n
43
-	 */
44
-	public function __construct(CardDavBackend $backend, IL10N $l10n) {
45
-		$this->backend = $backend;
46
-		$this->l10n = $l10n;
47
-	}
38
+    /**
39
+     * ContactsManager constructor.
40
+     *
41
+     * @param CardDavBackend $backend
42
+     * @param IL10N $l10n
43
+     */
44
+    public function __construct(CardDavBackend $backend, IL10N $l10n) {
45
+        $this->backend = $backend;
46
+        $this->l10n = $l10n;
47
+    }
48 48
 
49
-	/**
50
-	 * @param IManager $cm
51
-	 * @param string $userId
52
-	 * @param IURLGenerator $urlGenerator
53
-	 */
54
-	public function setupContactsProvider(IManager $cm, $userId, IURLGenerator $urlGenerator) {
55
-		$addressBooks = $this->backend->getAddressBooksForUser("principals/users/$userId");
56
-		$this->register($cm, $addressBooks, $urlGenerator);
57
-		$this->setupSystemContactsProvider($cm, $urlGenerator);
58
-	}
49
+    /**
50
+     * @param IManager $cm
51
+     * @param string $userId
52
+     * @param IURLGenerator $urlGenerator
53
+     */
54
+    public function setupContactsProvider(IManager $cm, $userId, IURLGenerator $urlGenerator) {
55
+        $addressBooks = $this->backend->getAddressBooksForUser("principals/users/$userId");
56
+        $this->register($cm, $addressBooks, $urlGenerator);
57
+        $this->setupSystemContactsProvider($cm, $urlGenerator);
58
+    }
59 59
 
60
-	/**
61
-	 * @param IManager $cm
62
-	 * @param IURLGenerator $urlGenerator
63
-	 */
64
-	public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGenerator) {
65
-		$addressBooks = $this->backend->getAddressBooksForUser("principals/system/system");
66
-		$this->register($cm, $addressBooks, $urlGenerator);
67
-	}
60
+    /**
61
+     * @param IManager $cm
62
+     * @param IURLGenerator $urlGenerator
63
+     */
64
+    public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGenerator) {
65
+        $addressBooks = $this->backend->getAddressBooksForUser("principals/system/system");
66
+        $this->register($cm, $addressBooks, $urlGenerator);
67
+    }
68 68
 
69
-	/**
70
-	 * @param IManager $cm
71
-	 * @param $addressBooks
72
-	 * @param IURLGenerator $urlGenerator
73
-	 */
74
-	private function register(IManager $cm, $addressBooks, $urlGenerator) {
75
-		foreach ($addressBooks as $addressBookInfo) {
76
-			$addressBook = new \OCA\DAV\CardDAV\AddressBook($this->backend, $addressBookInfo, $this->l10n);
77
-			$cm->registerAddressBook(
78
-				new AddressBookImpl(
79
-					$addressBook,
80
-					$addressBookInfo,
81
-					$this->backend,
82
-					$urlGenerator
83
-				)
84
-			);
85
-		}
86
-	}
69
+    /**
70
+     * @param IManager $cm
71
+     * @param $addressBooks
72
+     * @param IURLGenerator $urlGenerator
73
+     */
74
+    private function register(IManager $cm, $addressBooks, $urlGenerator) {
75
+        foreach ($addressBooks as $addressBookInfo) {
76
+            $addressBook = new \OCA\DAV\CardDAV\AddressBook($this->backend, $addressBookInfo, $this->l10n);
77
+            $cm->registerAddressBook(
78
+                new AddressBookImpl(
79
+                    $addressBook,
80
+                    $addressBookInfo,
81
+                    $this->backend,
82
+                    $urlGenerator
83
+                )
84
+            );
85
+        }
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.