Passed
Push — master ( 89e8b2...a3deb2 )
by Roeland
21:46 queued 12:09
created
lib/private/Repair/NC17/SetEnterpriseLogo.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -37,81 +37,81 @@
 block discarded – undo
37 37
  */
38 38
 class SetEnterpriseLogo implements IRepairStep {
39 39
 
40
-	/** @var IConfig $config */
41
-	private $config;
42
-
43
-	/** @var IRegistry $subscriptionRegistry */
44
-	private $subscriptionRegistry;
45
-
46
-	/** @var IAppData $appData */
47
-	private $appData;
48
-
49
-	/** @var SCSSCacher $scssCacher */
50
-	private $scssCacher;
51
-
52
-	/** @var \OC_Defaults|ThemingDefaults */
53
-	private $themingDefaults;
54
-
55
-	public function getName(): string {
56
-		return 'Sets the enterprise logo';
57
-	}
58
-
59
-	public function __construct(
60
-		IConfig $config,
61
-		IRegistry $subscriptionRegistry,
62
-		Factory $appDataFactory,
63
-		SCSSCacher $SCSSCacher,
64
-		$ThemingDefaults
65
-	) {
66
-		$this->config = $config;
67
-		$this->subscriptionRegistry = $subscriptionRegistry;
68
-		$this->appData = $appDataFactory->get('theming');
69
-		$this->scssCacher = $SCSSCacher;
70
-		$this->themingDefaults = $ThemingDefaults;
71
-	}
72
-
73
-	public function run(IOutput $output): void {
74
-		// only run once
75
-		if ($this->config->getAppValue('core', 'enterpriseLogoChecked') === 'yes') {
76
-			$output->info('Repair step already executed');
77
-			return;
78
-		}
79
-
80
-		if (!$this->subscriptionRegistry->delegateHasValidSubscription()) {
81
-			// no need to set the enterprise logo
82
-			$this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
83
-			return;
84
-		}
85
-
86
-		if ($this->themingDefaults instanceof ThemingDefaults) {
87
-			$output->info('Theming is enabled - trying to set logo.');
88
-			try {
89
-				$folder = $this->appData->getFolder('images');
90
-			} catch (NotFoundException $e) {
91
-				$folder = $this->appData->newFolder('images');
92
-			}
93
-
94
-			if (!$folder->fileExists('logo') || $folder->getFile('logo')->getSize() === 0) {
95
-				$output->info('Logo does not exist yet - setting it.');
96
-
97
-				if ($folder->fileExists('logo')) {
98
-					$folder->getFile('logo')->delete();
99
-				}
100
-				$target = $folder->newFile('logo');
101
-
102
-				$target->putContent(file_get_contents(__DIR__ . '/../../../../core/img/logo/logo-enterprise.png'));
103
-
104
-				$this->themingDefaults->set('logoMime', 'image/png');
105
-
106
-				$this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
107
-			} else {
108
-				$output->info('Logo already set - skipping.');
109
-			}
110
-		} else {
111
-			$output->info('Theming is not enabled - skipping.');
112
-		}
113
-
114
-		// if all were done, no need to redo the repair during next upgrade
115
-		$this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
116
-	}
40
+    /** @var IConfig $config */
41
+    private $config;
42
+
43
+    /** @var IRegistry $subscriptionRegistry */
44
+    private $subscriptionRegistry;
45
+
46
+    /** @var IAppData $appData */
47
+    private $appData;
48
+
49
+    /** @var SCSSCacher $scssCacher */
50
+    private $scssCacher;
51
+
52
+    /** @var \OC_Defaults|ThemingDefaults */
53
+    private $themingDefaults;
54
+
55
+    public function getName(): string {
56
+        return 'Sets the enterprise logo';
57
+    }
58
+
59
+    public function __construct(
60
+        IConfig $config,
61
+        IRegistry $subscriptionRegistry,
62
+        Factory $appDataFactory,
63
+        SCSSCacher $SCSSCacher,
64
+        $ThemingDefaults
65
+    ) {
66
+        $this->config = $config;
67
+        $this->subscriptionRegistry = $subscriptionRegistry;
68
+        $this->appData = $appDataFactory->get('theming');
69
+        $this->scssCacher = $SCSSCacher;
70
+        $this->themingDefaults = $ThemingDefaults;
71
+    }
72
+
73
+    public function run(IOutput $output): void {
74
+        // only run once
75
+        if ($this->config->getAppValue('core', 'enterpriseLogoChecked') === 'yes') {
76
+            $output->info('Repair step already executed');
77
+            return;
78
+        }
79
+
80
+        if (!$this->subscriptionRegistry->delegateHasValidSubscription()) {
81
+            // no need to set the enterprise logo
82
+            $this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
83
+            return;
84
+        }
85
+
86
+        if ($this->themingDefaults instanceof ThemingDefaults) {
87
+            $output->info('Theming is enabled - trying to set logo.');
88
+            try {
89
+                $folder = $this->appData->getFolder('images');
90
+            } catch (NotFoundException $e) {
91
+                $folder = $this->appData->newFolder('images');
92
+            }
93
+
94
+            if (!$folder->fileExists('logo') || $folder->getFile('logo')->getSize() === 0) {
95
+                $output->info('Logo does not exist yet - setting it.');
96
+
97
+                if ($folder->fileExists('logo')) {
98
+                    $folder->getFile('logo')->delete();
99
+                }
100
+                $target = $folder->newFile('logo');
101
+
102
+                $target->putContent(file_get_contents(__DIR__ . '/../../../../core/img/logo/logo-enterprise.png'));
103
+
104
+                $this->themingDefaults->set('logoMime', 'image/png');
105
+
106
+                $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
107
+            } else {
108
+                $output->info('Logo already set - skipping.');
109
+            }
110
+        } else {
111
+            $output->info('Theming is not enabled - skipping.');
112
+        }
113
+
114
+        // if all were done, no need to redo the repair during next upgrade
115
+        $this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
116
+    }
117 117
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
 				}
