@@ -269,7 +269,7 @@ public function updateLocalConfiguration(array $configurationToMerge): void
269
269
1346323822
270
270
);
271
271
}
272
- $ removedPaths = $ this ->findRemovedPaths ();
272
+ $ removedPaths = $ this ->getRemovedPaths ();
273
273
foreach ($ removedPaths as $ removedPath ) {
274
274
try {
275
275
Config::getValue ($ configurationToMerge , $ removedPath );
@@ -292,44 +292,26 @@ public function updateLocalConfiguration(array $configurationToMerge): void
292
292
}
293
293
}
294
294
295
- private function findRemovedPaths (): array
296
- {
297
- $ overrides = $ this ->configLoader ->loadOverrides ();
298
- $ removedPaths = [];
299
- if (isset ($ overrides ['processors ' ])) {
300
- foreach ($ overrides ['processors ' ] as $ index => $ processorConfig ) {
301
- if (($ processorConfig ['internal ' ] ?? false ) && $ processorConfig ['class ' ] === RemoveSettingsProcessor::class) {
302
- $ removedPaths = $ processorConfig ['paths ' ];
303
- break ;
304
- }
305
- }
306
- }
295
+ private const REMOVE_PROCESSOR_KEY = '_stale_options ' ;
307
296
308
- return $ removedPaths ;
297
+ private function getRemovedPaths (): array
298
+ {
299
+ return $ this ->configLoader ->loadOverrides ()['processors ' ][self ::REMOVE_PROCESSOR_KEY ]['paths ' ] ?? [];
309
300
}
310
301
311
302
private function updateRemovalPaths (array $ pathsToRemove ): void
312
303
{
313
304
$ overrideSettingsFile = SettingsFiles::getOverrideSettingsFile ();
314
305
$ overrides = $ this ->configLoader ->loadOverrides ();
315
- $ processorPosition = 0 ;
316
- if (isset ($ overrides ['processors ' ])) {
317
- foreach ($ overrides ['processors ' ] as $ index => $ processorConfig ) {
318
- if (($ processorConfig ['internal ' ] ?? false ) && $ processorConfig ['class ' ] === RemoveSettingsProcessor::class) {
319
- $ processorPosition = $ index ;
320
- break ;
321
- }
322
- }
323
- }
306
+ $ overrides ['processors ' ][self ::REMOVE_PROCESSOR_KEY ] = [
307
+ 'class ' => RemoveSettingsProcessor::class,
308
+ 'paths ' => $ pathsToRemove ,
309
+ ];
324
310
if (empty ($ pathsToRemove )) {
325
- unset($ overrides ['processors ' ][$ processorPosition ]);
311
+ unset($ overrides ['processors ' ][self :: REMOVE_PROCESSOR_KEY ]);
326
312
if (empty ($ overrides ['processors ' ])) {
327
313
unset($ overrides ['processors ' ]);
328
314
}
329
- } else {
330
- $ overrides ['processors ' ][$ processorPosition ]['class ' ] = RemoveSettingsProcessor::class;
331
- $ overrides ['processors ' ][$ processorPosition ]['paths ' ] = $ pathsToRemove ;
332
- $ overrides ['processors ' ][$ processorPosition ]['internal ' ] = true ;
333
315
}
334
316
$ this ->configDumper ->dumpToFile ($ overrides , $ overrideSettingsFile );
335
317
}
@@ -422,7 +404,7 @@ public function removeLocalConfigurationKeysByPath(array $keys): bool
422
404
}
423
405
}
424
406
if (!empty ($ removedPaths )) {
425
- $ alreadyRemovedPaths = $ this ->findRemovedPaths ();
407
+ $ alreadyRemovedPaths = $ this ->getRemovedPaths ();
426
408
$ removedPaths = array_unique (array_merge ($ alreadyRemovedPaths , $ removedPaths ));
427
409
$ this ->updateRemovalPaths ($ removedPaths );
428
410
}
0 commit comments