Skip to content

Commit

Permalink
refactor: handle empty theme sets after reading cache
Browse files Browse the repository at this point in the history
  • Loading branch information
alex4401 committed May 23, 2024
1 parent 235aed7 commit 0abc5c4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions includes/ThemeAndFeatureRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ThemeAndFeatureRegistry {
ConfigNames::DisableAutoDetection,
];

public const CACHE_GENERATION = 10;
public const CACHE_GENERATION = 11;
public const CACHE_TTL = 24 * 60 * 60;
public const TITLE = 'Theme-definitions';

Expand Down Expand Up @@ -226,6 +226,18 @@ function ( $old, &$ttl, &$setOpts ) {
);
} );

if ( empty( $options ) ) {
// This should match default Theme-definitions message
$themes = [
'none' => [
'id' => 'none',
'default' => true,
'in-site-css' => true,
'kind' => 'unknown',
]
];
}

// Construct ThemeInfo objects
$this->infos = array_map( fn ( $info ) => new ThemeInfo( $info ), $options );
$this->ids = array_keys( $this->infos );
Expand Down Expand Up @@ -261,18 +273,6 @@ private function fetchDefinitionList(): array {
}
}

if ( empty( $themes ) ) {
// This should match default Theme-definitions message
$themes = [
'none' => [
'id' => 'none',
'default' => true,
'in-site-css' => true,
'kind' => 'unknown',
]
];
}

return $themes;
}

Expand Down

0 comments on commit 0abc5c4

Please sign in to comment.