Refactor ChangeLogController to use the new changelog file
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
50ad761d91
commit
195d049b69
@ -24,7 +24,7 @@ return [
|
||||
* Path to changelog file, can be gzip compressed.
|
||||
* Useful when you want to have documentation somewhere else, e.g. /usr/share/doc.
|
||||
*/
|
||||
'changeLogFile' => ROOT_PATH . 'ChangeLog',
|
||||
'changeLogFile' => ROOT_PATH . 'CHANGELOG-6.0.md',
|
||||
|
||||
/**
|
||||
* Path to license file. Useful when you want to have documentation somewhere else, e.g. /usr/share/doc.
|
||||
|
||||
@ -146,6 +146,8 @@ validateExtension() {
|
||||
;;
|
||||
ChangeLog)
|
||||
;;
|
||||
CHANGELOG-[5-9].[0-9].md)
|
||||
;;
|
||||
LICENSE)
|
||||
;;
|
||||
RELEASE-DATE-[1-9].[0-9].[0-9])
|
||||
|
||||
@ -701,6 +701,11 @@
|
||||
<code><![CDATA[Response]]></code>
|
||||
</PossiblyUnusedReturnValue>
|
||||
</file>
|
||||
<file src="src/Controllers/ChangeLogController.php">
|
||||
<MixedOperand>
|
||||
<code><![CDATA[$releaseLinks[$matches[1]]]]></code>
|
||||
</MixedOperand>
|
||||
</file>
|
||||
<file src="src/Controllers/CollationConnectionController.php">
|
||||
<PossiblyUnusedReturnValue>
|
||||
<code><![CDATA[Response]]></code>
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
<title>phpMyAdmin - ChangeLog</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>phpMyAdmin - ChangeLog</h1>
|
||||
<pre>{{ changelog|raw }}</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -15,6 +15,7 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
use function __;
|
||||
use function array_column;
|
||||
use function array_keys;
|
||||
use function basename;
|
||||
use function file_get_contents;
|
||||
@ -22,19 +23,23 @@ use function htmlspecialchars;
|
||||
use function is_readable;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
use function preg_match_all;
|
||||
use function preg_replace;
|
||||
use function preg_replace_callback;
|
||||
use function readgzfile;
|
||||
use function sprintf;
|
||||
use function str_ends_with;
|
||||
|
||||
use const PREG_SET_ORDER;
|
||||
|
||||
#[Route('/changelog', ['GET'])]
|
||||
final class ChangeLogController implements InvocableController
|
||||
final readonly class ChangeLogController implements InvocableController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ResponseRenderer $response,
|
||||
private readonly Config $config,
|
||||
private readonly ResponseFactory $responseFactory,
|
||||
private readonly Template $template,
|
||||
private ResponseRenderer $response,
|
||||
private Config $config,
|
||||
private ResponseFactory $responseFactory,
|
||||
private Template $template,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -77,42 +82,46 @@ final class ChangeLogController implements InvocableController
|
||||
$githubUrl = 'https://github.com/phpmyadmin/phpmyadmin/';
|
||||
$faqUrl = 'https://docs.phpmyadmin.net/en/latest/faq.html';
|
||||
|
||||
$replaces = [
|
||||
'@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@' => '<a href="'
|
||||
. Url::getFromRoute('/url') . '&url=\\1">\\1</a>',
|
||||
preg_match_all('@\n\[(\d+\.\d+\.\d+)]: (' . $githubUrl . '\S+)@', $changelog, $matches, PREG_SET_ORDER);
|
||||
$releaseLinks = array_column($matches, 2, 1);
|
||||
$changelog = (string) preg_replace_callback(
|
||||
'/\n## \[(\d+\.\d+\.\d+)]/',
|
||||
static fn (array $matches): string => "\n## [" . $matches[1] . '](' . $releaseLinks[$matches[1]] . ')',
|
||||
$changelog,
|
||||
);
|
||||
|
||||
// mail address
|
||||
'/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +<(.*@.*)>/i' => '\\1 <a href="mailto:\\3">\\2</a>',
|
||||
$replaces = [
|
||||
'/# Changes in phpMyAdmin (\d+\.\d+)/' => '<h1>Changes in phpMyAdmin \\1</h1>',
|
||||
'@\[Keep a Changelog\]\(https://keepachangelog.com/\)@' => 'Keep a Changelog',
|
||||
'/\n### (Added|Changed|Deprecated|Removed|Fixed|Security)/' => "\n" . '<h3>\\1</h3>',
|
||||
|
||||
// Add link to release title
|
||||
'@\n## \[(\d+\.\d+\.\d+)\]\((' . $githubUrl . '\S+)\) \- (\d{4}|YYYY)-(\d{2}|MM)-(\d{2}|DD)\n@' => "\n"
|
||||
. '<h2><a href="' . Url::getFromRoute('/url') . '&url=\\2">\\1</a> \\3-\\4-\\5</h2>' . "\n",
|
||||
|
||||
// Add link to GitHub issues/commits
|
||||
'@\[(\#\d+|[a-z0-9]+)\]\((' . $githubUrl . '\S+)\)@' => '<a href="'
|
||||
. Url::getFromRoute('/url') . '&url=\\2">\\1</a>',
|
||||
|
||||
// FAQ entries
|
||||
'/FAQ ([0-9]+)\.([0-9a-z]+)/i' => '<a href="'
|
||||
. Url::getFromRoute('/url') . '&url=' . $faqUrl . '#faq\\1-\\2">FAQ \\1.\\2</a>',
|
||||
|
||||
// GitHub issues
|
||||
'/issue\s*#?([0-9]{4,5}) /i' => '<a href="'
|
||||
. Url::getFromRoute('/url') . '&url=' . $githubUrl . 'issues/\\1">issue #\\1</a> ',
|
||||
|
||||
// CVE/CAN entries
|
||||
'/((CAN|CVE)-[0-9]+-[0-9]+)/' => '<a href="' . Url::getFromRoute('/url') . '&url='
|
||||
. 'https://www.cve.org/CVERecord?id=\\1">\\1</a>',
|
||||
|
||||
// PMASAentries
|
||||
// PMASA entries
|
||||
'/(PMASA-[0-9]+-[0-9]+)/' => '<a href="'
|
||||
. Url::getFromRoute('/url') . '&url=https://www.phpmyadmin.net/security/\\1/">\\1</a>',
|
||||
|
||||
// Highlight releases (with links)
|
||||
'/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/' => '<a id="\\1_\\2_\\3"></a>'
|
||||
. '<a href="' . Url::getFromRoute('/url') . '&url=' . $githubUrl . 'commits/RELEASE_\\1_\\2_\\3">'
|
||||
. '\\1.\\2.\\3.0 \\4</a>',
|
||||
'/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/' => '<a id="\\1_\\2_\\3_\\4"></a>'
|
||||
. '<a href="' . Url::getFromRoute('/url') . '&url=' . $githubUrl . 'commits/RELEASE_\\1_\\2_\\3_\\4">'
|
||||
. '\\1.\\2.\\3.\\4 \\5</a>',
|
||||
|
||||
// Highlight releases (not linkable)
|
||||
'/( ### )(.*)/' => '\\1<b>\\2</b>',
|
||||
|
||||
// Links target and rel
|
||||
'/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="',
|
||||
|
||||
// Remove release link references
|
||||
'@\n\[(\d+\.\d+\.\d+)]: (' . $githubUrl . '\S+)@' => '',
|
||||
|
||||
'/YYYY-MM-DD/' => '(not yet released)',
|
||||
];
|
||||
|
||||
return $response->write($this->template->render('changelog', [
|
||||
|
||||
48
tests/test_data/changelog/CHANGELOG-5.2.md
Normal file
48
tests/test_data/changelog/CHANGELOG-5.2.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Changes in phpMyAdmin 5.2
|
||||
|
||||
All notable changes of the phpMyAdmin 5.2 release series are documented in this file following the [Keep a Changelog](https://keepachangelog.com/) format.
|
||||
|
||||
## [5.2.2] - YYYY-MM-DD
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#17522](https://github.com/phpmyadmin/phpmyadmin/issues/17522): Fix case where the routes cache file is invalid
|
||||
|
||||
### Security
|
||||
|
||||
* Upgrade slim/psr7 to 1.4.1 for CVE-2023-30536 - GHSA-q2qj-628g-vhfw
|
||||
|
||||
## [5.2.1] - 2023-02-07
|
||||
|
||||
### Added
|
||||
|
||||
* [#17519](https://github.com/phpmyadmin/phpmyadmin/issues/17519): Fix Export pages not working in certain conditions
|
||||
* [#17496](https://github.com/phpmyadmin/phpmyadmin/issues/17496): Fix error in table operation page when partitions are broken
|
||||
|
||||
### Changed
|
||||
|
||||
* [#17519](https://github.com/phpmyadmin/phpmyadmin/issues/17519): Fix Export pages not working in certain conditions
|
||||
* [#17496](https://github.com/phpmyadmin/phpmyadmin/issues/17496): Fix error in table operation page when partitions are broken
|
||||
|
||||
### Deprecated
|
||||
|
||||
* [#17519](https://github.com/phpmyadmin/phpmyadmin/issues/17519): Fix Export pages not working in certain conditions
|
||||
* [#17496](https://github.com/phpmyadmin/phpmyadmin/issues/17496): Fix error in table operation page when partitions are broken
|
||||
|
||||
### Removed
|
||||
|
||||
* [#17519](https://github.com/phpmyadmin/phpmyadmin/issues/17519): Fix Export pages not working in certain conditions
|
||||
* [#17496](https://github.com/phpmyadmin/phpmyadmin/issues/17496): Fix error in table operation page when partitions are broken
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#17519](https://github.com/phpmyadmin/phpmyadmin/issues/17519): Fix Export pages not working in certain conditions
|
||||
* [#17496](https://github.com/phpmyadmin/phpmyadmin/issues/17496): Fix error in table operation page when partitions are broken
|
||||
* [#16418](https://github.com/phpmyadmin/phpmyadmin/issues/16418): Fix FAQ 1.44 about manually removing vendor folders
|
||||
|
||||
### Security
|
||||
|
||||
* Fix an XSS attack through the drag-and-drop upload feature (PMASA-2023-01)
|
||||
|
||||
[5.2.2]: https://github.com/phpmyadmin/phpmyadmin/compare/RELEASE_5_2_1...QA_5_2
|
||||
[5.2.1]: https://github.com/phpmyadmin/phpmyadmin/compare/RELEASE_5_2_0...RELEASE_5_2_1
|
||||
BIN
tests/test_data/changelog/CHANGELOG-5.2.md.gz
Normal file
BIN
tests/test_data/changelog/CHANGELOG-5.2.md.gz
Normal file
Binary file not shown.
@ -1,13 +0,0 @@
|
||||
phpMyAdmin - ChangeLog
|
||||
======================
|
||||
|
||||
5.2.2 (not yet released)
|
||||
- issue #17522 Fix case where the routes cache file is invalid
|
||||
- issue Upgrade slim/psr7 to 1.4.1 for CVE-2023-30536 - GHSA-q2qj-628g-vhfw
|
||||
|
||||
5.2.1 (2023-02-07)
|
||||
- issue #16418 Fix FAQ 1.44 about manually removing vendor folders
|
||||
- issue [security] Fix an XSS attack through the drag-and-drop upload feature (PMASA-2023-01)
|
||||
|
||||
--- Older ChangeLogs can be found on our project website ---
|
||||
https://www.phpmyadmin.net/old-stuff/ChangeLogs/
|
||||
Binary file not shown.
@ -20,10 +20,21 @@ final class ChangeLogControllerTest extends AbstractTestCase
|
||||
{
|
||||
public function testWithValidFile(): void
|
||||
{
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('getChangeLogFilePath')->willReturn(__DIR__ . '/../../test_data/changelog/ChangeLog');
|
||||
$this->assertChangelogOutputIsValid(__DIR__ . '/../../test_data/changelog/CHANGELOG-5.2.md');
|
||||
}
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/');
|
||||
#[RequiresPhpExtension('zlib')]
|
||||
public function testWithCompressedFile(): void
|
||||
{
|
||||
$this->assertChangelogOutputIsValid(__DIR__ . '/../../test_data/changelog/CHANGELOG-5.2.md.gz');
|
||||
}
|
||||
|
||||
private function assertChangelogOutputIsValid(string $changelogPath): void
|
||||
{
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('getChangeLogFilePath')->willReturn($changelogPath);
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'https://example.com/');
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$template = new Template();
|
||||
@ -35,19 +46,52 @@ final class ChangeLogControllerTest extends AbstractTestCase
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$changelog = <<<'HTML'
|
||||
phpMyAdmin - ChangeLog
|
||||
======================
|
||||
<h1>Changes in phpMyAdmin 5.2</h1>
|
||||
|
||||
5.2.2 (not yet released)
|
||||
- <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17522">issue #17522</a> Fix case where the routes cache file is invalid
|
||||
- issue Upgrade slim/psr7 to 1.4.1 for <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://www.cve.org/CVERecord?id=CVE-2023-30536">CVE-2023-30536</a> - GHSA-q2qj-628g-vhfw
|
||||
All notable changes of the phpMyAdmin 5.2 release series are documented in this file following the Keep a Changelog format.
|
||||
|
||||
5.2.1 (2023-02-07)
|
||||
- <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/16418">issue #16418</a> Fix <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://docs.phpmyadmin.net/en/latest/faq.html#faq1-44">FAQ 1.44</a> about manually removing vendor folders
|
||||
- issue [security] Fix an XSS attack through the drag-and-drop upload feature (<a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://www.phpmyadmin.net/security/PMASA-2023-01/">PMASA-2023-01</a>)
|
||||
<h2><a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/compare/RELEASE_5_2_1...QA_5_2">5.2.2</a> (not yet released)</h2>
|
||||
|
||||
<h3>Fixed</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17522">#17522</a>: Fix case where the routes cache file is invalid
|
||||
|
||||
<h3>Security</h3>
|
||||
|
||||
* Upgrade slim/psr7 to 1.4.1 for <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://www.cve.org/CVERecord?id=CVE-2023-30536">CVE-2023-30536</a> - GHSA-q2qj-628g-vhfw
|
||||
|
||||
<h2><a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/compare/RELEASE_5_2_0...RELEASE_5_2_1">5.2.1</a> 2023-02-07</h2>
|
||||
|
||||
<h3>Added</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17519">#17519</a>: Fix Export pages not working in certain conditions
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17496">#17496</a>: Fix error in table operation page when partitions are broken
|
||||
|
||||
<h3>Changed</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17519">#17519</a>: Fix Export pages not working in certain conditions
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17496">#17496</a>: Fix error in table operation page when partitions are broken
|
||||
|
||||
<h3>Deprecated</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17519">#17519</a>: Fix Export pages not working in certain conditions
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17496">#17496</a>: Fix error in table operation page when partitions are broken
|
||||
|
||||
<h3>Removed</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17519">#17519</a>: Fix Export pages not working in certain conditions
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17496">#17496</a>: Fix error in table operation page when partitions are broken
|
||||
|
||||
<h3>Fixed</h3>
|
||||
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17519">#17519</a>: Fix Export pages not working in certain conditions
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/17496">#17496</a>: Fix error in table operation page when partitions are broken
|
||||
* <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/16418">#16418</a>: Fix <a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://docs.phpmyadmin.net/en/latest/faq.html#faq1-44">FAQ 1.44</a> about manually removing vendor folders
|
||||
|
||||
<h3>Security</h3>
|
||||
|
||||
* Fix an XSS attack through the drag-and-drop upload feature (<a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://www.phpmyadmin.net/security/PMASA-2023-01/">PMASA-2023-01</a>)
|
||||
|
||||
--- Older ChangeLogs can be found on our project website ---
|
||||
<a target="_blank" rel="noopener noreferrer" href="index.php?route=/url&lang=en&url=https://www.phpmyadmin.net/old-stuff/ChangeLogs/">https://www.phpmyadmin.net/old-stuff/ChangeLogs/</a>
|
||||
|
||||
HTML;
|
||||
// phpcs:enable
|
||||
@ -56,36 +100,12 @@ final class ChangeLogControllerTest extends AbstractTestCase
|
||||
self::assertSame($expected, (string) $response->getBody());
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('zlib')]
|
||||
public function testWithCompressedFile(): void
|
||||
{
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('getChangeLogFilePath')->willReturn(__DIR__ . '/../../test_data/changelog/ChangeLog.gz');
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/');
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new ChangeLogController($responseRenderer, $config, ResponseFactory::create(), new Template());
|
||||
$response = $controller($request);
|
||||
|
||||
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
|
||||
self::assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type'));
|
||||
self::assertStringContainsString(
|
||||
'- <a target="_blank" rel="noopener noreferrer"'
|
||||
. ' href="index.php?route=/url&lang=en&url=https://github.com/phpmyadmin/phpmyadmin/issues/16418">'
|
||||
. 'issue #16418</a> Fix <a target="_blank" rel="noopener noreferrer"'
|
||||
. ' href="index.php?route=/url&lang=en&url=https://docs.phpmyadmin.net/en/latest/faq.html#faq1-44">'
|
||||
. 'FAQ 1.44</a> about manually removing vendor folders',
|
||||
(string) $response->getBody(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testWithInvalidFile(): void
|
||||
{
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('getChangeLogFilePath')->willReturn(__DIR__ . '/../../test_data/changelog/InvalidChangeLog');
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/');
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'https://example.com/');
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new ChangeLogController($responseRenderer, $config, ResponseFactory::create(), new Template());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user