Merge pull request #31312 from woocommerce/fix/formatter

Fix PHP Fatal error in Changelogger Formatter class
This commit is contained in:
Roy Ho 2021-11-29 07:28:34 -08:00 committed by GitHub
commit 9e744e4029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -140,15 +140,15 @@ class Formatter extends KeepAChangelogParser {
} }
$version = ''; $version = '';
$timestamp = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); $timestamp = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
$entry_timestamp = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); $entry_timestamp = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
if ( count( $heading ) ) { if ( count( $heading ) ) {
$version = $heading[1]; $version = $heading[1];
$timestamp = $heading[2]; $timestamp = $heading[2];
try { try {
$timestamp = new DateTime( $timestamp, new DateTimeZone( 'UTC' ) ); $timestamp = new \DateTime( $timestamp, new \DateTimeZone( 'UTC' ) );
} catch ( \Exception $ex ) { } catch ( \Exception $ex ) {
throw new \InvalidArgumentException( "Heading has an invalid timestamp: $heading", 0, $ex ); throw new \InvalidArgumentException( "Heading has an invalid timestamp: $heading", 0, $ex );
} }
@ -239,7 +239,6 @@ class Formatter extends KeepAChangelogParser {
$version = $entry->getVersion(); $version = $entry->getVersion();
$is_subentry = preg_match( $this->subentry_pattern, $version, $subentry ); $is_subentry = preg_match( $this->subentry_pattern, $version, $subentry );
$timestamp = $entry->getTimestamp(); $timestamp = $entry->getTimestamp();
error_log(print_r($version, true));
$release_link = $this->getReleaseLink( $version ); $release_link = $this->getReleaseLink( $version );
if ( $is_subentry ) { if ( $is_subentry ) {