API Platform version(s) affected: 3.2
Description
Inside the newly added AddLinkHeaderProcessor the getLinks() call fails, if no request attribute with name _api_platform_links exists.
Error:
[Error] Call to a member function getLinks() on null
It does not even reach the custom processor.
How to reproduce
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata as Api;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
#[
ORM\Entity,
ORM\Table(name: 'my_entity'),
Api\ApiResource(
operations: [
new Api\Patch(
denormalizationContext: [
'groups' => ['rest:update'],
],
processor: MyCustomProcessor::class
),
],
mercure: false
)
]
class MyRequest
#[
ORM\Id,
ORM\GeneratedValue(strategy: 'CUSTOM'),
ORM\CustomIdGenerator(class: GuidGenerator::class),
ORM\Column(type: 'guid'),
Assert\Uuid,
]
private string $id;
#[
ORM\Column(type: 'string'),
Assert\Type(type: 'string'),
Serializer\Groups(['rest:update'])
]
private string $someId = '';
}
Run a plain PATCH request with the property someId set to some string. The request runs through these files
/var/www/html/vendor/api-platform/core/src/State/Processor/AddLinkHeaderProcessor.php:43
/var/www/html/vendor/api-platform/core/src/HttpCache/State/AddHeadersProcessor.php:32
/var/www/html/vendor/api-platform/core/src/Symfony/State/MercureLinkProcessor.php:32
/var/www/html/vendor/api-platform/core/src/State/Processor/SerializeProcessor.php:75
/var/www/html/vendor/api-platform/core/src/State/Processor/WriteProcessor.php:42
/var/www/html/vendor/api-platform/core/src/Symfony/Controller/MainController.php:100
... and fails.
API Platform version(s) affected: 3.2
Description
Inside the newly added
AddLinkHeaderProcessorthegetLinks()call fails, if no request attribute with name_api_platform_linksexists.Error:
It does not even reach the custom processor.
How to reproduce
Run a plain
PATCHrequest with the propertysomeIdset to some string. The request runs through these files... and fails.