Completed
Push — master ( ede9e3...c850b3 )
by Morris
15:47
created
lib/private/Archive/Archive.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@
 block discarded – undo
134 134
 				}
135 135
 				if(is_dir($source.'/'.$file)) {
136 136
 					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
137
+				} else{
138 138
 					$this->addFile($path.'/'.$file, $source.'/'.$file);
139 139
 				}
140 140
 			}
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -33,111 +33,111 @@
 block discarded – undo
33 33
 namespace OC\Archive;
34 34
 
35 35
 abstract class Archive {
36
-	/**
37
-	 * @param $source
38
-	 */
39
-	public abstract function __construct($source);
40
-	/**
41
-	 * add an empty folder to the archive
42
-	 * @param string $path
43
-	 * @return bool
44
-	 */
45
-	public abstract function addFolder($path);
46
-	/**
47
-	 * add a file to the archive
48
-	 * @param string $path
49
-	 * @param string $source either a local file or string data
50
-	 * @return bool
51
-	 */
52
-	public abstract function addFile($path, $source='');
53
-	/**
54
-	 * rename a file or folder in the archive
55
-	 * @param string $source
56
-	 * @param string $dest
57
-	 * @return bool
58
-	 */
59
-	public abstract function rename($source, $dest);
60
-	/**
61
-	 * get the uncompressed size of a file in the archive
62
-	 * @param string $path
63
-	 * @return int
64
-	 */
65
-	public abstract function filesize($path);
66
-	/**
67
-	 * get the last modified time of a file in the archive
68
-	 * @param string $path
69
-	 * @return int
70
-	 */
71
-	public abstract function mtime($path);
72
-	/**
73
-	 * get the files in a folder
74
-	 * @param string $path
75
-	 * @return array
76
-	 */
77
-	public abstract function getFolder($path);
78
-	/**
79
-	 * get all files in the archive
80
-	 * @return array
81
-	 */
82
-	public abstract function getFiles();
83
-	/**
84
-	 * get the content of a file
85
-	 * @param string $path
86
-	 * @return string
87
-	 */
88
-	public abstract function getFile($path);
89
-	/**
90
-	 * extract a single file from the archive
91
-	 * @param string $path
92
-	 * @param string $dest
93
-	 * @return bool
94
-	 */
95
-	public abstract function extractFile($path, $dest);
96
-	/**
97
-	 * extract the archive
98
-	 * @param string $dest
99
-	 * @return bool
100
-	 */
101
-	public abstract function extract($dest);
102
-	/**
103
-	 * check if a file or folder exists in the archive
104
-	 * @param string $path
105
-	 * @return bool
106
-	 */
107
-	public abstract function fileExists($path);
108
-	/**
109
-	 * remove a file or folder from the archive
110
-	 * @param string $path
111
-	 * @return bool
112
-	 */
113
-	public abstract function remove($path);
114
-	/**
115
-	 * get a file handler
116
-	 * @param string $path
117
-	 * @param string $mode
118
-	 * @return resource
119
-	 */
120
-	public abstract function getStream($path, $mode);
121
-	/**
122
-	 * add a folder and all its content
123
-	 * @param string $path
124
-	 * @param string $source
125
-	 * @return boolean|null
126
-	 */
127
-	public function addRecursive($path, $source) {
128
-		$dh = opendir($source);
129
-		if(is_resource($dh)) {
130
-			$this->addFolder($path);
131
-			while (($file = readdir($dh)) !== false) {
132
-				if($file === '.' || $file === '..') {
133
-					continue;
134
-				}
135
-				if(is_dir($source.'/'.$file)) {
136
-					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
138
-					$this->addFile($path.'/'.$file, $source.'/'.$file);
139
-				}
140
-			}
141
-		}
142
-	}
36
+    /**
37
+     * @param $source
38
+     */
39
+    public abstract function __construct($source);
40
+    /**
41
+     * add an empty folder to the archive
42
+     * @param string $path
43
+     * @return bool
44
+     */
45
+    public abstract function addFolder($path);
46
+    /**
47
+     * add a file to the archive
48
+     * @param string $path
49
+     * @param string $source either a local file or string data
50
+     * @return bool
51
+     */
52
+    public abstract function addFile($path, $source='');
53
+    /**
54
+     * rename a file or folder in the archive
55
+     * @param string $source
56
+     * @param string $dest
57
+     * @return bool
58
+     */
59
+    public abstract function rename($source, $dest);
60
+    /**
61
+     * get the uncompressed size of a file in the archive
62
+     * @param string $path
63
+     * @return int
64
+     */
65
+    public abstract function filesize($path);
66
+    /**
67
+     * get the last modified time of a file in the archive
68
+     * @param string $path
69
+     * @return int
70
+     */
71
+    public abstract function mtime($path);
72
+    /**
73
+     * get the files in a folder
74
+     * @param string $path
75
+     * @return array
76
+     */
77
+    public abstract function getFolder($path);
78
+    /**
79
+     * get all files in the archive
80
+     * @return array
81
+     */
82
+    public abstract function getFiles();
83
+    /**
84
+     * get the content of a file
85
+     * @param string $path
86
+     * @return string
87
+     */
88
+    public abstract function getFile($path);
89
+    /**
90
+     * extract a single file from the archive
91
+     * @param string $path
92
+     * @param string $dest
93
+     * @return bool
94
+     */
95
+    public abstract function extractFile($path, $dest);
96
+    /**
97
+     * extract the archive
98
+     * @param string $dest
99
+     * @return bool
100
+     */
101
+    public abstract function extract($dest);
102
+    /**
103
+     * check if a file or folder exists in the archive
104
+     * @param string $path
105
+     * @return bool
106
+     */
107
+    public abstract function fileExists($path);
108
+    /**
109
+     * remove a file or folder from the archive
110
+     * @param string $path
111
+     * @return bool
112
+     */
113
+    public abstract function remove($path);
114
+    /**
115
+     * get a file handler
116
+     * @param string $path
117
+     * @param string $mode
118
+     * @return resource
119
+     */
120
+    public abstract function getStream($path, $mode);
121
+    /**
122
+     * add a folder and all its content
123
+     * @param string $path
124
+     * @param string $source
125
+     * @return boolean|null
126
+     */
127
+    public function addRecursive($path, $source) {
128
+        $dh = opendir($source);
129
+        if(is_resource($dh)) {
130
+            $this->addFolder($path);
131
+            while (($file = readdir($dh)) !== false) {
132
+                if($file === '.' || $file === '..') {
133
+                    continue;
134
+                }
135
+                if(is_dir($source.'/'.$file)) {
136
+                    $this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
+                }else{
138
+                    $this->addFile($path.'/'.$file, $source.'/'.$file);
139
+                }
140
+            }
141
+        }
142
+    }
143 143
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param string $source either a local file or string data
50 50
 	 * @return bool
51 51
 	 */
52
-	public abstract function addFile($path, $source='');
52
+	public abstract function addFile($path, $source = '');
53 53
 	/**
54 54
 	 * rename a file or folder in the archive
55 55
 	 * @param string $source
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function addRecursive($path, $source) {
128 128
 		$dh = opendir($source);
129
-		if(is_resource($dh)) {
129
+		if (is_resource($dh)) {
130 130
 			$this->addFolder($path);
131 131
 			while (($file = readdir($dh)) !== false) {
132
-				if($file === '.' || $file === '..') {
132
+				if ($file === '.' || $file === '..') {
133 133
 					continue;
134 134
 				}
135
-				if(is_dir($source.'/'.$file)) {
135
+				if (is_dir($source.'/'.$file)) {
136 136
 					$this->addRecursive($path.'/'.$file, $source.'/'.$file);
137
-				}else{
137
+				} else {
138 138
 					$this->addFile($path.'/'.$file, $source.'/'.$file);
139 139
 				}
140 140
 			}
Please login to merge, or discard this patch.
lib/private/NaturalSort_DefaultCollator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
 namespace OC;
26 26
 
27 27
 class NaturalSort_DefaultCollator {
28
-	public function compare($a, $b) {
29
-		$result = strcasecmp($a, $b);
30
-		if ($result === 0) {
31
-			if ($a === $b) {
32
-				return 0;
33
-			}
34
-			return ($a > $b) ? -1 : 1;
35
-		}
36
-		return ($result < 0) ? -1 : 1;
37
-	}
28
+    public function compare($a, $b) {
29
+        $result = strcasecmp($a, $b);
30
+        if ($result === 0) {
31
+            if ($a === $b) {
32
+                return 0;
33
+            }
34
+            return ($a > $b) ? -1 : 1;
35
+        }
36
+        return ($result < 0) ? -1 : 1;
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 4 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			parent::__construct( 'core', 'layout.user' );
62 62
 			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63 63
 				$this->assign('bodyid', 'body-settings');
64
-			}else{
64
+			} else{
65 65
 				$this->assign('bodyid', 'body-user');
66 66
 			}
67 67
 
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,6 @@
 block discarded – undo
42 42
 use OC\Template\JSConfigHelper;
43 43
 use OC\Template\SCSSCacher;
44 44
 use OCP\Defaults;
45
-use OC\AppFramework\Http\Request;
46 45
 
47 46
 class TemplateLayout extends \OC_Template {
48 47
 
Please login to merge, or discard this patch.
Indentation   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -46,291 +46,291 @@
 block discarded – undo
46 46
 
47 47
 class TemplateLayout extends \OC_Template {
48 48
 
49
-	private static $versionHash = '';
50
-
51
-	/**
52
-	 * @var \OCP\IConfig
53
-	 */
54
-	private $config;
55
-
56
-	/**
57
-	 * @param string $renderAs
58
-	 * @param string $appId application id
59
-	 */
60
-	public function __construct( $renderAs, $appId = '' ) {
61
-
62
-		// yes - should be injected ....
63
-		$this->config = \OC::$server->getConfig();
64
-
65
-		if(\OCP\Util::isIE()) {
66
-			\OC_Util::addStyle('ie');
67
-		}
68
-
69
-		// Decide which page we show
70
-		if($renderAs == 'user') {
71
-			parent::__construct( 'core', 'layout.user' );
72
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
73
-				$this->assign('bodyid', 'body-settings');
74
-			}else{
75
-				$this->assign('bodyid', 'body-user');
76
-			}
77
-
78
-			// Code integrity notification
79
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
80
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
81
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
82
-			}
83
-
84
-			// Add navigation entry
85
-			$this->assign( 'application', '');
86
-			$this->assign( 'appid', $appId );
87
-			$navigation = \OC::$server->getNavigationManager()->getAll();
88
-			$this->assign( 'navigation', $navigation);
89
-			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
90
-			$this->assign( 'settingsnavigation', $settingsNavigation);
91
-			foreach($navigation as $entry) {
92
-				if ($entry['active']) {
93
-					$this->assign( 'application', $entry['name'] );
94
-					break;
95
-				}
96
-			}
97
-
98
-			foreach($settingsNavigation as $entry) {
99
-				if ($entry['active']) {
100
-					$this->assign( 'application', $entry['name'] );
101
-					break;
102
-				}
103
-			}
104
-			$userDisplayName = \OC_User::getDisplayName();
105
-			$this->assign('user_displayname', $userDisplayName);
106
-			$this->assign('user_uid', \OC_User::getUser());
107
-
108
-			if (\OC_User::getUser() === false) {
109
-				$this->assign('userAvatarSet', false);
110
-			} else {
111
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
112
-				$this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
113
-			}
114
-
115
-			// check if app menu icons should be inverted
116
-			try {
117
-				/** @var \OCA\Theming\Util $util */
118
-				$util = \OC::$server->query(\OCA\Theming\Util::class);
119
-				$this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
120
-			} catch (\OCP\AppFramework\QueryException $e) {
121
-				$this->assign('themingInvertMenu', false);
122
-			}
123
-
124
-		} else if ($renderAs == 'error') {
125
-			parent::__construct('core', 'layout.guest', '', false);
126
-			$this->assign('bodyid', 'body-login');
127
-		} else if ($renderAs == 'guest') {
128
-			parent::__construct('core', 'layout.guest');
129
-			\OC_Util::addStyle('guest');
130
-			$this->assign('bodyid', 'body-login');
131
-		} else if ($renderAs == 'public') {
132
-			parent::__construct('core', 'layout.public');
133
-			$this->assign( 'appid', $appId );
134
-			$this->assign('bodyid', 'body-public');
135
-			$this->assign('showSimpleSignUpLink', $this->config->getSystemValue('simpleSignUpLink.shown', true) !== false);
136
-		} else {
137
-			parent::__construct('core', 'layout.base');
138
-
139
-		}
140
-		// Send the language and the locale to our layouts
141
-		$lang = \OC::$server->getL10NFactory()->findLanguage();
142
-		$lang = str_replace('_', '-', $lang);
143
-		$this->assign('language', $lang);
144
-		$this->assign('locale', \OC::$server->getL10NFactory()->findLocale($lang));
145
-
146
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
147
-			if (empty(self::$versionHash)) {
148
-				$v = \OC_App::getAppVersions();
149
-				$v['core'] = implode('.', \OCP\Util::getVersion());
150
-				self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
151
-			}
152
-		} else {
153
-			self::$versionHash = md5('not installed');
154
-		}
155
-
156
-		// Add the js files
157
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
158
-		$this->assign('jsfiles', array());
159
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
160
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
161
-				$jsConfigHelper = new JSConfigHelper(
162
-					\OC::$server->getL10N('lib'),
163
-					\OC::$server->query(Defaults::class),
164
-					\OC::$server->getAppManager(),
165
-					\OC::$server->getSession(),
166
-					\OC::$server->getUserSession()->getUser(),
167
-					$this->config,
168
-					\OC::$server->getGroupManager(),
169
-					\OC::$server->getIniWrapper(),
170
-					\OC::$server->getURLGenerator(),
171
-					\OC::$server->getCapabilitiesManager()
172
-				);
173
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
174
-			} else {
175
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
176
-			}
177
-		}
178
-		foreach($jsFiles as $info) {
179
-			$web = $info[1];
180
-			$file = $info[2];
181
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
182
-		}
183
-
184
-		try {
185
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
186
-		} catch (\Exception $e) {
187
-			$pathInfo = '';
188
-		}
189
-
190
-		// Do not initialise scss appdata until we have a fully installed instance
191
-		// Do not load scss for update, errors, installation or login page
192
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
193
-			&& !\OCP\Util::needUpgrade()
194
-			&& $pathInfo !== ''
195
-			&& !preg_match('/^\/login/', $pathInfo)
196
-			&& $renderAs !== 'error'
197
-		) {
198
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
199
-		} else {
200
-			// If we ignore the scss compiler,
201
-			// we need to load the guest css fallback
202
-			\OC_Util::addStyle('guest');
203
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
204
-		}
205
-
206
-		$this->assign('cssfiles', array());
207
-		$this->assign('printcssfiles', []);
208
-		$this->assign('versionHash', self::$versionHash);
209
-		foreach($cssFiles as $info) {
210
-			$web = $info[1];
211
-			$file = $info[2];
212
-
213
-			if (substr($file, -strlen('print.css')) === 'print.css') {
214
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
215
-			} else {
216
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
217
-			}
218
-		}
219
-	}
220
-
221
-	/**
222
-	 * @param string $path
223
- 	 * @param string $file
224
-	 * @return string
225
-	 */
226
-	protected function getVersionHashSuffix($path = false, $file = false) {
227
-		if ($this->config->getSystemValue('debug', false)) {
228
-			// allows chrome workspace mapping in debug mode
229
-			return "";
230
-		}
231
-		$themingSuffix = '';
232
-		$v = [];
233
-
234
-		if ($this->config->getSystemValue('installed', false)) {
235
-			if (\OC::$server->getAppManager()->isInstalled('theming')) {
236
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
237
-			}
238
-			$v = \OC_App::getAppVersions();
239
-		}
240
-
241
-		// Try the webroot path for a match
242
-		if ($path !== false && $path !== '') {
243
-			$appName = $this->getAppNamefromPath($path);
244
-			if(array_key_exists($appName, $v)) {
245
-				$appVersion = $v[$appName];
246
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
247
-			}
248
-		}
249
-		// fallback to the file path instead
250
-		if ($file !== false && $file !== '') {
251
-			$appName = $this->getAppNamefromPath($file);
252
-			if(array_key_exists($appName, $v)) {
253
-				$appVersion = $v[$appName];
254
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
255
-			}
256
-		}
257
-
258
-		return '?v=' . self::$versionHash . $themingSuffix;
259
-	}
260
-
261
-	/**
262
-	 * @param array $styles
263
-	 * @return array
264
-	 */
265
-	static public function findStylesheetFiles($styles, $compileScss = true) {
266
-		// Read the selected theme from the config file
267
-		$theme = \OC_Util::getTheme();
268
-
269
-		if($compileScss) {
270
-			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
271
-		} else {
272
-			$SCSSCacher = null;
273
-		}
274
-
275
-		$locator = new \OC\Template\CSSResourceLocator(
276
-			\OC::$server->getLogger(),
277
-			$theme,
278
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
279
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
280
-			$SCSSCacher
281
-		);
282
-		$locator->find($styles);
283
-		return $locator->getResources();
284
-	}
285
-
286
-	/**
287
-	 * @param string $path
288
-	 * @return string|boolean
289
-	 */
290
-	public function getAppNamefromPath($path) {
291
-		if ($path !== '' && is_string($path)) {
292
-			$pathParts = explode('/', $path);
293
-			if ($pathParts[0] === 'css') {
294
-				// This is a scss request
295
-				return $pathParts[1];
296
-			}
297
-			return end($pathParts);
298
-		}
299
-		return false;
300
-
301
-	}
302
-
303
-	/**
304
-	 * @param array $scripts
305
-	 * @return array
306
-	 */
307
-	static public function findJavascriptFiles($scripts) {
308
-		// Read the selected theme from the config file
309
-		$theme = \OC_Util::getTheme();
310
-
311
-		$locator = new \OC\Template\JSResourceLocator(
312
-			\OC::$server->getLogger(),
313
-			$theme,
314
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
315
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
316
-			\OC::$server->query(JSCombiner::class)
317
-			);
318
-		$locator->find($scripts);
319
-		return $locator->getResources();
320
-	}
321
-
322
-	/**
323
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
324
-	 * @param string $filePath Absolute path
325
-	 * @return string Relative path
326
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
327
-	 */
328
-	public static function convertToRelativePath($filePath) {
329
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
330
-		if(count($relativePath) !== 2) {
331
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
332
-		}
333
-
334
-		return $relativePath[1];
335
-	}
49
+    private static $versionHash = '';
50
+
51
+    /**
52
+     * @var \OCP\IConfig
53
+     */
54
+    private $config;
55
+
56
+    /**
57
+     * @param string $renderAs
58
+     * @param string $appId application id
59
+     */
60
+    public function __construct( $renderAs, $appId = '' ) {
61
+
62
+        // yes - should be injected ....
63
+        $this->config = \OC::$server->getConfig();
64
+
65
+        if(\OCP\Util::isIE()) {
66
+            \OC_Util::addStyle('ie');
67
+        }
68
+
69
+        // Decide which page we show
70
+        if($renderAs == 'user') {
71
+            parent::__construct( 'core', 'layout.user' );
72
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
73
+                $this->assign('bodyid', 'body-settings');
74
+            }else{
75
+                $this->assign('bodyid', 'body-user');
76
+            }
77
+
78
+            // Code integrity notification
79
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
80
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
81
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
82
+            }
83
+
84
+            // Add navigation entry
85
+            $this->assign( 'application', '');
86
+            $this->assign( 'appid', $appId );
87
+            $navigation = \OC::$server->getNavigationManager()->getAll();
88
+            $this->assign( 'navigation', $navigation);
89
+            $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
90
+            $this->assign( 'settingsnavigation', $settingsNavigation);
91
+            foreach($navigation as $entry) {
92
+                if ($entry['active']) {
93
+                    $this->assign( 'application', $entry['name'] );
94
+                    break;
95
+                }
96
+            }
97
+
98
+            foreach($settingsNavigation as $entry) {
99
+                if ($entry['active']) {
100
+                    $this->assign( 'application', $entry['name'] );
101
+                    break;
102
+                }
103
+            }
104
+            $userDisplayName = \OC_User::getDisplayName();
105
+            $this->assign('user_displayname', $userDisplayName);
106
+            $this->assign('user_uid', \OC_User::getUser());
107
+
108
+            if (\OC_User::getUser() === false) {
109
+                $this->assign('userAvatarSet', false);
110
+            } else {
111
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
112
+                $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
113
+            }
114
+
115
+            // check if app menu icons should be inverted
116
+            try {
117
+                /** @var \OCA\Theming\Util $util */
118
+                $util = \OC::$server->query(\OCA\Theming\Util::class);
119
+                $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
120
+            } catch (\OCP\AppFramework\QueryException $e) {
121
+                $this->assign('themingInvertMenu', false);
122
+            }
123
+
124
+        } else if ($renderAs == 'error') {
125
+            parent::__construct('core', 'layout.guest', '', false);
126
+            $this->assign('bodyid', 'body-login');
127
+        } else if ($renderAs == 'guest') {
128
+            parent::__construct('core', 'layout.guest');
129
+            \OC_Util::addStyle('guest');
130
+            $this->assign('bodyid', 'body-login');
131
+        } else if ($renderAs == 'public') {
132
+            parent::__construct('core', 'layout.public');
133
+            $this->assign( 'appid', $appId );
134
+            $this->assign('bodyid', 'body-public');
135
+            $this->assign('showSimpleSignUpLink', $this->config->getSystemValue('simpleSignUpLink.shown', true) !== false);
136
+        } else {
137
+            parent::__construct('core', 'layout.base');
138
+
139
+        }
140
+        // Send the language and the locale to our layouts
141
+        $lang = \OC::$server->getL10NFactory()->findLanguage();
142
+        $lang = str_replace('_', '-', $lang);
143
+        $this->assign('language', $lang);
144
+        $this->assign('locale', \OC::$server->getL10NFactory()->findLocale($lang));
145
+
146
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
147
+            if (empty(self::$versionHash)) {
148
+                $v = \OC_App::getAppVersions();
149
+                $v['core'] = implode('.', \OCP\Util::getVersion());
150
+                self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
151
+            }
152
+        } else {
153
+            self::$versionHash = md5('not installed');
154
+        }
155
+
156
+        // Add the js files
157
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
158
+        $this->assign('jsfiles', array());
159
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
160
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
161
+                $jsConfigHelper = new JSConfigHelper(
162
+                    \OC::$server->getL10N('lib'),
163
+                    \OC::$server->query(Defaults::class),
164
+                    \OC::$server->getAppManager(),
165
+                    \OC::$server->getSession(),
166
+                    \OC::$server->getUserSession()->getUser(),
167
+                    $this->config,
168
+                    \OC::$server->getGroupManager(),
169
+                    \OC::$server->getIniWrapper(),
170
+                    \OC::$server->getURLGenerator(),
171
+                    \OC::$server->getCapabilitiesManager()
172
+                );
173
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
174
+            } else {
175
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
176
+            }
177
+        }
178
+        foreach($jsFiles as $info) {
179
+            $web = $info[1];
180
+            $file = $info[2];
181
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
182
+        }
183
+
184
+        try {
185
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
186
+        } catch (\Exception $e) {
187
+            $pathInfo = '';
188
+        }
189
+
190
+        // Do not initialise scss appdata until we have a fully installed instance
191
+        // Do not load scss for update, errors, installation or login page
192
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
193
+            && !\OCP\Util::needUpgrade()
194
+            && $pathInfo !== ''
195
+            && !preg_match('/^\/login/', $pathInfo)
196
+            && $renderAs !== 'error'
197
+        ) {
198
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
199
+        } else {
200
+            // If we ignore the scss compiler,
201
+            // we need to load the guest css fallback
202
+            \OC_Util::addStyle('guest');
203
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
204
+        }
205
+
206
+        $this->assign('cssfiles', array());
207
+        $this->assign('printcssfiles', []);
208
+        $this->assign('versionHash', self::$versionHash);
209
+        foreach($cssFiles as $info) {
210
+            $web = $info[1];
211
+            $file = $info[2];
212
+
213
+            if (substr($file, -strlen('print.css')) === 'print.css') {
214
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
215
+            } else {
216
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
217
+            }
218
+        }
219
+    }
220
+
221
+    /**
222
+     * @param string $path
223
+     * @param string $file
224
+     * @return string
225
+     */
226
+    protected function getVersionHashSuffix($path = false, $file = false) {
227
+        if ($this->config->getSystemValue('debug', false)) {
228
+            // allows chrome workspace mapping in debug mode
229
+            return "";
230
+        }
231
+        $themingSuffix = '';
232
+        $v = [];
233
+
234
+        if ($this->config->getSystemValue('installed', false)) {
235
+            if (\OC::$server->getAppManager()->isInstalled('theming')) {
236
+                $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
237
+            }
238
+            $v = \OC_App::getAppVersions();
239
+        }
240
+
241
+        // Try the webroot path for a match
242
+        if ($path !== false && $path !== '') {
243
+            $appName = $this->getAppNamefromPath($path);
244
+            if(array_key_exists($appName, $v)) {
245
+                $appVersion = $v[$appName];
246
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
247
+            }
248
+        }
249
+        // fallback to the file path instead
250
+        if ($file !== false && $file !== '') {
251
+            $appName = $this->getAppNamefromPath($file);
252
+            if(array_key_exists($appName, $v)) {
253
+                $appVersion = $v[$appName];
254
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
255
+            }
256
+        }
257
+
258
+        return '?v=' . self::$versionHash . $themingSuffix;
259
+    }
260
+
261
+    /**
262
+     * @param array $styles
263
+     * @return array
264
+     */
265
+    static public function findStylesheetFiles($styles, $compileScss = true) {
266
+        // Read the selected theme from the config file
267
+        $theme = \OC_Util::getTheme();
268
+
269
+        if($compileScss) {
270
+            $SCSSCacher = \OC::$server->query(SCSSCacher::class);
271
+        } else {
272
+            $SCSSCacher = null;
273
+        }
274
+
275
+        $locator = new \OC\Template\CSSResourceLocator(
276
+            \OC::$server->getLogger(),
277
+            $theme,
278
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
279
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
280
+            $SCSSCacher
281
+        );
282
+        $locator->find($styles);
283
+        return $locator->getResources();
284
+    }
285
+
286
+    /**
287
+     * @param string $path
288
+     * @return string|boolean
289
+     */
290
+    public function getAppNamefromPath($path) {
291
+        if ($path !== '' && is_string($path)) {
292
+            $pathParts = explode('/', $path);
293
+            if ($pathParts[0] === 'css') {
294
+                // This is a scss request
295
+                return $pathParts[1];
296
+            }
297
+            return end($pathParts);
298
+        }
299
+        return false;
300
+
301
+    }
302
+
303
+    /**
304
+     * @param array $scripts
305
+     * @return array
306
+     */
307
+    static public function findJavascriptFiles($scripts) {
308
+        // Read the selected theme from the config file
309
+        $theme = \OC_Util::getTheme();
310
+
311
+        $locator = new \OC\Template\JSResourceLocator(
312
+            \OC::$server->getLogger(),
313
+            $theme,
314
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
315
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
316
+            \OC::$server->query(JSCombiner::class)
317
+            );
318
+        $locator->find($scripts);
319
+        return $locator->getResources();
320
+    }
321
+
322
+    /**
323
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
324
+     * @param string $filePath Absolute path
325
+     * @return string Relative path
326
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
327
+     */
328
+    public static function convertToRelativePath($filePath) {
329
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
330
+        if(count($relativePath) !== 2) {
331
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
332
+        }
333
+
334
+        return $relativePath[1];
335
+    }
336 336
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -57,47 +57,47 @@  discard block
 block discarded – undo
57 57
 	 * @param string $renderAs
58 58
 	 * @param string $appId application id
59 59
 	 */
60
-	public function __construct( $renderAs, $appId = '' ) {
60
+	public function __construct($renderAs, $appId = '') {
61 61
 
62 62
 		// yes - should be injected ....
63 63
 		$this->config = \OC::$server->getConfig();
64 64
 
65
-		if(\OCP\Util::isIE()) {
65
+		if (\OCP\Util::isIE()) {
66 66
 			\OC_Util::addStyle('ie');
67 67
 		}
68 68
 
69 69
 		// Decide which page we show
70
-		if($renderAs == 'user') {
71
-			parent::__construct( 'core', 'layout.user' );
72
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
70
+		if ($renderAs == 'user') {
71
+			parent::__construct('core', 'layout.user');
72
+			if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) {
73 73
 				$this->assign('bodyid', 'body-settings');
74
-			}else{
74
+			} else {
75 75
 				$this->assign('bodyid', 'body-user');
76 76
 			}
77 77
 
78 78
 			// Code integrity notification
79 79
 			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
80
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
80
+			if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
81 81
 				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
82 82
 			}
83 83
 
84 84
 			// Add navigation entry
85
-			$this->assign( 'application', '');
86
-			$this->assign( 'appid', $appId );
85
+			$this->assign('application', '');
86
+			$this->assign('appid', $appId);
87 87
 			$navigation = \OC::$server->getNavigationManager()->getAll();
88
-			$this->assign( 'navigation', $navigation);
88
+			$this->assign('navigation', $navigation);
89 89
 			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
90
-			$this->assign( 'settingsnavigation', $settingsNavigation);
91
-			foreach($navigation as $entry) {
90
+			$this->assign('settingsnavigation', $settingsNavigation);
91
+			foreach ($navigation as $entry) {
92 92
 				if ($entry['active']) {
93
-					$this->assign( 'application', $entry['name'] );
93
+					$this->assign('application', $entry['name']);
94 94
 					break;
95 95
 				}
96 96
 			}
97 97
 
98
-			foreach($settingsNavigation as $entry) {
98
+			foreach ($settingsNavigation as $entry) {
99 99
 				if ($entry['active']) {
100
-					$this->assign( 'application', $entry['name'] );
100
+					$this->assign('application', $entry['name']);
101 101
 					break;
102 102
 				}
103 103
 			}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			$this->assign('bodyid', 'body-login');
131 131
 		} else if ($renderAs == 'public') {
132 132
 			parent::__construct('core', 'layout.public');
133
-			$this->assign( 'appid', $appId );
133
+			$this->assign('appid', $appId);
134 134
 			$this->assign('bodyid', 'body-public');
135 135
 			$this->assign('showSimpleSignUpLink', $this->config->getSystemValue('simpleSignUpLink.shown', true) !== false);
136 136
 		} else {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$this->assign('language', $lang);
144 144
 		$this->assign('locale', \OC::$server->getL10NFactory()->findLocale($lang));
145 145
 
146
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
146
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
147 147
 			if (empty(self::$versionHash)) {
148 148
 				$v = \OC_App::getAppVersions();
149 149
 				$v['core'] = implode('.', \OCP\Util::getVersion());
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
176 176
 			}
177 177
 		}
178
-		foreach($jsFiles as $info) {
178
+		foreach ($jsFiles as $info) {
179 179
 			$web = $info[1];
180 180
 			$file = $info[2];
181
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
181
+			$this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix());
182 182
 		}
183 183
 
184 184
 		try {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 		// Do not initialise scss appdata until we have a fully installed instance
191 191
 		// Do not load scss for update, errors, installation or login page
192
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
192
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)
193 193
 			&& !\OCP\Util::needUpgrade()
194 194
 			&& $pathInfo !== ''
195 195
 			&& !preg_match('/^\/login/', $pathInfo)
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 		$this->assign('cssfiles', array());
207 207
 		$this->assign('printcssfiles', []);
208 208
 		$this->assign('versionHash', self::$versionHash);
209
-		foreach($cssFiles as $info) {
209
+		foreach ($cssFiles as $info) {
210 210
 			$web = $info[1];
211 211
 			$file = $info[2];
212 212
 
213 213
 			if (substr($file, -strlen('print.css')) === 'print.css') {
214
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
214
+				$this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix());
215 215
 			} else {
216
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file)  );
216
+				$this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix($web, $file));
217 217
 			}
218 218
 		}
219 219
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 		if ($this->config->getSystemValue('installed', false)) {
235 235
 			if (\OC::$server->getAppManager()->isInstalled('theming')) {
236
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
236
+				$themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0');
237 237
 			}
238 238
 			$v = \OC_App::getAppVersions();
239 239
 		}
@@ -241,21 +241,21 @@  discard block
 block discarded – undo
241 241
 		// Try the webroot path for a match
242 242
 		if ($path !== false && $path !== '') {
243 243
 			$appName = $this->getAppNamefromPath($path);
244
-			if(array_key_exists($appName, $v)) {
244
+			if (array_key_exists($appName, $v)) {
245 245
 				$appVersion = $v[$appName];
246
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
246
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
247 247
 			}
248 248
 		}
249 249
 		// fallback to the file path instead
250 250
 		if ($file !== false && $file !== '') {
251 251
 			$appName = $this->getAppNamefromPath($file);
252
-			if(array_key_exists($appName, $v)) {
252
+			if (array_key_exists($appName, $v)) {
253 253
 				$appVersion = $v[$appName];
254
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
254
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
255 255
 			}
256 256
 		}
257 257
 
258
-		return '?v=' . self::$versionHash . $themingSuffix;
258
+		return '?v='.self::$versionHash.$themingSuffix;
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		// Read the selected theme from the config file
267 267
 		$theme = \OC_Util::getTheme();
268 268
 
269
-		if($compileScss) {
269
+		if ($compileScss) {
270 270
 			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
271 271
 		} else {
272 272
 			$SCSSCacher = null;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 		$locator = new \OC\Template\CSSResourceLocator(
276 276
 			\OC::$server->getLogger(),
277 277
 			$theme,
278
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
279
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
278
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
279
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
280 280
 			$SCSSCacher
281 281
 		);
282 282
 		$locator->find($styles);
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 		$locator = new \OC\Template\JSResourceLocator(
312 312
 			\OC::$server->getLogger(),
313 313
 			$theme,
314
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
315
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
314
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
315
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
316 316
 			\OC::$server->query(JSCombiner::class)
317 317
 			);
318 318
 		$locator->find($scripts);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	public static function convertToRelativePath($filePath) {
329 329
 		$relativePath = explode(\OC::$SERVERROOT, $filePath);
330
-		if(count($relativePath) !== 2) {
330
+		if (count($relativePath) !== 2) {
331 331
 			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
332 332
 		}
333 333
 
Please login to merge, or discard this patch.
lib/private/Migration/BackgroundRepair.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function execute($jobList, ILogger $logger = null) {
59 59
 		// add an interval of 15 mins
60
-		$this->setInterval(15*60);
60
+		$this->setInterval(15 * 60);
61 61
 
62 62
 		$this->jobList = $jobList;
63 63
 		$this->logger = $logger;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		try {
91 91
 			$repair->addStep($step);
92 92
 		} catch (\Exception $ex) {
93
-			$this->logger->logException($ex,[
93
+			$this->logger->logException($ex, [
94 94
 				'app' => 'migration'
95 95
 			]);
96 96
 
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -37,81 +37,81 @@
 block discarded – undo
37 37
  */
38 38
 class BackgroundRepair extends TimedJob {
39 39
 
40
-	/** @var IJobList */
41
-	private $jobList;
40
+    /** @var IJobList */
41
+    private $jobList;
42 42
 
43
-	/** @var ILogger */
44
-	private $logger;
43
+    /** @var ILogger */
44
+    private $logger;
45 45
 
46
-	/** @var EventDispatcher */
47
-	private $dispatcher;
46
+    /** @var EventDispatcher */
47
+    private $dispatcher;
48 48
 
49
-	public function setDispatcher(EventDispatcher $dispatcher) {
50
-		$this->dispatcher = $dispatcher;
51
-	}
52
-	/**
53
-	 * run the job, then remove it from the job list
54
-	 *
55
-	 * @param JobList $jobList
56
-	 * @param ILogger|null $logger
57
-	 */
58
-	public function execute($jobList, ILogger $logger = null) {
59
-		// add an interval of 15 mins
60
-		$this->setInterval(15*60);
49
+    public function setDispatcher(EventDispatcher $dispatcher) {
50
+        $this->dispatcher = $dispatcher;
51
+    }
52
+    /**
53
+     * run the job, then remove it from the job list
54
+     *
55
+     * @param JobList $jobList
56
+     * @param ILogger|null $logger
57
+     */
58
+    public function execute($jobList, ILogger $logger = null) {
59
+        // add an interval of 15 mins
60
+        $this->setInterval(15*60);
61 61
 
62
-		$this->jobList = $jobList;
63
-		$this->logger = $logger;
64
-		parent::execute($jobList, $logger);
65
-	}
62
+        $this->jobList = $jobList;
63
+        $this->logger = $logger;
64
+        parent::execute($jobList, $logger);
65
+    }
66 66
 
67
-	/**
68
-	 * @param array $argument
69
-	 * @throws \Exception
70
-	 * @throws \OC\NeedsUpdateException
71
-	 */
72
-	protected function run($argument) {
73
-		if (!isset($argument['app']) || !isset($argument['step'])) {
74
-			// remove the job - we can never execute it
75
-			$this->jobList->remove($this, $this->argument);
76
-			return;
77
-		}
78
-		$app = $argument['app'];
67
+    /**
68
+     * @param array $argument
69
+     * @throws \Exception
70
+     * @throws \OC\NeedsUpdateException
71
+     */
72
+    protected function run($argument) {
73
+        if (!isset($argument['app']) || !isset($argument['step'])) {
74
+            // remove the job - we can never execute it
75
+            $this->jobList->remove($this, $this->argument);
76
+            return;
77
+        }
78
+        $app = $argument['app'];
79 79
 
80
-		try {
81
-			$this->loadApp($app);
82
-		} catch (NeedsUpdateException $ex) {
83
-			// as long as the app is not yet done with it's offline migration
84
-			// we better not start with the live migration
85
-			return;
86
-		}
80
+        try {
81
+            $this->loadApp($app);
82
+        } catch (NeedsUpdateException $ex) {
83
+            // as long as the app is not yet done with it's offline migration
84
+            // we better not start with the live migration
85
+            return;
86
+        }
87 87
 
88
-		$step = $argument['step'];
89
-		$repair = new Repair([], $this->dispatcher);
90
-		try {
91
-			$repair->addStep($step);
92
-		} catch (\Exception $ex) {
93
-			$this->logger->logException($ex,[
94
-				'app' => 'migration'
95
-			]);
88
+        $step = $argument['step'];
89
+        $repair = new Repair([], $this->dispatcher);
90
+        try {
91
+            $repair->addStep($step);
92
+        } catch (\Exception $ex) {
93
+            $this->logger->logException($ex,[
94
+                'app' => 'migration'
95
+            ]);
96 96
 
97
-			// remove the job - we can never execute it
98
-			$this->jobList->remove($this, $this->argument);
99
-			return;
100
-		}
97
+            // remove the job - we can never execute it
98
+            $this->jobList->remove($this, $this->argument);
99
+            return;
100
+        }
101 101
 
102
-		// execute the repair step
103
-		$repair->run();
102
+        // execute the repair step
103
+        $repair->run();
104 104
 
105
-		// remove the job once executed successfully
106
-		$this->jobList->remove($this, $this->argument);
107
-	}
105
+        // remove the job once executed successfully
106
+        $this->jobList->remove($this, $this->argument);
107
+    }
108 108
 
109
-	/**
110
-	 * @codeCoverageIgnore
111
-	 * @param $app
112
-	 * @throws NeedsUpdateException
113
-	 */
114
-	protected function loadApp($app) {
115
-		OC_App::loadApp($app);
116
-	}
109
+    /**
110
+     * @codeCoverageIgnore
111
+     * @param $app
112
+     * @throws NeedsUpdateException
113
+     */
114
+    protected function loadApp($app) {
115
+        OC_App::loadApp($app);
116
+    }
117 117
 }
Please login to merge, or discard this patch.
lib/private/Command/QueueBus.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		if ($command instanceof ICommand) {
56 56
 			// ensure the command can be serialized
57 57
 			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
58
+			if (strlen($serialized) > 4000) {
59 59
 				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60 60
 			}
61 61
 			$unserialized = unserialize($serialized);
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,48 +26,48 @@
 block discarded – undo
26 26
 use OCP\Command\ICommand;
27 27
 
28 28
 class QueueBus implements IBus {
29
-	/**
30
-	 * @var ICommand[]|callable[]
31
-	 */
32
-	private $queue = [];
29
+    /**
30
+     * @var ICommand[]|callable[]
31
+     */
32
+    private $queue = [];
33 33
 
34
-	/**
35
-	 * Schedule a command to be fired
36
-	 *
37
-	 * @param \OCP\Command\ICommand | callable $command
38
-	 */
39
-	public function push($command) {
40
-		$this->queue[] = $command;
41
-	}
34
+    /**
35
+     * Schedule a command to be fired
36
+     *
37
+     * @param \OCP\Command\ICommand | callable $command
38
+     */
39
+    public function push($command) {
40
+        $this->queue[] = $command;
41
+    }
42 42
 
43
-	/**
44
-	 * Require all commands using a trait to be run synchronous
45
-	 *
46
-	 * @param string $trait
47
-	 */
48
-	public function requireSync($trait) {
49
-	}
43
+    /**
44
+     * Require all commands using a trait to be run synchronous
45
+     *
46
+     * @param string $trait
47
+     */
48
+    public function requireSync($trait) {
49
+    }
50 50
 
51
-	/**
52
-	 * @param \OCP\Command\ICommand | callable $command
53
-	 */
54
-	private function runCommand($command) {
55
-		if ($command instanceof ICommand) {
56
-			// ensure the command can be serialized
57
-			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
59
-				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
-			}
61
-			$unserialized = unserialize($serialized);
62
-			$unserialized->handle();
63
-		} else {
64
-			$command();
65
-		}
66
-	}
51
+    /**
52
+     * @param \OCP\Command\ICommand | callable $command
53
+     */
54
+    private function runCommand($command) {
55
+        if ($command instanceof ICommand) {
56
+            // ensure the command can be serialized
57
+            $serialized = serialize($command);
58
+            if(strlen($serialized) > 4000) {
59
+                throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
+            }
61
+            $unserialized = unserialize($serialized);
62
+            $unserialized->handle();
63
+        } else {
64
+            $command();
65
+        }
66
+    }
67 67
 
68
-	public function run() {
69
-		while ($command = array_shift($this->queue)) {
70
-			$this->runCommand($command);
71
-		}
72
-	}
68
+    public function run() {
69
+        while ($command = array_shift($this->queue)) {
70
+            $this->runCommand($command);
71
+        }
72
+    }
73 73
 }
Please login to merge, or discard this patch.
lib/private/Command/CallableJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OC\BackgroundJob\QueuedJob;
26 26
 
27 27
 class CallableJob extends QueuedJob {
28
-	protected function run($serializedCallable) {
29
-		$callable = unserialize($serializedCallable);
30
-		if (is_callable($callable)) {
31
-			$callable();
32
-		} else {
33
-			throw new \InvalidArgumentException('Invalid serialized callable');
34
-		}
35
-	}
28
+    protected function run($serializedCallable) {
29
+        $callable = unserialize($serializedCallable);
30
+        if (is_callable($callable)) {
31
+            $callable();
32
+        } else {
33
+            throw new \InvalidArgumentException('Invalid serialized callable');
34
+        }
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Command/ClosureJob.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 use SuperClosure\Serializer;
27 27
 
28 28
 class ClosureJob extends QueuedJob {
29
-	protected function run($serializedCallable) {
30
-		$serializer = new Serializer();
31
-		$callable = $serializer->unserialize($serializedCallable);
32
-		if (is_callable($callable)) {
33
-			$callable();
34
-		} else {
35
-			throw new \InvalidArgumentException('Invalid serialized callable');
36
-		}
37
-	}
29
+    protected function run($serializedCallable) {
30
+        $serializer = new Serializer();
31
+        $callable = $serializer->unserialize($serializedCallable);
32
+        if (is_callable($callable)) {
33
+            $callable();
34
+        } else {
35
+            throw new \InvalidArgumentException('Invalid serialized callable');
36
+        }
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
29
-		\OC_Util::setupFS($user->getUID());
30
-	}
28
+    protected function setupFS(IUser $user){
29
+        \OC_Util::setupFS($user->getUID());
30
+    }
31 31
 
32
-	protected function getUserFolder(IUser $user) {
33
-		$this->setupFS($user);
34
-		return \OC::$server->getUserFolder($user->getUID());
35
-	}
32
+    protected function getUserFolder(IUser $user) {
33
+        $this->setupFS($user);
34
+        return \OC::$server->getUserFolder($user->getUID());
35
+    }
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
28
+	protected function setupFS(IUser $user) {
29 29
 		\OC_Util::setupFS($user->getUID());
30 30
 	}
31 31
 
Please login to merge, or discard this patch.
lib/private/Command/CommandJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  * Wrap a command in the background job interface
30 30
  */
31 31
 class CommandJob extends QueuedJob {
32
-	protected function run($serializedCommand) {
33
-		$command = unserialize($serializedCommand);
34
-		if ($command instanceof ICommand) {
35
-			$command->handle();
36
-		} else {
37
-			throw new \InvalidArgumentException('Invalid serialized command');
38
-		}
39
-	}
32
+    protected function run($serializedCommand) {
33
+        $command = unserialize($serializedCommand);
34
+        if ($command instanceof ICommand) {
35
+            $command->handle();
36
+        } else {
37
+            throw new \InvalidArgumentException('Invalid serialized command');
38
+        }
39
+    }
40 40
 }
Please login to merge, or discard this patch.