Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c16a9f5
Extract out $BRANCHES into its own include file that returns the data…
Jun 17, 2026
93fa5ca
version.inc and releases.inc also return their data, allowing it to b…
Jun 17, 2026
f85b639
release_get_latest and show_source_releases get pulled out of version…
Jun 17, 2026
ed92963
Do not require code coverage on phpunit.xml
Jun 17, 2026
c575b0b
Create a new autoloadable version of the helpers contained in branche…
Jun 17, 2026
7fb1756
Replace usages of get_all_branches and get_active_branches
Jun 17, 2026
b30ae19
Replace usages of get_eol_branches
Jun 17, 2026
0dc50b0
Replace usages of branch status and date functions
Jun 17, 2026
88672ec
Add deprecation notices to functions inside branches.inc
Jun 17, 2026
f9a08f7
Update bumpRelease with class equivilents
Jun 17, 2026
c0c3957
Update feed with Branches::getReleaseData()
Jun 17, 2026
0b0dd4e
Update /releases/?serialize (imported vars)
Jun 17, 2026
610f458
Depreciate get_current_release_for_branch, swap over
Jun 17, 2026
20c80c9
Remove more referneces to get_branch_security_eol
Jun 17, 2026
9412aa8
var_export apparently puts a space at the end of each => which editin…
Jun 17, 2026
b2b630f
Keep relying on the old logic in bumpReleases to avoid exploding the …
Jun 17, 2026
bf31057
Need to include the autoloader for branch capabilities.
Jun 18, 2026
5b060aa
Update include/branches.inc
markrandall Jun 18, 2026
46f8046
Update src/Releases/Branches.php
markrandall Jun 18, 2026
1e85c70
Remove all changes to files moved into public/
Jun 18, 2026
1685dfd
Extract out $BRANCHES into its own include file that returns the data…
Jun 17, 2026
61c5393
version.inc and releases.inc also return their data, allowing it to b…
Jun 17, 2026
a938395
release_get_latest and show_source_releases get pulled out of version…
Jun 17, 2026
b14191d
Do not require code coverage on phpunit.xml
Jun 17, 2026
392dbcc
Create a new autoloadable version of the helpers contained in branche…
Jun 17, 2026
48e3ad9
Replace usages of get_all_branches and get_active_branches
Jun 17, 2026
84510c3
Replace usages of get_eol_branches
Jun 17, 2026
59278fb
Replace usages of branch status and date functions
Jun 17, 2026
7253294
Add deprecation notices to functions inside branches.inc
Jun 17, 2026
479f648
Update bumpRelease with class equivilents
Jun 17, 2026
defd27e
Update feed with Branches::getReleaseData()
Jun 17, 2026
4dd2d05
Update /releases/?serialize (imported vars)
Jun 17, 2026
f606759
Depreciate get_current_release_for_branch, swap over
Jun 17, 2026
12a4ca3
Remove more referneces to get_branch_security_eol
Jun 17, 2026
8bac17c
var_export apparently puts a space at the end of each => which editin…
Jun 17, 2026
dfd0473
Keep relying on the old logic in bumpReleases to avoid exploding the …
Jun 17, 2026
21c1881
Need to include the autoloader for branch capabilities.
Jun 18, 2026
0e4c553
Update include/branches.inc
markrandall Jun 18, 2026
718680b
Update src/Releases/Branches.php
markrandall Jun 18, 2026
b477bf6
Remove all changes to files moved into public/
Jun 18, 2026
17357e4
Update public facing pages
Jun 18, 2026
6e20c66
Merge remote-tracking branch 'origin/preview' into branch-api-extraction
Jun 18, 2026
573e452
Merge remote-tracking branch 'personal/branch-api-extraction' into br…
Jun 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions bin/bumpRelease
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#!/usr/bin/env php
<?php

use phpweb\Releases\Branches;

(PHP_SAPI === 'cli') or die("Please run this script using the cli sapi");

