Skip to content

Commit 5bb196b

Browse files
themsaidtaylorotwell
authored andcommitted
[5.4] Stop validating Memcached connection (#19192)
* Stop validating Memcached connection * remove import * update tests
1 parent 2f41489 commit 5bb196b

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

src/Illuminate/Cache/MemcachedConnector.php

+1-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminate\Cache;
44

55
use Memcached;
6-
use RuntimeException;
76

87
class MemcachedConnector
98
{
@@ -15,8 +14,6 @@ class MemcachedConnector
1514
* @param array $options
1615
* @param array $credentials
1716
* @return \Memcached
18-
*
19-
* @throws \RuntimeException
2017
*/
2118
public function connect(array $servers, $connectionId = null, array $options = [], array $credentials = [])
2219
{
@@ -35,7 +32,7 @@ public function connect(array $servers, $connectionId = null, array $options = [
3532
}
3633
}
3734

38-
return $this->validateConnection($memcached);
35+
return $memcached;
3936
}
4037

4138
/**
@@ -87,25 +84,4 @@ protected function setCredentials($memcached, $credentials)
8784

8885
$memcached->setSaslAuthData($username, $password);
8986
}
90-
91-
/**
92-
* Validate the given Memcached connection.
93-
*
94-
* @param \Memcached $memcached
95-
* @return \Memcached
96-
*/
97-
protected function validateConnection($memcached)
98-
{
99-
$status = $memcached->getVersion();
100-
101-
if (! is_array($status)) {
102-
throw new RuntimeException('No Memcached servers added.');
103-
}
104-
105-
if (in_array('255.255.255', $status) && count(array_unique($status)) === 1) {
106-
throw new RuntimeException('Could not establish Memcached connection.');
107-
}
108-
109-
return $memcached;
110-
}
11187
}

tests/Cache/CacheMemcachedConnectorTest.php

-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Memcached;
66
use Mockery as m;
7-
use RuntimeException;
87
use PHPUnit\Framework\TestCase;
98

109
class CacheMemcachedConnectorTest extends TestCase
@@ -28,21 +27,6 @@ public function testServersAreAddedCorrectly()
2827
$this->assertSame($result, $memcached);
2928
}
3029

31-
/**
32-
* @expectedException RuntimeException
33-
*/
34-
public function testExceptionThrownOnBadConnection()
35-
{
36-
$memcached = $this->memcachedMockWithAddServer(['255.255.255']);
37-
38-
$connector = $this->connectorMock();
39-
$connector->expects($this->once())
40-
->method('createMemcachedInstance')
41-
->will($this->returnValue($memcached));
42-
43-
$this->connect($connector);
44-
}
45-
4630
public function testServersAreAddedCorrectlyWithPersistentConnection()
4731
{
4832
$persistentConnectionId = 'persistent_connection_id';
@@ -110,7 +94,6 @@ protected function memcachedMockWithAddServer($returnedVersion = [])
11094
{
11195
$memcached = m::mock('stdClass');
11296
$memcached->shouldReceive('addServer')->once()->with($this->getHost(), $this->getPort(), $this->getWeight());
113-
$memcached->shouldReceive('getVersion')->once()->andReturn($returnedVersion);
11497
$memcached->shouldReceive('getServerList')->once()->andReturn([]);
11598

11699
return $memcached;

0 commit comments

Comments
 (0)