Skip to content

Commit 6e27e78

Browse files
committed
Merge remote-tracking branch 'origin/3.4' into 4.0
* origin/3.4: (22 commits) event constant mistake Updated the default values of some Cache config options Update simple-example.rst to use const for jQuery Update shared-entry.rst to use Bootstrap 4's SCSS Removed an extra blank line Reword and added a note Link to proxy configuration docs from the routing scheme page Fixed typos Fixed security expression testing user Use matching closing tag Better explain render() and render_esi() functions Updated the embed controllers article updating the guard session migration details for Symfony 3.4 changes Avoiding authentication on every request with Guard [Filesystem] Improved the code of an example Removed another usage of mt_rand() Transition from mt_rand to random_int Mentioned Debian explicitly remove not existent label_attr options from buttons Fixed some code indentation ...
2 parents 31791c9 + 7ac5f7b commit 6e27e78

23 files changed

+367
-111
lines changed

components/cache/adapters/chain_adapter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ slowest storage engines, :class:`Symfony\\Component\\Cache\\Adapter\\ApcuAdapter
4646
));
4747

4848
When calling this adapter's :method:`Symfony\\Component\\Cache\\ChainAdapter::prune` method,
49-
the call is deligated to all its compatibe cache adapters. It is safe to mix both adapters
49+
the call is delegated to all its compatible cache adapters. It is safe to mix both adapters
5050
that *do* and do *not* implement :class:`Symfony\\Component\\Cache\\PruneableInterface`, as
5151
incompatible adapters are silently ignored::
5252

components/cache/cache_pools.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ Pruning Cache Items
146146
-------------------
147147

148148
Some cache pools do not include an automated mechanism for pruning expired cache items.
149-
For example, the :ref:`FilesystemAdaper <component-cache-filesystem-adapter>` cache
149+
For example, the :ref:`FilesystemAdapter <component-cache-filesystem-adapter>` cache
150150
does not remove expired cache items *until an item is explicitly requested and determined to
151151
be expired*, for example, via a call to ``Psr\\Cache\\CacheItemPoolInterface::getItem``.
152152
Under certain workloads, this can cause stale cache entries to persist well past their
153153
expiration, resulting in a sizable consumption of wasted disk or memory space from excess,
154154
expired cache items.
155155

156-
This shortcomming has been solved through the introduction of
156+
This shortcoming has been solved through the introduction of
157157
:class:`Symfony\\Component\\Cache\\PruneableInterface`, which defines the abstract method
158158
:method:`Symfony\\Component\\Cache\\PruneableInterface::prune`. The
159159
:ref:`ChainAdapter <component-cache-chain-adapter>`,
160-
:ref:`FilesystemAdaper <component-cache-filesystem-adapter>`,
160+
:ref:`FilesystemAdapter <component-cache-filesystem-adapter>`,
161161
:ref:`PdoAdapter <pdo-doctrine-adapter>`, and
162162
:ref:`PhpFilesAdapter <component-cache-files-adapter>` all implement this new interface,
163163
allowing manual removal of stale cache items::
@@ -171,7 +171,7 @@ allowing manual removal of stale cache items::
171171
The :ref:`ChainAdapter <component-cache-chain-adapter>` implementation does not directly
172172
contain any pruning logic itself. Instead, when calling the chain adapter's
173173
:method:`Symfony\\Component\\Cache\\ChainAdapter::prune` method, the call is delegated to all
174-
its compatibe cache adapters (and those that do not implement ``PruneableInterface`` are
174+
its compatible cache adapters (and those that do not implement ``PruneableInterface`` are
175175
silently ignored)::
176176

177177
use Symfony\Component\Cache\Adapter\ApcuAdapter;

components/console/events.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Listeners receive a
149149
.. tip::
150150

151151
This event is also dispatched when an exception is thrown by the command.
152-
It is then dispatched just after the ``ConsoleEvents::EXCEPTION`` event.
152+
It is then dispatched just after the ``ConsoleEvents::ERROR`` event.
153153
The exit code received in this case is the exception code.
154154

155155
.. _`reserved exit codes`: http://www.tldp.org/LDP/abs/html/exitcodes.html

components/filesystem.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endpoint for filesystem operations::
2929
$fileSystem = new Filesystem();
3030

3131
try {
32-
$fileSystem->mkdir('/tmp/random/dir/'.mt_rand());
32+
$fileSystem->mkdir(sys_get_temp_dir().'/'.random_int(0, 1000));
3333
} catch (IOExceptionInterface $exception) {
3434
echo "An error occurred while creating your directory at ".$exception->getPath();
3535
}

components/http_foundation/session_configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ the ``php.ini`` directive ``session.gc_maxlifetime``. The meaning in this contex
138138
that any stored session that was saved more than ``gc_maxlifetime`` ago should be
139139
deleted. This allows one to expire records based on idle time.
140140

141-
However, some operating systems do their own session handling and set the
142-
``session.gc_probability`` variable to ``0`` to stop PHP doing garbage
141+
However, some operating systems (e.g. Debian) do their own session handling and set
142+
the ``session.gc_probability`` variable to ``0`` to stop PHP doing garbage
143143
collection. That's why Symfony now overwrites this value to ``1``.
144144

145145
If you wish to use the original value set in your ``php.ini``, add the following

configuration/external_parameters.rst

Lines changed: 222 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Environment Variable Processors
140140
.. versionadded:: 3.4
141141
Environment variable processors were introduced in Symfony 3.4.
142142

143-
The values of the environment variables are considered strings by default.
143+
The values of environment variables are considered strings by default.
144144
However, your code may expect other data types, like integers or booleans.
145145
Symfony solves this problem with *processors*, which modify the contents of the
146146
given environment variables. The following example uses the integer processor to
@@ -159,7 +159,6 @@ turn the value of the ``HTTP_PORT`` env var into an integer:
159159
160160
<!-- config/packages/framework.xml -->
161161
<?xml version="1.0" encoding="UTF-8" ?>
162-
163162
<container xmlns="http://symfony.com/schema/dic/services"
164163
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
165164
xmlns:framework="http://symfony.com/schema/dic/symfony"
@@ -169,57 +168,152 @@ turn the value of the ``HTTP_PORT`` env var into an integer:
169168
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
170169
171170
<framework:config>
172-
<framework:router http_port="%env(int:HTTP_PORT)%" />
171+
<framework:router http-port="%env(int:HTTP_PORT)%" />
173172
</framework:config>
174173
</container>
175174
176175
.. code-block:: php
177176
178-
// config/packages/doctrine.php
177+
// config/packages/framework.php
179178
$container->loadFromExtension('framework', array(
180179
'router' => array(
181180
'http_port' => '%env(int:HTTP_PORT)%',
182-
)
181+
),
183182
));
184183
185184
Symfony provides the following env var processors:
186185

187186
``env(string:FOO)``
188187
Casts ``FOO`` to a string:
189188

190-
.. code-block:: yaml
189+
.. configuration-block::
191190

192-
parameters:
193-
env(SECRET): "some_secret"
194-
framework:
195-
secret: '%env(string:SECRET)%'
191+
.. code-block:: yaml
192+
193+
# config/packages/framework.yaml
194+
parameters:
195+
env(SECRET): 'some_secret'
196+
framework:
197+
secret: '%env(string:SECRET)%'
198+
199+
.. code-block:: xml
200+
201+
<!-- config/packages/framework.xml -->
202+
<?xml version="1.0" encoding="UTF-8" ?>
203+
<container xmlns="http://symfony.com/schema/dic/services"
204+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205+
xmlns:framework="http://symfony.com/schema/dic/symfony"
206+
xsi:schemaLocation="http://symfony.com/schema/dic/services
207+
http://symfony.com/schema/dic/services/services-1.0.xsd
208+
http://symfony.com/schema/dic/symfony
209+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
210+
211+
<parameters>
212+
<parameter key="env(SECRET)">some_secret</parameter>
213+
</parameters>
214+
215+
<framework:config secret="%env(string:SECRET)%" />
216+
</container>
217+
218+
.. code-block:: php
219+
220+
// config/packages/framework.php
221+
$container->setParameter('env(SECRET)', 'some_secret');
222+
$container->loadFromExtension('framework', array(
223+
'secret' => '%env(string:SECRET)%',
224+
));
196225
197226
``env(bool:FOO)``
198227
Casts ``FOO`` to a bool:
199228

200-
.. code-block:: yaml
229+
.. configuration-block::
201230

202-
parameters:
203-
env(HTTP_METHOD_OVERRIDE): "true"
204-
framework:
205-
http_method_override: '%env(bool:HTTP_METHOD_OVERRIDE)%'
231+
.. code-block:: yaml
232+
233+
# config/packages/framework.yaml
234+
parameters:
235+
env(HTTP_METHOD_OVERRIDE): 'true'
236+
framework:
237+
http_method_override: '%env(bool:HTTP_METHOD_OVERRIDE)%'
238+
239+
.. code-block:: xml
240+
241+
<!-- config/packages/framework.xml -->
242+
<?xml version="1.0" encoding="UTF-8" ?>
243+
<container xmlns="http://symfony.com/schema/dic/services"
244+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
245+
xmlns:framework="http://symfony.com/schema/dic/symfony"
246+
xsi:schemaLocation="http://symfony.com/schema/dic/services
247+
http://symfony.com/schema/dic/services/services-1.0.xsd
248+
http://symfony.com/schema/dic/symfony
249+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
250+
251+
<parameters>
252+
<parameter key="env(HTTP_METHOD_OVERRIDE)">true</parameter>
253+
</parameters>
254+
255+
<framework:config http-methode-override="%env(bool:HTTP_METHOD_OVERRIDE)%" />
256+
</container>
257+
258+
.. code-block:: php
259+
260+
// config/packages/framework.php
261+
$container->setParameter('env(HTTP_METHOD_OVERRIDE)', 'true');
262+
$container->loadFromExtension('framework', array(
263+
'http_method_override' => '%env(bool:HTTP_METHOD_OVERRIDE)%',
264+
));
206265
207266
``env(int:FOO)``
208267
Casts ``FOO`` to an int.
209268

210269
``env(float:FOO)``
211-
Casts ``FOO`` to an float.
270+
Casts ``FOO`` to a float.
212271

213272
``env(const:FOO)``
214273
Finds the const value named in ``FOO``:
215274

216-
.. code-block:: yaml
217-
218-
parameters:
219-
env(HEALTH_CHECK_METHOD): "Symfony\Component\HttpFoundation\Request:METHOD_HEAD"
220-
security:
221-
access_control:
222-
- { path: '^/health-check$', methods: '%env(const:HEALTH_CHECK_METHOD)%' }
275+
.. configuration-block::
276+
277+
.. code-block:: yaml
278+
279+
# config/packages/security.yaml
280+
parameters:
281+
env(HEALTH_CHECK_METHOD): 'Symfony\Component\HttpFoundation\Request::METHOD_HEAD'
282+
security:
283+
access_control:
284+
- { path: '^/health-check$', methods: '%env(const:HEALTH_CHECK_METHOD)%' }
285+
286+
.. code-block:: xml
287+
288+
<!-- config/packages/security.xml -->
289+
<?xml version="1.0" encoding="UTF-8" ?>
290+
<container xmlns="http://symfony.com/schema/dic/services"
291+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
292+
xmlns:security="http://symfony.com/schema/dic/security"
293+
xsi:schemaLocation="http://symfony.com/schema/dic/services
294+
http://symfony.com/schema/dic/services/services-1.0.xsd">
295+
296+
<parameters>
297+
<parameter key="env(HEALTH_CHECK_METHOD)">Symfony\Component\HttpFoundation\Request::METHOD_HEAD</parameter>
298+
</parameters>
299+
300+
<security:config>
301+
<rule path="^/health-check$" methods="%env(const:HEALTH_CHECK_METHOD)%" />
302+
</security:config>
303+
</container>
304+
305+
.. code-block:: php
306+
307+
// config/packages/security.php
308+
$container->setParameter('env(HEALTH_CHECK_METHOD)', 'Symfony\Component\HttpFoundation\Request::METHOD_HEAD');
309+
$container->loadFromExtension('security', array(
310+
'access_control' => array(
311+
array(
312+
'path' => '^/health-check$',
313+
'methods' => '%env(const:HEALTH_CHECK_METHOD)%',
314+
),
315+
),
316+
));
223317
224318
``env(base64:FOO)``
225319
Decodes the content of ``FOO``, which is a base64 encoded string.
@@ -228,34 +322,123 @@ Symfony provides the following env var processors:
228322
Decodes the content of ``FOO``, which is a JSON encoded string. It returns
229323
either an array or ``null``:
230324

231-
.. code-block:: yaml
325+
.. configuration-block::
232326

233-
parameters:
234-
env(TRUSTED_HOSTS): "['10.0.0.1', '10.0.0.2']"
235-
framework:
236-
trusted_hosts: '%env(json:TRUSTED_HOSTS)%'
327+
.. code-block:: yaml
328+
329+
# config/packages/framework.yaml
330+
parameters:
331+
env(TRUSTED_HOSTS): '["10.0.0.1", "10.0.0.2"]'
332+
framework:
333+
trusted_hosts: '%env(json:TRUSTED_HOSTS)%'
334+
335+
.. code-block:: xml
336+
337+
<!-- config/packages/framework.xml -->
338+
<?xml version="1.0" encoding="UTF-8" ?>
339+
<container xmlns="http://symfony.com/schema/dic/services"
340+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
341+
xmlns:framework="http://symfony.com/schema/dic/symfony"
342+
xsi:schemaLocation="http://symfony.com/schema/dic/services
343+
http://symfony.com/schema/dic/services/services-1.0.xsd
344+
http://symfony.com/schema/dic/symfony
345+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
346+
347+
<parameters>
348+
<parameter key="env(TRUSTED_HOSTS)">["10.0.0.1", "10.0.0.2"]</parameter>
349+
</parameters>
350+
351+
<framework:config trusted-hosts="%env(json:TRUSTED_HOSTS)%" />
352+
</container>
353+
354+
.. code-block:: php
355+
356+
// config/packages/framework.php
357+
$container->setParameter('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]');
358+
$container->loadFromExtension('framework', array(
359+
'trusted_hosts' => '%env(json:TRUSTED_HOSTS)%',
360+
));
237361
238362
``env(resolve:FOO)``
239363
Replaces the string ``FOO`` by the value of a config parameter with the
240364
same name:
241365

242-
.. code-block:: yaml
366+
.. configuration-block::
243367

244-
parameters:
245-
env(HOST): '10.0.0.1'
246-
env(SENTRY_DSN): "http://%env(HOST)%/project"
247-
sentry:
248-
dsn: '%env(resolve:SENTRY_DSN)%'
368+
.. code-block:: yaml
369+
370+
# config/packages/sentry.yaml
371+
parameters:
372+
env(HOST): '10.0.0.1'
373+
env(SENTRY_DSN): 'http://%env(HOST)%/project'
374+
sentry:
375+
dsn: '%env(resolve:SENTRY_DSN)%'
376+
377+
.. code-block:: xml
378+
379+
<!-- config/packages/sentry.xml -->
380+
<?xml version="1.0" encoding="UTF-8" ?>
381+
<container xmlns="http://symfony.com/schema/dic/services"
382+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
383+
xsi:schemaLocation="http://symfony.com/schema/dic/services
384+
http://symfony.com/schema/dic/services/services-1.0.xsd">
385+
386+
<parameters>
387+
<parameter key="env(HOST)">10.0.0.1</parameter>
388+
<parameter key="env(SENTRY_DSN)">http://%env(HOST)%/project</parameter>
389+
</parameters>
390+
391+
<sentry:config dsn="%env(resolve:SENTRY_DSN)%" />
392+
</container>
393+
394+
.. code-block:: php
395+
396+
// config/packages/sentry.php
397+
$container->setParameter('env(HOST)', '10.0.0.1');
398+
$container->setParameter('env(SENTRY_DSN)', 'http://%env(HOST)%/project');
399+
$container->loadFromExtension('sentry', array(
400+
'dsn' => '%env(resolve:SENTRY_DSN)%',
401+
));
249402
250403
``env(file:FOO)``
251404
Returns the contents of a file whose path is the value of the ``FOO`` env var:
252405

253-
.. code-block:: yaml
406+
.. configuration-block::
254407

255-
parameters:
256-
env(AUTH_FILE): "../config/auth.json"
257-
google:
258-
auth: '%env(file:AUTH_FILE)%'
408+
.. code-block:: yaml
409+
410+
# config/packages/framework.yaml
411+
parameters:
412+
env(AUTH_FILE): '../config/auth.json'
413+
google:
414+
auth: '%env(file:AUTH_FILE)%'
415+
416+
.. code-block:: xml
417+
418+
<!-- config/packages/framework.xml -->
419+
<?xml version="1.0" encoding="UTF-8" ?>
420+
<container xmlns="http://symfony.com/schema/dic/services"
421+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
422+
xmlns:framework="http://symfony.com/schema/dic/symfony"
423+
xsi:schemaLocation="http://symfony.com/schema/dic/services
424+
http://symfony.com/schema/dic/services/services-1.0.xsd
425+
http://symfony.com/schema/dic/symfony
426+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
427+
428+
<parameters>
429+
<parameter key="env(AUTH_FILE)">../config/auth.json</parameter>
430+
</parameters>
431+
432+
<google auth="%env(file:AUTH_FILE)%" />
433+
</container>
434+
435+
.. code-block:: php
436+
437+
// config/packages/framework.php
438+
$container->setParameter('env(AUTH_FILE)', '../config/auth.json');
439+
$container->loadFromExtension('google', array(
440+
'auth' => '%env(file:AUTH_FILE)%',
441+
));
259442
260443
It is also possible to combine any number of processors:
261444

0 commit comments

Comments
 (0)