Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f36ec7c

Browse filesBrowse files
Merge branch '5.0' into 5.1
* 5.0: Handle fetch mode deprecation of DBAL 2.11. Fixed handling of CSRF logout error [WebProfilerBundle] changed label of memory usage in time panel (Mb into MiB) [DotEnv][WebLink][Templating][ErrorHandler] Updated README with minimal example
2 parents 64cc68e + da25ef1 commit f36ec7c
Copy full SHA for f36ec7c

File tree

11 files changed

+213
-11
lines changed
Filter options

11 files changed

+213
-11
lines changed

‎src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function loadTokenBySeries(string $series)
6363
$paramValues = ['series' => $series];
6464
$paramTypes = ['series' => \PDO::PARAM_STR];
6565
$stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes);
66-
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
66+
$row = method_exists($stmt, 'fetchAssociative') ? $stmt->fetchAssociative() : $stmt->fetch(\PDO::FETCH_ASSOC);
6767

6868
if ($row) {
6969
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used']));
+88Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace Security\RememberMe;
4+
5+
use Doctrine\DBAL\DriverManager;
6+
use PHPUnit\Framework\TestCase;
7+
use Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider;
8+
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
9+
use Symfony\Component\Security\Core\Exception\TokenNotFoundException;
10+
11+
/**
12+
* @requires extension pdo_sqlite
13+
*/
14+
class DoctrineTokenProviderTest extends TestCase
15+
{
16+
public static function setUpBeforeClass()
17+
{
18+
if (\PHP_VERSION_ID >= 80000) {
19+
self::markTestSkipped('Doctrine DBAL 2.x is incompatible with PHP 8.');
20+
}
21+
}
22+
23+
public function testCreateNewToken()
24+
{
25+
$provider = $this->bootstrapProvider();
26+
27+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
28+
$provider->createNewToken($token);
29+
30+
$this->assertEquals($provider->loadTokenBySeries('someSeries'), $token);
31+
}
32+
33+
public function testLoadTokenBySeriesThrowsNotFoundException()
34+
{
35+
$provider = $this->bootstrapProvider();
36+
37+
$this->expectException(TokenNotFoundException::class);
38+
$provider->loadTokenBySeries('someSeries');
39+
}
40+
41+
public function testUpdateToken()
42+
{
43+
$provider = $this->bootstrapProvider();
44+
45+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
46+
$provider->createNewToken($token);
47+
$provider->updateToken('someSeries', 'newValue', $lastUsed = new \DateTime('2014-06-26T22:03:46'));
48+
$token = $provider->loadTokenBySeries('someSeries');
49+
50+
$this->assertEquals('newValue', $token->getTokenValue());
51+
$this->assertEquals($token->getLastUsed(), $lastUsed);
52+
}
53+
54+
public function testDeleteToken()
55+
{
56+
$provider = $this->bootstrapProvider();
57+
$token = new PersistentToken('someClass', 'someUser', 'someSeries', 'tokenValue', new \DateTime('2013-01-26T18:23:51'));
58+
$provider->createNewToken($token);
59+
$provider->deleteTokenBySeries('someSeries');
60+
61+
$this->expectException(TokenNotFoundException::class);
62+
63+
$provider->loadTokenBySeries('someSeries');
64+
}
65+
66+
/**
67+
* @return DoctrineTokenProvider
68+
*/
69+
private function bootstrapProvider()
70+
{
71+
$connection = DriverManager::getConnection([
72+
'driver' => 'pdo_sqlite',
73+
'url' => 'sqlite:///:memory:',
74+
]);
75+
$connection->executeUpdate(<<< 'SQL'
76+
CREATE TABLE rememberme_token (
77+
series char(88) UNIQUE PRIMARY KEY NOT NULL,
78+
value char(88) NOT NULL,
79+
lastUsed datetime NOT NULL,
80+
class varchar(100) NOT NULL,
81+
username varchar(200) NOT NULL
82+
);
83+
SQL
84+
);
85+
86+
return new DoctrineTokenProvider($connection);
87+
}
88+
}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.js

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class TimelineEngine {
9494

9595
createLabel(name, duration, memory, period) {
9696
const label = this.renderer.createText(name, period.start * this.scale, this.labelY, 'timeline-label');
97-
const sublabel = this.renderer.createTspan(` ${duration} ms / ${memory} Mb`, 'timeline-sublabel');
97+
const sublabel = this.renderer.createTspan(` ${duration} ms / ${memory} MiB`, 'timeline-sublabel');
9898

9999
label.appendChild(sublabel);
100100

‎src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PdoAdapter.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ protected function doFetch(array $ids)
219219
}
220220
$stmt->execute();
221221

222-
while ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
222+
if (method_exists($stmt, 'iterateNumeric')) {
223+
$stmt = $stmt->iterateNumeric();
224+
} else {
225+
$stmt->setFetchMode(\PDO::FETCH_NUM);
226+
}
227+
228+
foreach ($stmt as $row) {
223229
if (null === $row[1]) {
224230
$expired[] = $row[0];
225231
} else {

‎src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ protected function isPruned($cache, string $name): bool
2424
$getPdoConn = $o->getMethod('getConnection');
2525
$getPdoConn->setAccessible(true);
2626

27-
/** @var \Doctrine\DBAL\Statement $select */
27+
/** @var \Doctrine\DBAL\Statement|\PDOStatement $select */
2828
$select = $getPdoConn->invoke($cache)->prepare('SELECT 1 FROM cache_items WHERE item_id LIKE :id');
2929
$select->bindValue(':id', sprintf('%%%s', $name));
3030
$select->execute();
3131

32-
return 0 === \count($select->fetchAll(\PDO::FETCH_COLUMN));
32+
return 1 !== (int) (method_exists($select, 'fetchOne') ? $select->fetchOne() : $select->fetch(\PDO::FETCH_COLUMN));
3333
}
3434
}

‎src/Symfony/Component/Dotenv/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/README.md
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,32 @@ Dotenv Component
44
Symfony Dotenv parses `.env` files to make environment variables stored in them
55
accessible via `$_SERVER` or `$_ENV`.
66

7+
Getting Started
8+
---------------
9+
10+
```
11+
$ composer require symfony/dotenv
12+
```
13+
14+
```php
15+
use Symfony\Component\Dotenv\Dotenv;
16+
17+
$dotenv = new Dotenv();
18+
$dotenv->load(__DIR__.'/.env');
19+
20+
// you can also load several files
21+
$dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev');
22+
23+
// overwrites existing env variables
24+
$dotenv->overload(__DIR__.'/.env');
25+
26+
// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
27+
$dotenv->loadEnv(__DIR__.'/.env');
28+
```
29+
730
Resources
831
---------
932

10-
* [Documentation](https://symfony.com/doc/current/components/dotenv.html)
1133
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
1234
* [Report issues](https://github.com/symfony/symfony/issues) and
1335
[send Pull Requests](https://github.com/symfony/symfony/pulls)

‎src/Symfony/Component/ErrorHandler/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/README.md
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ ErrorHandler Component
33

44
The ErrorHandler component provides tools to manage errors and ease debugging PHP code.
55

6+
Getting Started
7+
---------------
8+
9+
```
10+
$ composer require symfony/error-handler
11+
```
12+
13+
```php
14+
use Symfony\Component\ErrorHandler\Debug;
15+
use Symfony\Component\ErrorHandler\ErrorHandler;
16+
use Symfony\Component\ErrorHandler\DebugClassLoader;
17+
18+
Debug::enable();
19+
20+
// or enable only one feature
21+
//ErrorHandler::register();
22+
//DebugClassLoader::enable();
23+
24+
$data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) {
25+
// if any code executed inside this anonymous function fails, a PHP exception
26+
// will be thrown, even if the code uses the '@' PHP silence operator
27+
$data = json_decode(file_get_contents($filename), true);
28+
$data['read_at'] = date($datetimeFormat);
29+
file_put_contents($filename, json_encode($data));
30+
31+
return $data;
32+
});
33+
```
34+
635
Resources
736
---------
837

‎src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function onKernelException(ExceptionEvent $event)
111111
}
112112

113113
if ($exception instanceof LogoutException) {
114-
$this->handleLogoutException($exception);
114+
$this->handleLogoutException($event, $exception);
115115

116116
return;
117117
}
@@ -183,10 +183,12 @@ private function handleAccessDeniedException(ExceptionEvent $event, AccessDenied
183183
}
184184
}
185185

186-
private function handleLogoutException(LogoutException $exception): void
186+
private function handleLogoutException(ExceptionEvent $event, LogoutException $exception): void
187187
{
188+
$event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
189+
188190
if (null !== $this->logger) {
189-
$this->logger->info('A LogoutException was thrown.', ['exception' => $exception]);
191+
$this->logger->info('A LogoutException was thrown; wrapping with AccessDeniedHttpException', ['exception' => $exception]);
190192
}
191193
}
192194

‎src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2222
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
2323
use Symfony\Component\Security\Core\Exception\AuthenticationException;
24+
use Symfony\Component\Security\Core\Exception\LogoutException;
2425
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
2526
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
2627
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
@@ -157,6 +158,17 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \
157158
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious());
158159
}
159160

161+
public function testLogoutException()
162+
{
163+
$event = $this->createEvent(new LogoutException('Invalid CSRF.'));
164+
165+
$listener = $this->createExceptionListener();
166+
$listener->onKernelException($event);
167+
168+
$this->assertEquals('Invalid CSRF.', $event->getException()->getMessage());
169+
$this->assertEquals(403, $event->getException()->getStatusCode());
170+
}
171+
160172
public function getAccessDeniedExceptionProvider()
161173
{
162174
return [

‎src/Symfony/Component/Templating/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Templating/README.md
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,33 @@ for changes. It also provides a concrete template engine implementation using
99
PHP with additional tools for escaping and separating templates into blocks and
1010
layouts.
1111

12+
Getting Started
13+
---------------
14+
15+
```
16+
$ composer require symfony/templating
17+
```
18+
19+
```php
20+
use Symfony\Component\Templating\Loader\FilesystemLoader;
21+
use Symfony\Component\Templating\PhpEngine;
22+
use Symfony\Component\Templating\Helper\SlotsHelper;
23+
use Symfony\Component\Templating\TemplateNameParser;
24+
25+
$filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
26+
27+
$templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
28+
$templating->set(new SlotsHelper());
29+
30+
echo $templating->render('hello.php', ['firstname' => 'Fabien']);
31+
32+
// hello.php
33+
Hello, <?= $view->escape($firstname) ?>!
34+
```
35+
1236
Resources
1337
---------
1438

15-
* [Documentation](https://symfony.com/doc/current/components/templating.html)
1639
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
1740
* [Report issues](https://github.com/symfony/symfony/issues) and
1841
[send Pull Requests](https://github.com/symfony/symfony/pulls)

‎src/Symfony/Component/WebLink/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/WebLink/README.md
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,30 @@ This component implements the [HTML5's Links](https://www.w3.org/TR/html5/links.
88
and [Resource Hints](https://www.w3.org/TR/resource-hints/) W3C's specifications.
99
It can also be used with extensions defined in the [HTML5 link type extensions wiki](http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions).
1010

11+
Getting Started
12+
---------------
13+
14+
```
15+
$ composer require symfony/web-link
16+
```
17+
18+
```php
19+
use Symfony\Component\WebLink\GenericLinkProvider;
20+
use Symfony\Component\WebLink\HttpHeaderSerializer;
21+
use Symfony\Component\WebLink\Link;
22+
23+
$linkProvider = (new GenericLinkProvider())
24+
->withLink(new Link('preload', '/bootstrap.min.css'));
25+
26+
header('Link: '.(new HttpHeaderSerializer())->serialize($linkProvider->getLinks()));
27+
28+
echo 'Hello';
29+
```
30+
1131
Resources
1232
---------
1333

14-
* [Documentation](https://symfony.com/doc/current/components/web_link.html)
34+
* [Documentation](https://symfony.com/doc/current/web_link.html)
1535
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
1636
* [Report issues](https://github.com/symfony/symfony/issues) and
1737
[send Pull Requests](https://github.com/symfony/symfony/pulls)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.