Skip to content

Commit b448e74

Browse files
authored
Merge pull request #2920 from meyerbaptiste/fix_deprecation_notices_2.4
Fix deprecation notices in 2.4
2 parents 0ceb418 + 08a4ce3 commit b448e74

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ parameters:
101101
- '#Method ApiPlatform\\Core\\DataProvider\\CollectionDataProviderInterface::getCollection\(\) invoked with 3 parameters, 1-2 required\.#'
102102
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 3 parameters, 1 required\.#'
103103
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 4 parameters, 1 required\.#'
104+
- '#Class Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener constructor invoked with 5 parameters, 1-3 required\.#'

src/Bridge/Symfony/Bundle/Resources/views/DataCollector/request.html.twig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@
164164
</thead>
165165

166166
<tbody>
167-
{% for key, value in collector.resourceMetadata.attributes if key != 'filters' %}
168-
<tr>
169-
<th scope="row">{{ key }}</th>
170-
<td>{{- profiler_dump(value, 2) -}}</td>
171-
</tr>
167+
{% for key, value in collector.resourceMetadata.attributes %}
168+
{% if key != 'filters' %}
169+
<tr>
170+
<th scope="row">{{ key }}</th>
171+
<td>{{- profiler_dump(value, 2) -}}</td>
172+
</tr>
173+
{% endif %}
172174
{% endfor %}
173175
</tbody>
174176
</table>

src/EventListener/ExceptionListener.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace ApiPlatform\Core\EventListener;
1515

1616
use ApiPlatform\Core\Util\RequestAttributesExtractor;
17+
use Psr\Log\LoggerInterface;
1718
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
1819
use Symfony\Component\HttpKernel\EventListener\ExceptionListener as BaseExceptionListener;
1920

@@ -23,8 +24,15 @@
2324
* @author Samuel ROZE <[email protected]>
2425
* @author Kévin Dunglas <[email protected]>
2526
*/
26-
final class ExceptionListener extends BaseExceptionListener
27+
final class ExceptionListener
2728
{
29+
private $exceptionListener;
30+
31+
public function __construct($controller, LoggerInterface $logger = null, $debug = false, string $charset = null, $fileLinkFormat = null)
32+
{
33+
$this->exceptionListener = new BaseExceptionListener($controller, $logger, $debug, $charset, $fileLinkFormat);
34+
}
35+
2836
public function onKernelException(GetResponseForExceptionEvent $event): void
2937
{
3038
$request = $event->getRequest();
@@ -36,6 +44,6 @@ public function onKernelException(GetResponseForExceptionEvent $event): void
3644
return;
3745
}
3846

39-
parent::onKernelException($event);
47+
$this->exceptionListener->onKernelException($event);
4048
}
4149
}

src/Serializer/AbstractItemNormalizer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ protected function denormalizeCollection(string $attribute, PropertyMetadata $pr
396396
);
397397
}
398398

399-
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $this->createChildContext($context, $attribute));
399+
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $this->createChildContext($context, $attribute, $format));
400400
}
401401

402402
return $values;
@@ -531,7 +531,7 @@ protected function getAttributeValue($object, $attribute, $format = null, array
531531
$this->resourceClassResolver->isResourceClass($className)
532532
) {
533533
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
534-
$childContext = $this->createChildContext($context, $attribute);
534+
$childContext = $this->createChildContext($context, $attribute, $format);
535535
$childContext['resource_class'] = $resourceClass;
536536

537537
return $this->normalizeCollectionOfRelations($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
@@ -543,7 +543,7 @@ protected function getAttributeValue($object, $attribute, $format = null, array
543543
$this->resourceClassResolver->isResourceClass($className)
544544
) {
545545
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
546-
$childContext = $this->createChildContext($context, $attribute);
546+
$childContext = $this->createChildContext($context, $attribute, $format);
547547
$childContext['resource_class'] = $resourceClass;
548548

549549
return $this->normalizeRelation($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
@@ -660,7 +660,7 @@ private function createAttributeValue($attribute, $value, $format = null, array
660660
$this->resourceClassResolver->isResourceClass($className)
661661
) {
662662
$resourceClass = $this->resourceClassResolver->getResourceClass(null, $className);
663-
$childContext = $this->createChildContext($context, $attribute);
663+
$childContext = $this->createChildContext($context, $attribute, $format);
664664
$childContext['resource_class'] = $resourceClass;
665665

666666
return $this->denormalizeRelation($attribute, $propertyMetadata, $resourceClass, $value, $format, $childContext);

tests/Fixtures/app/AppKernel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Symfony\Component\DependencyInjection\ContainerBuilder;
3030
use Symfony\Component\HttpKernel\Kernel;
3131
use Symfony\Component\Routing\RouteCollectionBuilder;
32+
use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
3233
use Symfony\Component\Security\Core\User\UserInterface;
3334

3435
/**
@@ -96,10 +97,11 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
9697

9798
$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");
9899

100+
$alg = class_exists(SodiumPasswordEncoder::class) && SodiumPasswordEncoder::isSupported() ? 'auto' : 'bcrypt';
99101
$securityConfig = [
100102
'encoders' => [
101-
User::class => 'bcrypt',
102-
UserDocument::class => 'bcrypt',
103+
User::class => $alg,
104+
UserDocument::class => $alg,
103105
// Don't use plaintext in production!
104106
UserInterface::class => 'plaintext',
105107
],
@@ -128,6 +130,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
128130
'provider' => 'chain_provider',
129131
'http_basic' => null,
130132
'anonymous' => null,
133+
'logout_on_user_change' => true,
131134
],
132135
],
133136
'access_control' => [

0 commit comments

Comments
 (0)