require_once __DIR__ . "/../include/branches.inc";
require_once __DIR__ . "/../include/version.inc";
require_once __DIR__ . "/../include/releases.inc";
require __DIR__ . '/../include/releases.inc';
require __DIR__ . '/../src/autoload.php';

if ($_SERVER['argc'] < 1) {
fwrite(STDERR, "Usage: {$_SERVER['argv'][0]} major_version [ minor_version ]\n");
exit(1);
}

$RELEASES = Branches::getReleaseData();
$major = (int) $_SERVER['argv'][1];
isset($RELEASES[$major]) or die("Unknown major version $major");
$minor = isset($_SERVER['argv'][2]) ? (int) $_SERVER['argv'][2] : null;

$version = get_current_release_for_branch($major, $minor);
$version = Branches::getCurrentReleaseForBranch($major, $minor);
$info = $RELEASES[$major][$version] ?? null;

if ($info === null) {
Expand All @@ -34,7 +37,7 @@ $OLDRELEASES[$major] = array_merge(
);

file_put_contents(__DIR__ . "/../include/releases.inc", [
"<?php\n\$OLDRELEASES = ",
"<?php\nreturn \$OLDRELEASES = ",
var_export($OLDRELEASES, true),
";\n",
]);
Expand Down
33 changes: 33 additions & 0 deletions include/branch-overrides.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

return [
/* 3.0 is here because version_compare() can't handle the only version in
* $OLDRELEASES, and it saves another special case in
* get_branch_security_eol_date(). */
'3.0' => [
'security' => '2000-10-20',
],
'5.3' => [
'stable' => '2013-07-11',
'security' => '2014-08-14',
],
'5.4' => [
'stable' => '2014-09-14',
'security' => '2015-09-03',
],
'5.5' => [
'stable' => '2015-07-10',
'security' => '2016-07-21',
],
'5.6' => [
'stable' => '2017-01-19',
'security' => '2018-12-31',
],
'7.0' => [
'stable' => '2018-01-04',
'security' => '2019-01-10',
],
'8.4' => [
'date' => '2024-11-21',
],
];
120 changes: 88 additions & 32 deletions include/branches.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use phpweb\Releases\Branches;

include_once __DIR__ . '/releases.inc';
include_once __DIR__ . '/version.inc';

Expand All @@ -10,37 +12,7 @@
* - stable: the end of active support (usually two years after release).
* - security: the end of security support (usually release + 3 years).
*/
$BRANCHES = [
/* 3.0 is here because version_compare() can't handle the only version in
* $OLDRELEASES, and it saves another special case in
* get_branch_security_eol_date(). */
'3.0' => [
'security' => '2000-10-20',
],
'5.3' => [
'stable' => '2013-07-11',
'security' => '2014-08-14',
],
'5.4' => [
'stable' => '2014-09-14',
'security' => '2015-09-03',
],
'5.5' => [
'stable' => '2015-07-10',
'security' => '2016-07-21',
],
'5.6' => [
'stable' => '2017-01-19',
'security' => '2018-12-31',
],
'7.0' => [
'stable' => '2018-01-04',
'security' => '2019-01-10',
],
'8.4' => [
'date' => '2024-11-21',
],
];
$BRANCHES = require __DIR__ . '/branch-overrides.inc';

/* Time to keep EOLed branches in the array returned by get_active_branches(),
* which is used on the front page download links and the supported versions
Expand Down Expand Up @@ -98,6 +70,7 @@
return null;
}

#[Deprecated('Use Branches::get_all_branches()')]
function get_all_branches() {
$branches = [];

Expand Down Expand Up @@ -135,7 +108,8 @@
return $branches;
}

function get_active_branches($include_recent_eols = true) {
#[Deprecated('Use Branches::active()')]
function get_active_branches(bool $include_recent_eols = true) {
$branches = [];
$now = new DateTime();

Expand Down Expand Up @@ -170,6 +144,7 @@
/* If you provide an array to $always_include, note that the version numbers
* must be in $RELEASES _and_ must be the full version number, not the branch:
* ie provide array('5.3.29'), not array('5.3'). */
#[Deprecated('Use Branches::eol()')]
function get_eol_branches($always_include = null) {
$always_include = $always_include ?: [];
$branches = [];
Expand Down Expand Up @@ -246,6 +221,7 @@
* MAJOR.MINOR.REVISION (the REVISION will be ignored if provided). This will
* return either null (if no release exists on the given branch), or the usual
* version metadata from $RELEASES for a single release. */
#[Deprecated('Use Branches::getInitialRelease')]
function get_initial_release($branch) {
$branch = version_number_to_branch($branch);
if (!$branch) {
Expand Down Expand Up @@ -274,6 +250,7 @@
return null;
}

#[Deprecated('Use Branches::getFinalRelease')]
function get_final_release($branch) {
$branch = version_number_to_branch($branch);
if (!$branch) {
Expand Down Expand Up @@ -305,6 +282,7 @@
return null;
}

#[Deprecated('Use Branches::getBranchBugsEOLDate')]
function get_branch_bug_eol_date($branch): ?DateTime
{
if (isset($GLOBALS['BRANCHES'][$branch]['stable'])) {
Expand All @@ -324,6 +302,7 @@
return $date?->setDate($date->format('Y'), 12, 31);
}

#[Deprecated('Use Branches::getBranchSecurityEOLDate')]
function get_branch_security_eol_date($branch): ?DateTime
{
if (isset($GLOBALS['BRANCHES'][$branch]['security'])) {
Expand Down Expand Up @@ -351,13 +330,15 @@
return $date?->setDate($date->format('Y'), 12, 31);
}

#[Deprecated('Use Branches::getBranchReleaseDate')]
function get_branch_release_date($branch): ?DateTime
{
$initial = get_initial_release($branch);

return isset($initial['date']) ? new DateTime($initial['date']) : null;
}

#[Deprecated('Use Branches::getBranchSupportState')]
function get_branch_support_state($branch) {
$initial = get_branch_release_date($branch);
$bug = get_branch_bug_eol_date($branch);
Expand Down Expand Up @@ -419,6 +400,7 @@
return $versionArray;
}

#[Deprecated('Use Branches::getCurrentReleaseForBranch')]
function get_current_release_for_branch(int $major, ?int $minor): ?string {
global $RELEASES, $OLDRELEASES;

Expand All @@ -441,3 +423,77 @@

return null;
}


// Get latest release version and info.
function release_get_latest() {

Check failure on line 429 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Function release_get_latest() has no return type specified.
$RELEASES = Branches::getReleaseData();

$version = '0.0.0';
$current = null;
foreach ($RELEASES as $versions) {
foreach ($versions as $ver => $info) {
if (version_compare($ver, $version) > 0) {
$version = $ver;
$current = $info;
}
}
}

return [$version, $current];
}

function show_source_releases()

Check failure on line 446 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Function show_source_releases() has no return type specified.
{
$RELEASES = Branches::getReleaseData();

$SHOW_COUNT = 4;

$current_uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');

$i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
$releases = array_slice($major_releases, 0, $SHOW_COUNT);
?>
<a id="v<?php echo $MAJOR; ?>"></a>
<?php foreach ($releases as $v => $a): ?>
<?php $mver = substr($v, 0, strrpos($v, '.')); ?>

Check failure on line 459 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Parameter #3 $length of function substr expects int|null, int|false given.
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?>

<h3 id="v<?php echo $v; ?>" class="title">
<span class="release-state"><?php echo $stable; ?></span>
PHP <?php echo $v; ?>
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>)
</h3>
<div class="content-box">

<ul>
<?php foreach ($a['source'] as $rel): ?>
<li>
<?php download_link($rel['filename'], $rel['filename']); ?>
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>

Check failure on line 473 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Parameter #2 $timestamp of function date expects int|null, int|false given.
<?php
if (isset($rel['md5'])) echo '<span class="md5sum">', $rel['md5'], '</span>';
if (isset($rel['sha256'])) echo '<span class="sha256">', $rel['sha256'], '</span>';
?>
<?php if (isset($rel['note']) && $rel['note']): ?>

Check failure on line 478 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Result of && is always false.

Check failure on line 478 in include/branches.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Offset 'note' on array{filename: string, name: string, md5?: string, sha256?: string, date: string} in isset() does not exist.
<p>
<strong>Note:</strong>
<?php echo $rel['note']; ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li>
<a href="/downloads.php?os=windows&osvariant=windows-downloads&version=<?php echo urlencode($mver); ?>">
Windows downloads
</a>
</li>
</ul>

<a href="<?php echo $current_uri; ?>#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a>
</div>
<?php endforeach; ?>
<?php endforeach; /* major releases loop end */ ?>
<?php
}

5 changes: 4 additions & 1 deletion include/gpg-keys.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use phpweb\Releases\Branches;

require __DIR__ . '/branches.inc';

// GPG keys used for signing releases.
Expand Down Expand Up @@ -224,7 +227,7 @@ function gpg_key_get_branches(bool $activeOnly): array {

if (!$activeOnly) { return $branches; }

$active = get_active_branches();
$active = Branches::active();
return array_filter($branches, function ($branch) use ($active) {
[$major] = explode('.', $branch, 2);
return isset($active[$major][$branch]);
Expand Down
2 changes: 1 addition & 1 deletion include/releases.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$OLDRELEASES = array (
return $OLDRELEASES = array (
8 =>
array (
'8.4.21' =>
Expand Down
75 changes: 2 additions & 73 deletions include/version.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
/* The format is:
* array(
Expand All @@ -15,7 +15,7 @@
* ),
* );
*/
$RELEASES = (function () {
return $RELEASES = (function () {
$data = [];

/* PHP 8.5 Release */
Expand Down Expand Up @@ -74,6 +74,7 @@
[$major] = explode('.', $version, 2);

$info = [
'version' => $version,
'announcement' => $release['announcement'] ?? true,
'tags' => $release['tags'],
'date' => $release['date'],
Expand All @@ -91,75 +92,3 @@
}
return $ret;
})();

// Get latest release version and info.
function release_get_latest() {
global $RELEASES;

$version = '0.0.0';
$current = null;
foreach ($RELEASES as $versions) {
foreach ($versions as $ver => $info) {
if (version_compare($ver, $version) > 0) {
$version = $ver;
$current = $info;
}
}
}

return [$version, $current];
}

function show_source_releases()
{
global $RELEASES;

$SHOW_COUNT = 4;

$current_uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');

$i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
$releases = array_slice($major_releases, 0, $SHOW_COUNT);
?>
<a id="v<?php echo $MAJOR; ?>"></a>
<?php foreach ($releases as $v => $a): ?>
<?php $mver = substr($v, 0, strrpos($v, '.')); ?>
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?>

<h3 id="v<?php echo $v; ?>" class="title">
<span class="release-state"><?php echo $stable; ?></span>
PHP <?php echo $v; ?>
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>)
</h3>
<div class="content-box">

<ul>
<?php foreach ($a['source'] as $rel): ?>
<li>
<?php download_link($rel['filename'], $rel['filename']); ?>
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>
<?php
if (isset($rel['md5'])) echo '<span class="md5sum">', $rel['md5'], '</span>';
if (isset($rel['sha256'])) echo '<span class="sha256">', $rel['sha256'], '</span>';
?>
<?php if (isset($rel['note']) && $rel['note']): ?>
<p>
<strong>Note:</strong>
<?php echo $rel['note']; ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li>
<a href="/downloads.php?os=windows&osvariant=windows-downloads&version=<?php echo urlencode($mver); ?>">
Windows downloads
</a>
</li>
</ul>

<a href="<?php echo $current_uri; ?>#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a>
</div>
<?php endforeach; ?>
<?php endforeach; /* major releases loop end */ ?>
<?php
}
Loading
Loading