Skip to content

Commit fbc9c21

Browse files
[Cache] Fix Couchbase password parsing
1 parent 5f942a9 commit fbc9c21

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

.github/workflows/integration-tests.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,16 @@ jobs:
132132
133133
- name: Configure Couchbase
134134
run: |
135-
curl -s -u 'username=Administrator&password=111111' -X POST http://localhost:8091/node/controller/setupServices -d 'services=kv%2Cn1ql%2Cindex%2Cfts'
136-
curl -s -X POST http://localhost:8091/settings/web -d 'username=Administrator&password=111111&port=SAME'
137-
curl -s -u Administrator:111111 -X POST http://localhost:8091/pools/default/buckets -d 'ramQuotaMB=100&bucketType=ephemeral&name=cache'
138-
curl -s -u Administrator:111111 -X POST http://localhost:8091/pools/default -d 'memoryQuota=256'
135+
curl -s -u 'username=Administrator&password=111111@' -X POST http://localhost:8091/node/controller/setupServices -d 'services=kv%2Cn1ql%2Cindex%2Cfts'
136+
curl -s -X POST http://localhost:8091/settings/web -d 'username=Administrator&password=111111%40&port=SAME'
137+
curl -s -u Administrator:111111@ -X POST http://localhost:8091/pools/default/buckets -d 'ramQuotaMB=100&bucketType=ephemeral&name=cache'
138+
curl -s -u Administrator:111111@ -X POST http://localhost:8091/pools/default -d 'memoryQuota=256'
139139
140140
- name: Setup PHP
141141
uses: shivammathur/setup-php@v2
142142
with:
143143
coverage: "none"
144-
extensions: "json,couchbase-3.2.2,memcached,mongodb-1.10.0,redis-5.3.4,rdkafka,xsl,ldap"
144+
extensions: "json,couchbase-3.0.4,memcached,mongodb-1.10.0,redis-5.3.4,rdkafka,xsl,ldap"
145145
ini-values: date.timezone=UTC,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1
146146
php-version: "${{ matrix.php }}"
147147
tools: pecl

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<env name="ZOOKEEPER_HOST" value="localhost" />
2626
<env name="COUCHBASE_HOST" value="localhost" />
2727
<env name="COUCHBASE_USER" value="Administrator" />
28-
<env name="COUCHBASE_PASS" value="111111" />
28+
<env name="COUCHBASE_PASS" value="111111%40" />
2929
</php>
3030

3131
<testsuites>

src/Symfony/Component/Cache/Adapter/CouchbaseCollectionAdapter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static function createConnection($dsn, array $options = [])
8585
preg_match($dsnPattern, $server, $matches);
8686

8787
$username = $matches['username'] ?: $username;
88-
$password = $matches['password'] ?: $password;
88+
$password = rawurldecode($matches['password'] ?: $password);
8989
$protocol = $matches['protocol'] ?: $protocol;
9090

9191
if (isset($matches['options'])) {
@@ -122,7 +122,7 @@ public static function createConnection($dsn, array $options = [])
122122

123123
public static function isSupported(): bool
124124
{
125-
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '3.0.5', '>=') && version_compare(phpversion('couchbase'), '4.0', '<');
125+
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '3.0.4', '>=') && version_compare(phpversion('couchbase'), '4.0', '<');
126126
}
127127

128128
private static function getOptions(string $options): array

src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,20 @@ public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
6363

6464
return new CouchbaseCollectionAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
6565
}
66+
67+
public function testExpiration()
68+
{
69+
$cache = $this->createCachePool();
70+
$cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2 * 1000));
71+
$cache->save($cache->getItem('k2')->set('v2')->expiresAfter(366 * 86400 * 1000));
72+
73+
sleep(3);
74+
$item = $cache->getItem('k1');
75+
$this->assertFalse($item->isHit());
76+
$this->assertNull($item->get(), "Item's value must be null when isHit() is false.");
77+
78+
$item = $cache->getItem('k2');
79+
$this->assertTrue($item->isHit());
80+
$this->assertSame('v2', $item->get());
81+
}
6682
}

src/Symfony/Component/Cache/phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<env name="MEMCACHED_HOST" value="localhost" />
1616
<env name="COUCHBASE_HOST" value="localhost" />
1717
<env name="COUCHBASE_USER" value="Administrator" />
18-
<env name="COUCHBASE_PASS" value="111111" />
18+
<env name="COUCHBASE_PASS" value="111111%40" />
1919
</php>
2020

2121
<testsuites>

0 commit comments

Comments
 (0)