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 9c2a9c8

Browse filesBrowse files
committed
Merge branch '4.4' into 5.3
* 4.4: [LDAP] Fix resource type checks & docblocks on PHP 8.1 Fix Redis replication on Redis <5
2 parents b5cdb1c + 5c5fd0c commit 9c2a9c8
Copy full SHA for 9c2a9c8

File tree

3 files changed

+37
-15
lines changed
Filter options

3 files changed

+37
-15
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php
+23-2Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Predis\Connection\Aggregate\PredisCluster;
1616
use Predis\Connection\Aggregate\ReplicationInterface;
1717
use Predis\Response\Status;
18+
use Symfony\Component\Cache\CacheItem;
1819
use Symfony\Component\Cache\Exception\InvalidArgumentException;
1920
use Symfony\Component\Cache\Exception\LogicException;
2021
use Symfony\Component\Cache\Marshaller\DeflateMarshaller;
@@ -163,6 +164,12 @@ protected function doDeleteYieldTags(array $ids): iterable
163164
});
164165

165166
foreach ($results as $id => $result) {
167+
if ($result instanceof \RedisException) {
168+
CacheItem::log($this->logger, 'Failed to delete key "{key}": '.$result->getMessage(), ['key' => substr($id, \strlen($this->namespace)), 'exception' => $result]);
169+
170+
continue;
171+
}
172+
166173
try {
167174
yield $id => !\is_string($result) || '' === $result ? [] : $this->marshaller->unmarshall($result);
168175
} catch (\Exception $e) {
@@ -201,6 +208,8 @@ protected function doInvalidate(array $tagIds): bool
201208
// gargage collect that set from the client side.
202209

203210
$lua = <<<'EOLUA'
211+
redis.replicate_commands()
212+
204213
local cursor = '0'
205214
local id = KEYS[1]
206215
repeat
@@ -238,14 +247,26 @@ protected function doInvalidate(array $tagIds): bool
238247
});
239248

240249
$lua = <<<'EOLUA'
250+
redis.replicate_commands()
251+
241252
local id = KEYS[1]
242253
local cursor = table.remove(ARGV)
243254
redis.call('SREM', '{'..id..'}'..id, unpack(ARGV))
244255
245256
return redis.call('SSCAN', '{'..id..'}'..id, cursor, 'COUNT', 5000)
246257
EOLUA;
247258

248-
foreach ($results as $id => [$cursor, $ids]) {
259+
$success = true;
260+
foreach ($results as $id => $values) {
261+
if ($values instanceof \RedisException) {
262+
CacheItem::log($this->logger, 'Failed to invalidate key "{key}": '.$values->getMessage(), ['key' => substr($id, \strlen($this->namespace)), 'exception' => $values]);
263+
$success = false;
264+
265+
continue;
266+
}
267+
268+
[$cursor, $ids] = $values;
269+
249270
while ($ids || '0' !== $cursor) {
250271
$this->doDelete($ids);
251272

@@ -268,7 +289,7 @@ protected function doInvalidate(array $tagIds): bool
268289
}
269290
}
270291

271-
return true;
292+
return $success;
272293
}
273294

274295
private function getRedisEvictionPolicy(): string

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Ldap\Adapter\ExtLdap;
1313

14+
use LDAP\Connection as LDAPConnection;
1415
use Symfony\Component\Ldap\Adapter\AbstractConnection;
1516
use Symfony\Component\Ldap\Exception\AlreadyExistsException;
1617
use Symfony\Component\Ldap\Exception\ConnectionException;
@@ -32,7 +33,7 @@ class Connection extends AbstractConnection
3233
/** @var bool */
3334
private $bound = false;
3435

35-
/** @var resource */
36+
/** @var resource|LDAPConnection */
3637
private $connection;
3738

3839
/**
@@ -89,9 +90,7 @@ public function bind(string $dn = null, string $password = null)
8990
}
9091

9192
/**
92-
* Returns a link resource.
93-
*
94-
* @return resource
93+
* @return resource|LDAPConnection
9594
*
9695
* @internal
9796
*/
@@ -165,7 +164,7 @@ private function connect()
165164

166165
private function disconnect()
167166
{
168-
if ($this->connection && \is_resource($this->connection)) {
167+
if ($this->connection) {
169168
ldap_unbind($this->connection);
170169
}
171170

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Ldap\Adapter\ExtLdap;
1313

14+
use LDAP\Connection as LDAPConnection;
15+
use LDAP\Result;
1416
use Symfony\Component\Ldap\Adapter\AbstractQuery;
1517
use Symfony\Component\Ldap\Exception\LdapException;
1618
use Symfony\Component\Ldap\Exception\NotBoundException;
@@ -27,7 +29,7 @@ class Query extends AbstractQuery
2729
/** @var Connection */
2830
protected $connection;
2931

30-
/** @var resource[] */
32+
/** @var resource[]|Result[] */
3133
private $results;
3234

3335
/** @var array */
@@ -156,7 +158,7 @@ public function execute()
156158
* Returns an LDAP search resource. If this query resulted in multiple searches, only the first
157159
* page will be returned.
158160
*
159-
* @return resource
161+
* @return resource|Result
160162
*
161163
* @internal
162164
*/
@@ -172,7 +174,7 @@ public function getResource(int $idx = 0)
172174
/**
173175
* Returns all LDAP search resources.
174176
*
175-
* @return resource[]
177+
* @return resource[]|Result[]
176178
*
177179
* @internal
178180
*/
@@ -215,7 +217,7 @@ private function resetPagination()
215217
/**
216218
* Sets LDAP pagination controls.
217219
*
218-
* @param resource $con
220+
* @param resource|LDAPConnection $con
219221
*/
220222
private function controlPagedResult($con, int $pageSize, bool $critical, string $cookie): bool
221223
{
@@ -239,8 +241,8 @@ private function controlPagedResult($con, int $pageSize, bool $critical, string
239241
/**
240242
* Retrieve LDAP pagination cookie.
241243
*
242-
* @param resource $con
243-
* @param resource $result
244+
* @param resource|LDAPConnection $con
245+
* @param resource|Result $result
244246
*/
245247
private function controlPagedResultResponse($con, $result, string $cookie = ''): string
246248
{
@@ -257,9 +259,9 @@ private function controlPagedResultResponse($con, $result, string $cookie = ''):
257259
/**
258260
* Calls actual LDAP search function with the prepared options and parameters.
259261
*
260-
* @param resource $con
262+
* @param resource|LDAPConnection $con
261263
*
262-
* @return resource
264+
* @return resource|Result
263265
*/
264266
private function callSearchFunction($con, string $func, int $sizeLimit)
265267
{

0 commit comments

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