Skip to content

Commit

Permalink
Merge pull request #49 from vpg/php7
Browse files Browse the repository at this point in the history
Making cachetool compatible w/ php7
  • Loading branch information
gordalina authored Oct 1, 2017
2 parents 22d5c7b + c405f12 commit 42ae3c3
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 6 deletions.
19 changes: 16 additions & 3 deletions src/CacheTool/Adapter/FastCGI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class FastCGI extends AbstractAdapter
*/
protected $client;

/**
* @var Array of patterns matching php socket files
*/
protected $possibleSocketFilePatterns = [
'/var/run/php*.sock',
'/var/run/php/*.sock'
];

/**
* @var string
*/
Expand All @@ -34,9 +42,14 @@ public function __construct($host = null, $tempDir = null)
{
// try to guess where it is
if ($host === null) {
if (file_exists('/var/run/php5-fpm.sock')) {
$host = '/var/run/php5-fpm.sock';
} else {
foreach ($this->possibleSocketFilePatterns as $possibleSocketFilePattern) {
$possibleSocketFile = current(glob($possibleSocketFilePattern));
if (file_exists($possibleSocketFile)) {
$host = $possibleSocketFile;
break;
}
}
if ($host === null) {
$host = '127.0.0.1:9000';
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/CacheTool/Command/ApcCacheInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->ensureExtensionLoaded('apc');

$user = $this->getCacheTool()->apc_cache_info('user');
$system = $this->getCacheTool()->apc_cache_info('system');
$user = $this->getCacheTool()->apc_cache_info('user') ?: [];
$system = $this->getCacheTool()->apc_cache_info('system') ?: [];

$this->normalize($user);
$this->normalize($system);
Expand Down
2 changes: 1 addition & 1 deletion src/CacheTool/Command/ApcCacheInfoFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->ensureExtensionLoaded('apc');

$info = $this->getCacheTool()->apc_cache_info('system');
$info = $this->getCacheTool()->apc_cache_info('system') ?: [];
$this->normalize($info);

if (!$info) {
Expand Down
6 changes: 6 additions & 0 deletions tests/CacheTool/Command/ApcBinDumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcBinDumpCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();
$this->assertNoHHVM();

Expand All @@ -18,6 +21,9 @@ public function testCommand()

public function testCommandWithFile()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();
$this->assertNoHHVM();

Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcBinLoadCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcBinLoadCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();
$this->assertNoHHVM();

Expand Down
9 changes: 9 additions & 0 deletions tests/CacheTool/Command/ApcCacheClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcCacheClearCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:cache:clear all -v');
Expand All @@ -16,6 +19,9 @@ public function testCommand()

public function testCommandUser()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:cache:clear user -v');
Expand All @@ -25,6 +31,9 @@ public function testCommandUser()

public function testException()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:cache:clear err -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcCacheInfoCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcCacheInfoCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:cache:info');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcCacheInfoFileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcCacheInfoFileCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:cache:info:file -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcKeyDeleteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcKeyDeleteCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:key:delete key -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcKeyExistsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcKeyExistsCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:key:exists key -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcKeyFetchCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcKeyFetchCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:key:fetch key -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcKeyStoreCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcKeyStoreCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:key:store key value 3600 -v');
Expand Down
3 changes: 3 additions & 0 deletions tests/CacheTool/Command/ApcSmaInfoCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ApcSmaInfoCommandTest extends CommandTest
{
public function testCommand()
{
if (PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('Skip APC test w/ php7');
}
$this->assertHasApc();

$result = $this->runCommand('apc:sma:info -v');
Expand Down

0 comments on commit 42ae3c3

Please sign in to comment.