Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Directly parse request body as associative array #106

Merged
merged 70 commits into from
Nov 1, 2023

Conversation

mabolek
Copy link
Contributor

@mabolek mabolek commented Sep 13, 2023

The HTTP request body was previously first parsed into objects and then converted to an array. This was done to be able to detect the difference between record data and nested table/recordId/language/workspace arrays. This can instead be implemented using array_is_list(). symfony/polyfill-php81 provides a polyfill for PHP versions below 8.1.

This commit also adds an optional third parameter, ?array $parsedBody = null, to \Pixelant\Interest\RequestHandler\AbstractRecordRequestHandler::__construct(). This parameter makes it possible to supply a parsed JSON body as associative array to avoid parsing JSON twice.

Removes compatibility code for versions below v11 and upgrades composer dependencies.
It is now possible to configure how empty files are handled. The extension configuration property `handleEmptyFile` can be set to these values:

0: Treat as any other file. You can also use this option if you want to handle empty files with a custom `Pixelant\Interest\DataHandling\Operation\Event\BeforeRecordOperationEvent`. Just make sure your EventHandler it is executed after `\Pixelant\Interest\DataHandling\Operation\Event\Handler\PersistFileDataEventHandler`.

1: Stop processing the record. This might result in pending relation records that will never be resolved in the database, but if that's OK for you it won't cause any issues.

2: Fail. The operation will be treated as failed and returns an error.
Removes compatibility code for versions below v11 and upgrades composer dependencies.
It is now possible to configure how empty files are handled. The extension configuration property `handleEmptyFile` can be set to these values:

0: Treat as any other file. You can also use this option if you want to handle empty files with a custom `Pixelant\Interest\DataHandling\Operation\Event\BeforeRecordOperationEvent`. Just make sure your EventHandler it is executed after `\Pixelant\Interest\DataHandling\Operation\Event\Handler\PersistFileDataEventHandler`.

1: Stop processing the record. This might result in pending relation records that will never be resolved in the database, but if that's OK for you it won't cause any issues.

2: Fail. The operation will be treated as failed and returns an error.
Use `getDataForDataHandler()` and `setDataForDataHandler()` instead.
Reduces code by rewriting HttpBackendUserAuthentication to use more functionality from TYPO3 core.
Moves deprecated method declaration into separate class.
To try to avoid triggering the autoloader.
To try to avoid triggering the autoloader.
Due to the changes in BackendUserAuthentication between TYPO3 v11 and v12, we have to load different versions of the HttpBackendUserAuthentication class on runtime.
UpdateRecordOperationTest has been updated so $imageUpdates is no longer overwritten in the foreach loop.

Fixes #103
Versions below this will fail in TYPO3 v12 due to a missing fallback. See: TYPO3/testing-framework#497
The HTTP request body was previously first parsed into objects and then converted to an array. This was done to be able to detect the difference between record data and nested table/recordId/language/workspace arrays. This can instead be implemented using `array_is_list()`. `symfony/polyfill-php81` provides a polyfill for PHP versions below 8.1.

This commit also adds an optional third parameter, `?array $parsedBody = null`, to  `\Pixelant\Interest\RequestHandler\AbstractRecordRequestHandler::__construct()`. This parameter makes it possible to supply a parsed JSON body as associative array to avoid parsing JSON twice.
@mabolek mabolek changed the base branch from master to typo3v12 September 13, 2023 00:18
@mabolek mabolek changed the title [TASK] Directly parse request body as associative array [WIP][TASK] Directly parse request body as associative array Sep 13, 2023
@mabolek mabolek self-assigned this Sep 13, 2023
* Rename `$decodedContent` to `$parsedBody`
* Correctly set metadata
* Throw exception on JSON decode error
* Fetch and parse request body in separate method
@mabolek mabolek changed the title [WIP][TASK] Directly parse request body as associative array [TASK] Directly parse request body as associative array Nov 1, 2023
Copy link
Contributor

@MattiasNilsson MattiasNilsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one small feedback!

Base automatically changed from typo3v12 to master November 1, 2023 08:48
@mabolek mabolek merged commit 31d3c48 into master Nov 1, 2023
37 checks passed
@mabolek mabolek deleted the typo3v12-array-is-list branch November 1, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants