Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4680724
fix(metadata): resource name collection missing deprecation (#4953)
lchrusciel Sep 16, 2022
e3e81fb
docs: minor changelog fixes (#4949)
dunglas Sep 16, 2022
4092a8d
chore: drop dependency on fig/link-util (#4945)
nicolas-grekas Sep 16, 2022
c037806
fix(symfony): missing Elasticsearch DocumentMetadataFactoryInterface …
walva Sep 17, 2022
d099dd6
fix(symfony): upgrade command removes filters (#4970)
emmanuelballery Sep 17, 2022
11ed63d
fix(symfony): upgrade command requires phpunit (#4968)
soyuka Sep 17, 2022
fc639ea
fix(metadata): do not auto-generate NotExposed operation when using c…
vincentchalamon Sep 19, 2022
b0730bb
fix(symfony): missing deprecations related to Ulid and Uuid normalize…
walva Sep 19, 2022
8691fdf
chore: commitlint only the Pull Request HEAD (#4983)
soyuka Sep 20, 2022
693b03a
fix(symfony): bc layer broken for symfony/console lower than 5.3 (#4990)
deguif Sep 23, 2022
d265387
chore: add conflict on elasticsearch >= 8.0 (#5018)
alanpoulain Sep 27, 2022
4ca639c
fix(symfony): add missing dependency on symfony/deprecation-contracts…
GuilhemN Sep 27, 2022
44ba110
fix: replace FQCN service names by snake ones (#5019)
alanpoulain Sep 28, 2022
603551a
fix(metadata): fix missing `array` cast for RDF types in `ApiResource…
chalasr Sep 29, 2022
07afa77
fix: check fetch joined queries based on all aliases (#4974)
Sajito Sep 29, 2022
9895e34
fix(symfony): don't use ArrayAdapter in production #4975 (#5025)
soyuka Sep 29, 2022
1091938
chore: update swagger ui and javascript libraries (#5028)
soyuka Sep 29, 2022
e0a8a1a
Merge 2.7 into 3.0
soyuka Sep 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .commitlintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"defaultIgnores": true,
"parserPreset": "conventional-changelog-conventionalcommits",
"extends": "@commitlint/config-conventional",
"rules": {
"scope-enum": [
2,
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ env:

jobs:
commitlint:
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
configFile: .commitlintrc
- uses: wagoid/commitlint-github-action@v5
- name: Run commitlint
run: |
commit=$(gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/pulls/${{github.event.number}}/commits \
| jq -r '.[0].commit.message')
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
echo '{}' > package.json
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc
php-cs-fixer:
name: PHP-cs-fixer (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
Expand Down
34 changes: 19 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@

Various cleanup in services and removal of backward compatibility layer.

## 2.7.0

* chore: remove @experimental phpdoc (#4933)
* Metadata: do not set id when identifier is `false` (#4880)
* Metadata: automatic GET operation when none is declared (#4881)
* Metadata: exception to status on operations (#4861)
* Serializer: adds the JSON_INVALID_UTF8_IGNORE flag to JsonEncode (#4741)
* Symfony: autoconfigure legacy Doctrine extensions (#4909)
* Elasticsearch: skip metadata without ES nodes (#4913)
* Symfony: deprecated the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)

Various cs fixes and PHPDoc to help upgrading to 3.0.

## 3.0.0-rc.2

* JsonLd: correct the `api_jsonld_context` route format (#4844)
Expand All @@ -49,6 +36,23 @@ Breaking changes:
* Metadata: the `Core` namespace got removed (#4805)
* Mercure: deprecation removed (#4805)

## 2.7.1

* Replace FQCN service names by snake ones (#5019)

## 2.7.0

* chore: remove @experimental phpdoc (#4933)
* Metadata: do not set id when identifier is `false` (#4880)
* Metadata: automatic GET operation when none is declared (#4881)
* Metadata: exception to status on operations (#4861)
* Serializer: adds the JSON_INVALID_UTF8_IGNORE flag to JsonEncode (#4741)
* Symfony: autoconfigure legacy Doctrine extensions (#4909)
* Elasticsearch: skip metadata without ES nodes (#4913)
* Symfony: deprecated the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)

Various cs fixes and PHPDoc to help upgrading to 3.0.

## 2.7.0-rc.2

* Symfony: the upgrade command now updates ApiFilter as well (#4845)
Expand Down Expand Up @@ -140,7 +144,7 @@ Doctrine: new interfaces for Filters and Extensions ready, switch to the `ApiPla

* Swagger UI: Add `usePkceWithAuthorizationCodeGrant` to Swagger UI initOAuth (#4649)
* **BC**: `mapping.paths` in configuration should override bundles configuration (#4465)
* GraphQL: Add ability to use different pagination types for the queries of a resource (#4453)
* GraphQL: Add the ability to use different pagination types for the queries of a resource (#4453)
* Security: **BC** Fix `ApiProperty` `security` attribute expression being passed a class string for the `object` variable on updates/creates - null is now passed instead if the object is not available (#4184)
* Security: `ApiProperty` now supports a `security_post_denormalize` attribute, which provides access to the `object` variable for the object being updated/created and `previous_object` for the object before it was updated (#4184)
* Maker: Add `make:data-provider` and `make :data-persister` commands to generate a data provider / persister (#3850)
Expand Down Expand Up @@ -174,7 +178,7 @@ Doctrine: new interfaces for Filters and Extensions ready, switch to the `ApiPla
* Metadata: deprecation of `ApiPlatform\Core\Annotation` (#4351)
* Metadata: `ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface` is deprecated in favor of `ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface` (#4351)
* Metadata: item and collection prefixes for operations are deprecated, as well as the `ApiPlatform\Core\Api\OperationType` class (#4351)
* Graphql: `ApiPlatform\Metadata\GraphQl` follow the same metadata conventions (a Subscription operation is available and isn't hidden behind an update Mutation anymore), interfaces got simplified (beeing @experimental) (#4351)
* Graphql: `ApiPlatform\Metadata\GraphQl` follow the same metadata conventions (a Subscription operation is available and isn't hidden behind an update Mutation anymore), interfaces got simplified (being @experimental) (#4351)
* IriConverter: new interface for `ApiPlatform\Bridge\Symfony\Routing\IriConverter` that adds an operationName, same for `ApiPlatform\Api\IdentifiersExtractor` (#4351)
* DataProvider: new `ApiPlatform\State\ProviderInterface` that replaces DataProviders (#4351)
* DataPersister: new `ApiPlatform\State\ProcessorInterface` that replaces DataPersisters (#4351)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"require": {
"php": ">=8.1",
"doctrine/inflector": "^1.0 || ^2.0",
"fig/link-util": "^1.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/container": "^1.0 || ^2.0",
"symfony/http-foundation": "^6.1",
Expand Down Expand Up @@ -100,7 +99,8 @@
"doctrine/common": "<2.7",
"doctrine/dbal": "<2.10",
"doctrine/mongodb-odm": "<2.2",
"doctrine/persistence": "<1.3"
"doctrine/persistence": "<1.3",
"elasticsearch/elasticsearch": ">=8.0"
},
"suggest": {
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
Expand Down
24 changes: 5 additions & 19 deletions src/Doctrine/Orm/Util/QueryChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,14 @@ public static function hasMaxResults(QueryBuilder $queryBuilder): bool
public static function hasOrderByOnFetchJoinedToManyAssociation(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
if (
0 === (is_countable($selectParts = $queryBuilder->getDQLPart('select')) ? \count($selectParts = $queryBuilder->getDQLPart('select')) : 0) ||
0 === (is_countable($queryBuilder->getDQLPart('join')) ? \count($queryBuilder->getDQLPart('join')) : 0) ||
0 === (is_countable($orderByParts = $queryBuilder->getDQLPart('orderBy')) ? \count($orderByParts = $queryBuilder->getDQLPart('orderBy')) : 0)
0 === \count($queryBuilder->getDQLPart('join')) ||
0 === \count($orderByParts = $queryBuilder->getDQLPart('orderBy'))
) {
return false;
}

$rootAliases = $queryBuilder->getRootAliases();

$selectAliases = [];

foreach ($selectParts as $select) {
foreach ($select->getParts() as $part) {
[$alias] = explode('.', (string) $part);

$selectAliases[] = $alias;
}
}

$selectAliases = array_diff($selectAliases, $rootAliases);
if (0 === \count($selectAliases)) {
return false;
}

$orderByAliases = [];

foreach ($orderByParts as $orderBy) {
Expand All @@ -133,11 +117,13 @@ public static function hasOrderByOnFetchJoinedToManyAssociation(QueryBuilder $qu
return false;
}

$allAliases = $queryBuilder->getAllAliases();

foreach ($orderByAliases as $orderByAlias) {
$inToManyContext = false;

foreach (QueryBuilderHelper::traverseJoins($orderByAlias, $queryBuilder, $managerRegistry) as $alias => [$metadata, $association]) {
if ($inToManyContext && \in_array($alias, $selectAliases, true)) {
if ($inToManyContext && \in_array($alias, $allAliases, true)) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Hydra/EventListener/AddLinkHeaderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\JsonLd\ContextBuilder;
use ApiPlatform\Util\CorsTrait;
use Fig\Link\GenericLinkProvider;
use Fig\Link\Link;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\WebLink\GenericLinkProvider;
use Symfony\Component\WebLink\Link;

/**
* Adds the HTTP Link header pointing to the Hydra documentation.
Expand Down
5 changes: 4 additions & 1 deletion src/Metadata/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
private ?bool $push = null,
private ?string $security = null,
private ?string $securityPostDenormalize = null,
private $types = null,
private array|string|null $types = null,
/**
* The related php types.
*/
Expand All @@ -70,6 +70,9 @@ public function __construct(
private $iris = null,
private array $extraProperties = []
) {
if (\is_string($types)) {
$this->types = (array) $types;
}
}

public function getDescription(): ?string
Expand Down
7 changes: 5 additions & 2 deletions src/Metadata/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ApiResource
protected $processor;

/**
* @param array|null $types The RDF types of this resource
* @param array|string|null $types The RDF types of this resource
* @param mixed|null $operations
* @param array|string|null $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string|null $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
Expand Down Expand Up @@ -83,7 +83,7 @@ public function __construct(
protected ?string $uriTemplate = null,
protected ?string $shortName = null,
protected ?string $description = null,
protected $types = null,
protected string|array|null $types = null,
$operations = null,
protected $formats = null,
protected $inputFormats = null,
Expand Down Expand Up @@ -147,6 +147,9 @@ public function __construct(
$this->operations = null === $operations ? null : new Operations($operations);
$this->provider = $provider;
$this->processor = $processor;
if (\is_string($types)) {
$this->types = (array) $types;
}
}

public function getOperations(): ?Operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Metadata\Resource\Factory;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\CollectionOperationInterface;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\HttpOperation;
use ApiPlatform\Metadata\NotExposed;
Expand Down Expand Up @@ -58,7 +59,7 @@ public function create(string $resourceClass): ResourceMetadataCollection

foreach ($operations as $operation) {
// An item operation has been found, nothing to do anymore in this factory
if ($operation instanceof Get) {
if ((HttpOperation::METHOD_GET === $operation->getMethod() && !$operation instanceof CollectionOperationInterface) || ($operation->getExtraProperties()['is_legacy_resource_metadata'] ?? false)) {
return $resourceMetadataCollection;
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/Symfony/Bundle/Resources/config/doctrine_mongodb_odm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<factory service="doctrine_mongodb.odm.default_document_manager" method="getMetadataFactory"/>
</service>

<service id="ApiPlatform\Doctrine\Common\State\RemoveProcessor" class="ApiPlatform\Doctrine\Common\State\RemoveProcessor">
<service id="api_platform.doctrine_mongodb.odm.state.remove_processor" class="ApiPlatform\Doctrine\Common\State\RemoveProcessor">
<argument type="service" id="doctrine_mongodb" />

<tag name="api_platform.state_processor" priority="-100" />
<tag name="api_platform.state_processor" priority="-100" key="ApiPlatform\Doctrine\Common\State\RemoveProcessor" />
</service>
<service id="api_platform.doctrine_mongodb.odm.state.remove_processor" alias="ApiPlatform\Doctrine\Common\State\RemoveProcessor" />
<service id="ApiPlatform\Doctrine\Common\State\RemoveProcessor" alias="api_platform.doctrine_mongodb.odm.state.remove_processor" />

<service id="ApiPlatform\Doctrine\Common\State\PersistProcessor" class="ApiPlatform\Doctrine\Common\State\PersistProcessor">
<service id="api_platform.doctrine_mongodb.odm.state.persist_processor" class="ApiPlatform\Doctrine\Common\State\PersistProcessor">
<argument type="service" id="doctrine_mongodb" />

<tag name="api_platform.state_processor" priority="-100" />
<tag name="api_platform.state_processor" priority="-100" key="ApiPlatform\Doctrine\Common\State\PersistProcessor" />
</service>
<service id="api_platform.doctrine_mongodb.odm.state.persist_processor" alias="ApiPlatform\Doctrine\Common\State\PersistProcessor" />
<service id="ApiPlatform\Doctrine\Common\State\PersistProcessor" alias="api_platform.doctrine_mongodb.odm.state.persist_processor" />

<!-- Filter -->

Expand Down Expand Up @@ -121,23 +121,23 @@

<service id="ApiPlatform\Doctrine\Odm\Filter\SearchFilter" alias="api_platform.doctrine_mongodb.odm.search_filter" />

<service id="ApiPlatform\Doctrine\Odm\State\CollectionProvider" class="ApiPlatform\Doctrine\Odm\State\CollectionProvider" public="false">
<service id="api_platform.doctrine_mongodb.odm.state.collection_provider" class="ApiPlatform\Doctrine\Odm\State\CollectionProvider" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="doctrine_mongodb" />
<argument type="tagged" tag="api_platform.doctrine_mongodb.odm.aggregation_extension.collection" />

<tag name="api_platform.state_provider" priority="-100" />
<tag name="api_platform.state_provider" priority="-100" key="ApiPlatform\Doctrine\Odm\State\CollectionProvider" />
</service>
<service id="api_platform.doctrine_mongodb.odm.state.collection_provider" alias="ApiPlatform\Doctrine\Odm\State\CollectionProvider" />
<service id="ApiPlatform\Doctrine\Odm\State\CollectionProvider" alias="api_platform.doctrine_mongodb.odm.state.collection_provider" />

<service id="ApiPlatform\Doctrine\Odm\State\ItemProvider" class="ApiPlatform\Doctrine\Odm\State\ItemProvider" public="false">
<service id="api_platform.doctrine_mongodb.odm.state.item_provider" class="ApiPlatform\Doctrine\Odm\State\ItemProvider" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="doctrine_mongodb" />
<argument type="tagged" tag="api_platform.doctrine_mongodb.odm.aggregation_extension.item" />

<tag name="api_platform.state_provider" priority="-100" />
<tag name="api_platform.state_provider" priority="-100" key="ApiPlatform\Doctrine\Odm\State\ItemProvider" />
</service>
<service id="api_platform.doctrine_mongodb.odm.state.item_provider" alias="ApiPlatform\Doctrine\Odm\State\ItemProvider" />
<service id="ApiPlatform\Doctrine\Odm\State\ItemProvider" alias="api_platform.doctrine_mongodb.odm.state.item_provider" />
<service id="api_platform.state.item_provider" alias="ApiPlatform\Doctrine\Odm\State\ItemProvider" />

<service id="api_platform.doctrine.odm.metadata.resource.metadata_collection_factory" class="ApiPlatform\Doctrine\Odm\Metadata\Resource\DoctrineMongoDbOdmResourceCollectionMetadataFactory" decorates="api_platform.metadata.resource.metadata_collection_factory" decoration-priority="40">
Expand Down
24 changes: 12 additions & 12 deletions src/Symfony/Bundle/Resources/config/doctrine_orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<factory service="doctrine.orm.default_entity_manager" method="getMetadataFactory" />
</service>

<service id="ApiPlatform\Doctrine\Common\State\RemoveProcessor" class="ApiPlatform\Doctrine\Common\State\RemoveProcessor">
<service id="api_platform.doctrine.orm.state.remove_processor" class="ApiPlatform\Doctrine\Common\State\RemoveProcessor">
<argument type="service" id="doctrine" />

<tag name="api_platform.state_processor" priority="-100" />
<tag name="api_platform.state_processor" priority="-100" key="ApiPlatform\Doctrine\Common\State\RemoveProcessor" />
</service>
<service id="api_platform.doctrine.orm.state.remove_processor" alias="ApiPlatform\Doctrine\Common\State\RemoveProcessor" />
<service id="ApiPlatform\Doctrine\Common\State\RemoveProcessor" alias="api_platform.doctrine.orm.state.remove_processor" />

<service id="ApiPlatform\Doctrine\Common\State\PersistProcessor" class="ApiPlatform\Doctrine\Common\State\PersistProcessor">
<service id="api_platform.doctrine.orm.state.persist_processor" class="ApiPlatform\Doctrine\Common\State\PersistProcessor">
<argument type="service" id="doctrine" />

<tag name="api_platform.state_processor" priority="-100" />
<tag name="api_platform.state_processor" priority="-100" key="ApiPlatform\Doctrine\Common\State\PersistProcessor" />
</service>
<service id="api_platform.doctrine.orm.state.persist_processor" alias="ApiPlatform\Doctrine\Common\State\PersistProcessor" />
<service id="ApiPlatform\Doctrine\Common\State\PersistProcessor" alias="api_platform.doctrine.orm.state.persist_processor" />

<!-- Filter -->

Expand Down Expand Up @@ -129,23 +129,23 @@
<argument type="service" id="api_platform.doctrine.orm.metadata.property.identifier_metadata_factory.inner" />
</service>

<service id="ApiPlatform\Doctrine\Orm\State\CollectionProvider" class="ApiPlatform\Doctrine\Orm\State\CollectionProvider" public="false">
<service id="api_platform.doctrine.orm.state.collection_provider" class="ApiPlatform\Doctrine\Orm\State\CollectionProvider" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="doctrine" />
<argument type="tagged" tag="api_platform.doctrine.orm.query_extension.collection" />

<tag name="api_platform.state_provider" priority="-100" />
<tag name="api_platform.state_provider" priority="-100" key="ApiPlatform\Doctrine\Orm\State\CollectionProvider" />
</service>
<service id="api_platform.doctrine.orm.state.collection_provider" alias="ApiPlatform\Doctrine\Orm\State\CollectionProvider" />
<service id="ApiPlatform\Doctrine\Orm\State\CollectionProvider" alias="api_platform.doctrine.orm.state.collection_provider" />

<service id="ApiPlatform\Doctrine\Orm\State\ItemProvider" class="ApiPlatform\Doctrine\Orm\State\ItemProvider" public="false">
<service id="api_platform.doctrine.orm.state.item_provider" class="ApiPlatform\Doctrine\Orm\State\ItemProvider" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="doctrine" />
<argument type="tagged" tag="api_platform.doctrine.orm.query_extension.item" />

<tag name="api_platform.state_provider" priority="-100" />
<tag name="api_platform.state_provider" priority="-100" key="ApiPlatform\Doctrine\Orm\State\ItemProvider" />
</service>
<service id="api_platform.doctrine.orm.state.item_provider" alias="ApiPlatform\Doctrine\Orm\State\ItemProvider" />
<service id="ApiPlatform\Doctrine\Orm\State\ItemProvider" alias="api_platform.doctrine.orm.state.item_provider" />
<service id="api_platform.state.item_provider" alias="ApiPlatform\Doctrine\Orm\State\ItemProvider" />

<service id="api_platform.doctrine.orm.search_filter" class="ApiPlatform\Doctrine\Orm\Filter\SearchFilter" public="false" abstract="true">
Expand Down
Loading