Skip to content

[FrameworkBundle][Validator] Fix apc cache service deprecation #16822

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

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions UPGRADE-2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,28 @@ FrameworkBundle
cookie_httponly: false
```

* The `validator.mapping.cache.apc` service is deprecated, and will be removed in 3.0.
Use `validator.mapping.cache.doctrine.apc` instead.

* The ability to pass `apc` as the `framework.validation.cache` configuration key value is deprecated,
and will be removed in 3.0. Use `validator.mapping.cache.doctrine.apc` instead:

Before:

```yaml
framework:
validation:
cache: apc
```

After:

```yaml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
```

Security
--------

Expand Down
21 changes: 21 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,27 @@ UPGRADE FROM 2.x to 3.0
interface.
The `security.csrf.token_manager` should be used instead.

* The `validator.mapping.cache.apc` service has been removed in favor of the `validator.mapping.cache.doctrine.apc` one.

* The ability to pass `apc` as the `framework.validation.cache` configuration key value has been removed.
Use `validator.mapping.cache.doctrine.apc` instead:

Before:

```yaml
framework:
validation:
cache: apc
```

After:

```yaml
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
Copy link
Contributor

Choose a reason for hiding this comment

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

please update this to not use this one but instead define the apc cache yourself in the config. so basically validator.mapping.cache.doctrine.apc but defined by the user.

Copy link
Contributor

Choose a reason for hiding this comment

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

same in upgrade-2.8

```

### HttpKernel

* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,15 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->scalarNode('cache')
->beforeNormalization()
// Can be removed in 3.0, once ApcCache support is dropped
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; })
->ifString()->then(function ($v) {
if ('apc' === $v) {
@trigger_error('The ability to pass "apc" as the framework.validation.cache configuration key value is deprecated since version 2.8 and will be removed in 3.0. Use the "validator.mapping.cache.doctrine.apc" service id instead.', E_USER_DEPRECATED);

return 'validator.mapping.cache.apc';
}

return $v;
})
->end()
->end()
->booleanNode('enable_annotations')->defaultFalse()->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

<service id="validator.mapping.cache.apc" class="%validator.mapping.cache.apc.class%" public="false">
<argument>%validator.mapping.cache.prefix%</argument>
<deprecated>The "%service_id%" service is deprecated since Symfony 2.5 and will be removed in 3.0.</deprecated>
</service>

<service id="validator.mapping.cache.doctrine.apc" class="Symfony\Component\Validator\Mapping\Cache\DoctrineCache" public="false">
Expand All @@ -47,7 +48,6 @@
</call>
</service>
</argument>
Copy link
Contributor

Choose a reason for hiding this comment

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

Even if this was unintentionally deprecated. I'd like to keep it that way, so it can stay removed in 3.0. I'm repeating myself, it doesn't make sense to only define the apc one but none else. This is only because of legacy reasons when APC was allaround and the defacto standard. But today apc is the least common cache I would say.

Copy link
Member

Choose a reason for hiding this comment

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

We can't remove it in 3.0 now, so let's revisit this later in 3.0 (see if we want to deprecate it there).

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, this is not in 3.0 - my mistake. But for the purposes of getting this merged in a timely manner, I still think it's best to add it back and then decide to deprecate it in 3.0 (for 4.0 removal) - i.e. keep the PR as it's written.

<deprecated>The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0.</deprecated>
</service>

<service id="validator.validator_factory" class="%validator.validator_factory.class%" public="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
),
'validation' => array(
'enabled' => true,
'cache' => 'apc',
'cache' => 'validator.mapping.cache.doctrine.apc',
),
'annotations' => array(
'cache' => 'file',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<framework:translator enabled="true" fallback="fr" logging="true">
<framework:path>%kernel.root_dir%/Fixtures/translations</framework:path>
</framework:translator>
<framework:validation enabled="true" cache="apc" />
<framework:validation enabled="true" cache="validator.mapping.cache.doctrine.apc" />
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
<framework:serializer enabled="true" enable-annotations="true" cache="serializer.mapping.cache.apc" name-converter="serializer.name_converter.camel_case_to_snake_case" />
</framework:config>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ framework:
paths: ['%kernel.root_dir%/Fixtures/translations']
validation:
enabled: true
cache: apc
cache: validator.mapping.cache.doctrine.apc
annotations:
cache: file
debug: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function testValidation()
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setMetadataCache', $calls[5][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertEquals(array(new Reference('validator.mapping.cache.doctrine.apc')), $calls[5][1]);
}

/**
Expand Down