Skip to content

Commit 5f9d267

Browse files
committed
Update the release highlights to use VarCache
1 parent 19c4f62 commit 5f9d267

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

bin/compile-release-highlights.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
22

3+
use phpweb\Build\VarCache;
4+
35
if (php_sapi_name() !== 'cli') {
46
die('This script must be run from the command line.');
57
}
68

9+
include __DIR__ . '/../src/autoload.php';
10+
711
final readonly class Segment
812
{
913
/**
@@ -139,10 +143,8 @@ function parseDirectory(string $path): array
139143
continue;
140144
}
141145

142-
$releaseComparisons[$fileName] = parseDirectory($dirName . '/highlights');
146+
$highlightPath = $dirName . '/highlights';
147+
if (is_dir($highlightPath)) {
148+
VarCache::WriteVar('releases/' . $fileName . '/highlights', parseDirectory($highlightPath));
149+
}
143150
}
144-
145-
file_put_contents(
146-
__DIR__ . '/../include/releases-comparisons.inc',
147-
'<?php return ' . var_export($releaseComparisons, true) . ';',
148-
);

src/Metadata/VersionData.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace phpweb\Metadata;
44

55
use DateTimeImmutable;
6+
use phpweb\Build\VarCache;
67
use function array_key_last;
78
use function array_reverse;
8-
use function array_unique;
99
use function get_active_branches;
1010
use function get_branch_bug_eol_date;
1111
use function get_branch_security_eol_date;
12-
use function ksort;
1312

1413
final class VersionData
1514
{
@@ -22,6 +21,7 @@ final class VersionData
2221
private ?DateTimeImmutable $_bugfixEOL = null;
2322
private ?DateTimeImmutable $_securityEOL = null;
2423
private ?array $_pointReleases = null;
24+
private ?array $_highlightSnippets = null;
2525

2626
public function __construct(public readonly string $label)
2727
{
@@ -122,10 +122,8 @@ public static function getSupportedVersions(): array
122122
* @return list<array>
123123
*/
124124
get {
125-
static $cache = null;
126-
$cache ??= require __DIR__ . '/../../include/releases-comparisons.inc';
127-
128-
return $cache[$this->label];
125+
return $this->_highlightSnippets
126+
??= VarCache::ReadVarWithDefault('releases/' . $this->label . '/highlights', []);
129127
}
130128
}
131129

0 commit comments

Comments
 (0)