100 100
 				$target = $folder->newFile('logo');
101 101
 
102
-				$target->putContent(file_get_contents(__DIR__ . '/../../../../core/img/logo/logo-enterprise.png'));
102
+				$target->putContent(file_get_contents(__DIR__.'/../../../../core/img/logo/logo-enterprise.png'));
103 103
 
104 104
 				$this->themingDefaults->set('logoMime', 'image/png');
105 105
 
Please login to merge, or discard this patch.
lib/private/Repair.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -63,177 +63,177 @@
 block discarded – undo
63 63
 
64 64
 class Repair implements IOutput {
65 65
 
66
-	/** @var IRepairStep[] */
67
-	private $repairSteps;
68
-
69
-	/** @var EventDispatcherInterface */
70
-	private $dispatcher;
71
-
72
-	/** @var string */
73
-	private $currentStep;
74
-
75
-	/**
76
-	 * Creates a new repair step runner
77
-	 *
78
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
79
-	 * @param EventDispatcherInterface $dispatcher
80
-	 */
81
-	public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
82
-		$this->repairSteps = $repairSteps;
83
-		$this->dispatcher  = $dispatcher;
84
-	}
85
-
86
-	/**
87
-	 * Run a series of repair steps for common problems
88
-	 */
89
-	public function run() {
90
-		if (count($this->repairSteps) === 0) {
91
-			$this->emit('\OC\Repair', 'info', array('No repair steps available'));
92
-
93
-			return;
94
-		}
95
-		// run each repair step
96
-		foreach ($this->repairSteps as $step) {
97
-			$this->currentStep = $step->getName();
98
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
99
-			$step->run($this);
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Add repair step
105
-	 *
106
-	 * @param IRepairStep|string $repairStep repair step
107
-	 * @throws \Exception
108
-	 */
109
-	public function addStep($repairStep) {
110
-		if (is_string($repairStep)) {
111
-			try {
112
-				$s = \OC::$server->query($repairStep);
113
-			} catch (QueryException $e) {
114
-				if (class_exists($repairStep)) {
115
-					$s = new $repairStep();
116
-				} else {
117
-					throw new \Exception("Repair step '$repairStep' is unknown");
118
-				}
119
-			}
120
-
121
-			if ($s instanceof IRepairStep) {
122
-				$this->repairSteps[] = $s;
123
-			} else {
124
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
125
-			}
126
-		} else {
127
-			$this->repairSteps[] = $repairStep;
128
-		}
129
-	}
130
-
131
-	/**
132
-	 * Returns the default repair steps to be run on the
133
-	 * command line or after an upgrade.
134
-	 *
135
-	 * @return IRepairStep[]
136
-	 */
137
-	public static function getRepairSteps() {
138
-		return [
139
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
140
-			new RepairMimeTypes(\OC::$server->getConfig()),
141
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
142
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
143
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
144
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
145
-			new AddLogRotateJob(\OC::$server->getJobList()),
146
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
147
-			new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
148
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
149
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
150
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
151
-			new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
152
-			new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
153
-			\OC::$server->query(RemoveCypressFiles::class),
154
-			\OC::$server->query(SwitchUpdateChannel::class),
155
-			\OC::$server->query(SetEnterpriseLogo::class),
156
-		];
157
-	}
158
-
159
-	/**
160
-	 * Returns expensive repair steps to be run on the
161
-	 * command line with a special option.
162
-	 *
163
-	 * @return IRepairStep[]
164
-	 */
165
-	public static function getExpensiveRepairSteps() {
166
-		return [
167
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
168
-		];
169
-	}
170
-
171
-	/**
172
-	 * Returns the repair steps to be run before an
173
-	 * upgrade.
174
-	 *
175
-	 * @return IRepairStep[]
176
-	 */
177
-	public static function getBeforeUpgradeRepairSteps() {
178
-		$connection = \OC::$server->getDatabaseConnection();
179
-		$config     = \OC::$server->getConfig();
180
-		$steps      = [
181
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
182
-			new SqliteAutoincrement($connection),
183
-			new SaveAccountsTableData($connection, $config),
184
-			new DropAccountTermsTable($connection)
185
-		];
186
-
187
-		return $steps;
188
-	}
189
-
190
-	/**
191
-	 * @param string $scope
192
-	 * @param string $method
193
-	 * @param array $arguments
194
-	 */
195
-	public function emit($scope, $method, array $arguments = []) {
196
-		if (!is_null($this->dispatcher)) {
197
-			$this->dispatcher->dispatch("$scope::$method",
198
-				new GenericEvent("$scope::$method", $arguments));
199
-		}
200
-	}
201
-
202
-	public function info($string) {
203
-		// for now just emit as we did in the past
204
-		$this->emit('\OC\Repair', 'info', array($string));
205
-	}
206
-
207
-	/**
208
-	 * @param string $message
209
-	 */
210
-	public function warning($message) {
211
-		// for now just emit as we did in the past
212
-		$this->emit('\OC\Repair', 'warning', [$message]);
213
-	}
214
-
215
-	/**
216
-	 * @param int $max
217
-	 */
218
-	public function startProgress($max = 0) {
219
-		// for now just emit as we did in the past
220
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
221
-	}
222
-
223
-	/**
224
-	 * @param int $step
225
-	 * @param string $description
226
-	 */
227
-	public function advance($step = 1, $description = '') {
228
-		// for now just emit as we did in the past
229
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
230
-	}
231
-
232
-	/**
233
-	 * @param int $max
234
-	 */
235
-	public function finishProgress() {
236
-		// for now just emit as we did in the past
237
-		$this->emit('\OC\Repair', 'finishProgress', []);
238
-	}
66
+    /** @var IRepairStep[] */
67
+    private $repairSteps;
68
+
69
+    /** @var EventDispatcherInterface */
70
+    private $dispatcher;
71
+
72
+    /** @var string */
73
+    private $currentStep;
74
+
75
+    /**
76
+     * Creates a new repair step runner
77
+     *
78
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
79
+     * @param EventDispatcherInterface $dispatcher
80
+     */
81
+    public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
82
+        $this->repairSteps = $repairSteps;
83
+        $this->dispatcher  = $dispatcher;
84
+    }
85
+
86
+    /**
87
+     * Run a series of repair steps for common problems
88
+     */
89
+    public function run() {
90
+        if (count($this->repairSteps) === 0) {
91
+            $this->emit('\OC\Repair', 'info', array('No repair steps available'));
92
+
93
+            return;
94
+        }
95
+        // run each repair step
96
+        foreach ($this->repairSteps as $step) {
97
+            $this->currentStep = $step->getName();
98
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
99
+            $step->run($this);
100
+        }
101
+    }
102
+
103
+    /**
104
+     * Add repair step
105
+     *
106
+     * @param IRepairStep|string $repairStep repair step
107
+     * @throws \Exception
108
+     */
109
+    public function addStep($repairStep) {
110
+        if (is_string($repairStep)) {
111
+            try {
112
+                $s = \OC::$server->query($repairStep);
113
+            } catch (QueryException $e) {
114
+                if (class_exists($repairStep)) {
115
+                    $s = new $repairStep();
116
+                } else {
117
+                    throw new \Exception("Repair step '$repairStep' is unknown");
118
+                }
119
+            }
120
+
121
+            if ($s instanceof IRepairStep) {
122
+                $this->repairSteps[] = $s;
123
+            } else {
124
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
125
+            }
126
+        } else {
127
+            $this->repairSteps[] = $repairStep;
128
+        }
129
+    }
130
+
131
+    /**
132
+     * Returns the default repair steps to be run on the
133
+     * command line or after an upgrade.
134
+     *
135
+     * @return IRepairStep[]
136
+     */
137
+    public static function getRepairSteps() {
138
+        return [
139
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
140
+            new RepairMimeTypes(\OC::$server->getConfig()),
141
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
142
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
143
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
144
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
145
+            new AddLogRotateJob(\OC::$server->getJobList()),
146
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
147
+            new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
148
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
149
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
150
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
151
+            new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
152
+            new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
153
+            \OC::$server->query(RemoveCypressFiles::class),
154
+            \OC::$server->query(SwitchUpdateChannel::class),
155
+            \OC::$server->query(SetEnterpriseLogo::class),
156
+        ];
157
+    }
158
+
159
+    /**
160
+     * Returns expensive repair steps to be run on the
161
+     * command line with a special option.
162
+     *
163
+     * @return IRepairStep[]
164
+     */
165
+    public static function getExpensiveRepairSteps() {
166
+        return [
167
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
168
+        ];
169
+    }
170
+
171
+    /**
172
+     * Returns the repair steps to be run before an
173
+     * upgrade.
174
+     *
175
+     * @return IRepairStep[]
176
+     */
177
+    public static function getBeforeUpgradeRepairSteps() {
178
+        $connection = \OC::$server->getDatabaseConnection();
179
+        $config     = \OC::$server->getConfig();
180
+        $steps      = [
181
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
182
+            new SqliteAutoincrement($connection),
183
+            new SaveAccountsTableData($connection, $config),
184
+            new DropAccountTermsTable($connection)
185
+        ];
186
+
187
+        return $steps;
188
+    }
189
+
190
+    /**
191
+     * @param string $scope
192
+     * @param string $method
193
+     * @param array $arguments
194
+     */
195
+    public function emit($scope, $method, array $arguments = []) {
196
+        if (!is_null($this->dispatcher)) {
197
+            $this->dispatcher->dispatch("$scope::$method",
198
+                new GenericEvent("$scope::$method", $arguments));
199
+        }
200
+    }
201
+
202
+    public function info($string) {
203
+        // for now just emit as we did in the past
204
+        $this->emit('\OC\Repair', 'info', array($string));
205
+    }
206
+
207
+    /**
208
+     * @param string $message
209
+     */
210
+    public function warning($message) {
211
+        // for now just emit as we did in the past
212
+        $this->emit('\OC\Repair', 'warning', [$message]);
213
+    }
214
+
215
+    /**
216
+     * @param int $max
217
+     */
218
+    public function startProgress($max = 0) {
219
+        // for now just emit as we did in the past
220
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
221
+    }
222
+
223
+    /**
224
+     * @param int $step
225
+     * @param string $description
226
+     */
227
+    public function advance($step = 1, $description = '') {
228
+        // for now just emit as we did in the past
229
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
230
+    }
231
+
232
+    /**
233
+     * @param int $max
234
+     */
235
+    public function finishProgress() {
236
+        // for now just emit as we did in the past
237
+        $this->emit('\OC\Repair', 'finishProgress', []);
238
+    }
239 239
 }
Please login to merge, or discard this patch.