Skip to content

Commit

Permalink
TASK: Merge branch '8.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Jun 1, 2022
2 parents cd05a65 + 0b1e534 commit 57acc46
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 38 deletions.
21 changes: 13 additions & 8 deletions Neos.Flow/Classes/Error/AbstractExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ public function handleException($exception)

$this->renderingOptions = $this->resolveCustomRenderingOptions($exception);

$exceptionWasLogged = false;
if ($this->throwableStorage instanceof ThrowableStorageInterface && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
$message = $this->throwableStorage->logThrowable($exception);
$this->logger->critical($message);
$exceptionWasLogged = true;
}

switch (PHP_SAPI) {
case 'cli':
$this->echoExceptionCli($exception);
break;
default:
$this->echoExceptionWeb($exception);
if (PHP_SAPI === 'cli') {
$this->echoExceptionCli($exception, $exceptionWasLogged);
}

$this->echoExceptionWeb($exception);
}

/**
Expand Down Expand Up @@ -243,17 +243,22 @@ protected function useCustomErrorView(): bool
* Formats and echoes the exception and its previous exceptions (if any) for the command line
*
* @param \Throwable $exception
* @param bool $exceptionWasLogged
* @return void
*/
protected function echoExceptionCli(\Throwable $exception)
protected function echoExceptionCli(\Throwable $exception, bool $exceptionWasLogged)
{
$response = new Response();

$exceptionMessage = $this->renderSingleExceptionCli($exception);
$exceptionMessage = $this->renderNestedExceptonsCli($exception, $exceptionMessage);

if ($exception instanceof FlowException) {
$exceptionMessage .= PHP_EOL . 'Open <b>Data/Logs/Exceptions/' . $exception->getReferenceCode() . '.txt</b> for a full stack trace.' . PHP_EOL;
if ($exceptionWasLogged) {
$exceptionMessage .= PHP_EOL . 'Open <b>Data/Logs/Exceptions/' . $exception->getReferenceCode() . '.txt</b> for a full stack trace.' . PHP_EOL;
} else {
$exceptionMessage .= PHP_EOL . 'The exception stacktrace was not logged, because "logException" is turned off.' . PHP_EOL;
}
}

$response->setContent($exceptionMessage);
Expand Down
7 changes: 6 additions & 1 deletion Neos.Flow/Classes/I18n/Cldr/Reader/DatesReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,15 @@ public function parseFormatFromCldr(Locale $locale, string $formatType, string $
if ($formatType === 'dateTime') {
// DateTime is a simple format like this: '{0} {1}' which denotes where to insert date and time
$parsedFormat = $this->prepareDateAndTimeFormat($format, $locale, $formatLength);

// Therefore, we need to change the format which is used as cache key to the expanded pattern
$format = '';
array_walk_recursive($parsedFormat, function ($element) use (&$format) {
$format .= $element;
});
} else {
$parsedFormat = $this->parseFormat($format);
}

$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
return $this->parsedFormats[$format] = $parsedFormat;
}
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Log/ThrowableStorage/FileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(string $storagePath)

$this->requestInformationRenderer = static function () {
// The following lines duplicate Scripts::initializeExceptionStorage(), which is a fallback to handle
// exceptions that may occure before Scripts::initializeExceptionStorage() has finished.
// exceptions that may occur before Scripts::initializeExceptionStorage() has finished.

$output = '';
if (!(Bootstrap::$staticObjectManager instanceof ObjectManagerInterface)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
`8.0.3 (2022-05-19) <https://github.com/neos/flow-development-collection/releases/tag/8.0.3>`_
==============================================================================================

Overview of merged pull requests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`FEATURE: Support object serialization without var annotation <https://github.com/neos/flow-development-collection/pull/2844>`_
-------------------------------------------------------------------------------------------------------------------------------

This change introduces support for PHP 7.4 style class property
type declarations for objects to be serialized by Flow. Previously,
a ``@var`` annotation had to be specified for each class property, in
order to communicate the type to Flow's serialization mechanism.

* Resolves: `#2843 <https://github.com/neos/flow-development-collection/issues/2843>`_

* Packages: ``Flow``

`BUGFIX: Store cache content in BLOB field with PdoBackend <https://github.com/neos/flow-development-collection/pull/2838>`_
----------------------------------------------------------------------------------------------------------------------------

The cache ``PdoBackend`` used a ``MEDIUMTEXT`` column for the content, with
some special handling for PostgreSQL to fix null bytes in the content.

When using igbinary, even with MariadDB problems can occur, since the
written content is garbled when fetched back and cannot be unserialized
anymore, leading to cache misses / read errors.

This change fixes it by using a ``MEDIUMBLOB`` (``BYTEA`` on PostgreSQL)
field for the content.

* See: `#2830 <https://github.com/neos/flow-development-collection/issues/2830>`_

**Upgrade instructions**

To make use of the new field, drop the ``cache`` table and run the cache setup again.

Another option is to switch the column type manually using a DB management tool
of your choice.

If you keep the old DB structure, aside from not having the fixed bug fixed:

- MariaDB doesn't care at all, the new code with the old DB structure works just fine.
- PostgreSQL will "work" but need a cache flush, as previously cached content shows wrong.

**Review instructions**

Hard to say, but you definitely need igbinary to run into the issue. Probably also a
specific kind of data that cannot be stored in MariaDB ``MEDIUMTEXT``.

For PostgreSQL some code that used to do bin2hex/hex2bin on the data has been
removed, so if things still work as before, this is good.


* Packages: ``Cache``

`TASK: Fix setup error handling in PdoBackendTest <https://github.com/neos/flow-development-collection/pull/2847>`_
-------------------------------------------------------------------------------------------------------------------

If the database setup fails, catching a ``Throwable`` is needed to skip
correctly.

**Review instructions**

The tests should pass, as opposed to https://github.com/neos/flow-development-collection/actions/runs/2346671349

See https://github.com/neos/flow-development-collection/pull/2838 for the "source" of this.

* Packages: ``Cache`` ``Eel`` ``Flow``

`TASK: Delete apigen.yml <https://github.com/neos/flow-development-collection/pull/2845>`_
------------------------------------------------------------------------------------------

The API documentation is discontinued, the tooling is outdated and
no one cares for static documentation anymore.

**Review instructions**


`TASK: Adjust issue and pr templates <https://github.com/neos/flow-development-collection/pull/2837>`_
------------------------------------------------------------------------------------------------------

the templates now mention that the texts are used in change logs and explain the informations we need during review

Should be merged together with:
- https://github.com/neos/BuildEssentials/pull/61
- https://github.com/neos/neos-development-collection/pull/3708

* Packages: ``Flow`` ``.github``

`TASK: Use type casting instead of intval/floatval <https://github.com/neos/flow-development-collection/pull/2833>`_
--------------------------------------------------------------------------------------------------------------------

Use type casting instead of slower function calls.

* Packages: ``Eel`` ``Flow`` ``Utility.Arrays``

`Detailed log <https://github.com/neos/flow-development-collection/compare/8.0.2...8.0.3>`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 changes: 21 additions & 28 deletions Neos.Flow/Tests/Functional/I18n/Cldr/Reader/DatesReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/

use Neos\Flow\I18n\Cldr\Reader\DatesReader;
use Neos\Flow\I18n\Locale;
use Neos\Flow\Tests\FunctionalTestCase;
use Neos\Flow\I18n;

class DatesReaderTest extends FunctionalTestCase
{
Expand All @@ -25,41 +25,34 @@ class DatesReaderTest extends FunctionalTestCase
*/
protected $datesReader;

protected function setUp(): void
public function setUp(): void
{
parent::setUp();

$this->datesReader = $this->objectManager->get(DatesReader::class);
}

/**
* Data provider with valid format strings and expected results.
*
* @return array
*/
public function formatStringsAndParsedFormats(): array
{
return [
['de', ['dd', ['.'], 'MM', ['.'], 'y']],
['en', ['MMM', [' '], 'd', [','], [' '], 'y']],
];
}

/**
* @test
* @dataProvider formatStringsAndParsedFormats
* @param string $localeIdentifier
* @param array $expectedResult
* @throws I18n\Cldr\Reader\Exception\InvalidDateTimeFormatException
* @throws I18n\Cldr\Reader\Exception\InvalidFormatLengthException
* @throws I18n\Cldr\Reader\Exception\InvalidFormatTypeException
* @throws I18n\Cldr\Reader\Exception\UnableToFindFormatException
* @throws I18n\Exception\InvalidLocaleIdentifierException
*/
public function formatStringsAreParsedCorrectly(string $localeIdentifier, array $expectedResult): void
public function parseFormatFromCldrCachesDateTimePatternsForEachLanguageIndependently(): void
{
$locale = new I18n\Locale($localeIdentifier);
$result = $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATE, DatesReader::FORMAT_LENGTH_DEFAULT);
self::assertEquals($expectedResult, $result);
$convertFormatToString = function (array $formatArray) {
$format = '';
array_walk_recursive($formatArray, function ($element) use (&$format) {
$format .= $element;
});
return $format;
};

// Warms the cache with parsed formats for en_US and de
$this->datesReader->parseFormatFromCldr(new Locale('en_US'), DatesReader::FORMAT_TYPE_DATETIME, DatesReader::FORMAT_LENGTH_SHORT);
$this->datesReader->parseFormatFromCldr(new Locale('de'), DatesReader::FORMAT_TYPE_DATETIME, DatesReader::FORMAT_LENGTH_SHORT);

// Reads two different cache entries
$enUSFormat = $this->datesReader->parseFormatFromCldr(new Locale('en_US'), DatesReader::FORMAT_TYPE_DATETIME, DatesReader::FORMAT_LENGTH_SHORT);
self::assertEquals('M/d/yy, h:mm a', $convertFormatToString($enUSFormat));

$deFormat = $this->datesReader->parseFormatFromCldr(new Locale('de'), DatesReader::FORMAT_TYPE_DATETIME, DatesReader::FORMAT_LENGTH_SHORT);
self::assertEquals('dd.MM.yy, HH:mm', $convertFormatToString($deFormat));
}
}

0 comments on commit 57acc46

Please sign in to comment.