refactor: ReleaseGate::invalidate() als einzige Stelle zum Zurücksetzen des Freigabe-Zustands; CompatibilityMatrix::locked() und ReleaseGate::lockOf() ersetzen die drei Kopien der Sperrprüfung
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7f9a087b8b
commit
63389f35a8
@@ -51,15 +51,25 @@ final class ReleaseGate
|
||||
self::$probe = null;
|
||||
}
|
||||
|
||||
/** The next status() computes again (after a check, a release or a withdrawal). */
|
||||
/** The next status() of this request computes again; the cached mirror results stay (see invalidate()). */
|
||||
public static function forget(): void
|
||||
{
|
||||
self::$status = null;
|
||||
}
|
||||
|
||||
public static function feature(DiviFeature $feature): FeatureStatus
|
||||
/**
|
||||
* The single way to make the release state current again: forgets the status of this request and, with
|
||||
* $mirrors, also deletes the cached mirror results (transient ReleaseResolver::CACHE) so the next status()
|
||||
* fingerprints Divi's code again. Without $mirrors: after a release or a withdrawal and after the admin check
|
||||
* (only the source of the state changed). With $mirrors: after a theme update, a CLI check or a new reference
|
||||
* (the code or the reference may have changed).
|
||||
*/
|
||||
public static function invalidate(bool $mirrors = false): void
|
||||
{
|
||||
return self::status()->matrix->of($feature);
|
||||
if ($mirrors) {
|
||||
delete_transient(ReleaseResolver::CACHE);
|
||||
}
|
||||
self::forget();
|
||||
}
|
||||
|
||||
/** @throws DiviLocked When $feature is not usable – before anything is written. */
|
||||
@@ -80,16 +90,28 @@ final class ReleaseGate
|
||||
return;
|
||||
}
|
||||
|
||||
$lock = self::lockOf($features);
|
||||
if ($lock !== null) {
|
||||
throw $lock;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The lock of this request's status for the locked ones of $features, or null when every one is usable. Asked by
|
||||
* DiviFeatureGate before a tool runs and by the Divi short form of lit/content-create (DiviContentComposer::
|
||||
* refusal()); no probe exception – tool calls never write the probe page.
|
||||
*
|
||||
* @param list<DiviFeature> $features
|
||||
*/
|
||||
public static function lockOf(array $features): ?DiviLocked
|
||||
{
|
||||
$status = self::status();
|
||||
$locked = [];
|
||||
foreach ($features as $feature) {
|
||||
if (! $status->matrix->of($feature)->usable()) {
|
||||
$locked[$feature->value] = $feature;
|
||||
}
|
||||
}
|
||||
if ($locked !== []) {
|
||||
throw new DiviLocked($status, array_values($locked));
|
||||
}
|
||||
$locked = $status->matrix->locked($features);
|
||||
|
||||
return $locked === [] ? null : new DiviLocked(
|
||||
$status,
|
||||
array_map(static fn (FeatureStatus $feature): DiviFeature => $feature->feature, $locked)
|
||||
);
|
||||
}
|
||||
|
||||
public static function whileProbing(int $postId, callable $write): mixed
|
||||
|
||||
Reference in New Issue
Block a user