summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Lee2017-07-06 13:14:21 (GMT)
committerDamian Lee2017-07-06 13:14:21 (GMT)
commitcd53ea6efe8306419e6052269b5899b07214f144 (patch)
tree2e0e085a9cbf5870772df17719bd1eb5cd0ea0bf
parented98d696169be0ad7ecd7b25639fbf5353a4ec79 (diff)
Issue #2887558 by damiankloip, hswong3i, delta, MiSc: Circular reference detected for service "cache.backend.memcache"8.x-2.0-alpha4
-rw-r--r--memcache.services.yml5
-rw-r--r--src/DrupalMemcache.php17
-rw-r--r--src/DrupalMemcacheBase.php30
-rw-r--r--src/DrupalMemcacheFactory.php21
4 files changed, 14 insertions, 59 deletions
diff --git a/memcache.services.yml b/memcache.services.yml
index 0cf6c77..1e85ebd 100644
--- a/memcache.services.yml
+++ b/memcache.services.yml
@@ -4,13 +4,10 @@ services:
arguments: ['@settings']
memcache.factory:
class: Drupal\memcache\DrupalMemcacheFactory
- arguments: ['@memcache.config', '@logger.channel.memcache']
+ arguments: ['@memcache.config']
cache.backend.memcache:
class: Drupal\memcache\MemcacheBackendFactory
arguments: ['@lock', '@memcache.config', '@memcache.factory', '@cache_tags.invalidator.checksum']
memcache.lock.factory:
class: Drupal\memcache\Lock\MemcacheLockFactory
arguments: ['@memcache.factory']
- logger.channel.memcache:
- parent: logger.channel_base
- arguments: ['memcache']
diff --git a/src/DrupalMemcache.php b/src/DrupalMemcache.php
index 2a618ed..dd1027f 100644
--- a/src/DrupalMemcache.php
+++ b/src/DrupalMemcache.php
@@ -7,7 +7,7 @@
namespace Drupal\memcache;
-use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
/**
* Class DrupalMemcache.
@@ -17,8 +17,8 @@ class DrupalMemcache extends DrupalMemcacheBase {
/**
* {@inheritdoc}
*/
- public function __construct(DrupalMemcacheConfig $settings, LoggerInterface $logger) {
- parent::__construct($settings, $logger);
+ public function __construct(DrupalMemcacheConfig $settings) {
+ parent::__construct($settings);
$this->memcache = new \Memcache();
}
@@ -86,16 +86,7 @@ class DrupalMemcache extends DrupalMemcacheBase {
$full_keys[$cid] = $full_key;
}
- $track_errors = ini_set('track_errors', 1);
- $php_errormsg = '';
- $results = @$this->memcache->get($full_keys);
-
- if (!empty($php_errormsg)) {
- $this->logger->warning('Exception caught in DrupalMemcache::getMulti: !msg', ['!msg' => $php_errormsg]);
- $php_errormsg = '';
- }
-
- ini_set('track_errors', $track_errors);
+ $results = $this->memcache->get($full_keys);
// If $results is FALSE, convert it to an empty array.
if (!$results) {
diff --git a/src/DrupalMemcacheBase.php b/src/DrupalMemcacheBase.php
index e303889..7c2bf39 100644
--- a/src/DrupalMemcacheBase.php
+++ b/src/DrupalMemcacheBase.php
@@ -7,7 +7,7 @@
namespace Drupal\memcache;
-use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
/**
* Class DrupalMemcacheBase.
@@ -44,27 +44,16 @@ abstract class DrupalMemcacheBase implements DrupalMemcacheInterface {
protected $prefix;
/**
- * A logger instance.
- *
- * @var \Psr\Log\LoggerInterface
- */
- protected $logger;
-
- /**
* Constructs a DrupalMemcacheBase object.
*
- * @param \Drupal\memcache\DrupalMemcacheConfig $settings
+ * @param \Drupal\memcache\DrupalMemcacheConfig
* The memcache config object.
- * @param \Psr\Log\LoggerInterface $logger
- * A logger instance.
*/
- public function __construct(DrupalMemcacheConfig $settings, LoggerInterface $logger) {
+ public function __construct(DrupalMemcacheConfig $settings) {
$this->settings = $settings;
$this->hashAlgorithm = $this->settings->get('key_hash_algorithm', 'sha1');
$this->prefix = $this->settings->get('key_prefix', '');
-
- $this->logger = $logger;
}
/**
@@ -72,18 +61,7 @@ abstract class DrupalMemcacheBase implements DrupalMemcacheInterface {
*/
public function get($key) {
$full_key = $this->key($key);
-
- $track_errors = ini_set('track_errors', '1');
- $php_errormsg = '';
- $result = @$this->memcache->get($full_key);
-
- if (!empty($php_errormsg)) {
- $this->logger->warning('Exception caught in DrupalMemcacheBase::get: !msg', ['!msg' => $php_errormsg]);
- $php_errormsg = '';
- }
- ini_set('track_errors', $track_errors);
-
- return $result;
+ return $this->memcache->get($full_key);
}
/**
diff --git a/src/DrupalMemcacheFactory.php b/src/DrupalMemcacheFactory.php
index 4f10071..30e9cce 100644
--- a/src/DrupalMemcacheFactory.php
+++ b/src/DrupalMemcacheFactory.php
@@ -7,7 +7,7 @@
namespace Drupal\memcache;
-use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
/**
* Factory class for creation of Memcache objects.
@@ -52,23 +52,13 @@ class DrupalMemcacheFactory {
protected $failedConnectionCache = array();
/**
- * A logger instance.
- *
- * @var \Psr\Log\LoggerInterface
- */
- protected $logger;
-
- /**
* Constructs a DrupalMemcacheFactory object.
*
* @param \Drupal\memcache\DrupalMemcacheConfig $settings
- * A Settings Object.
- * @param \Psr\Log\LoggerInterface $logger
- * A logger instance.
*/
- public function __construct(DrupalMemcacheConfig $settings, LoggerInterface $logger) {
+ public function __construct(DrupalMemcacheConfig $settings) {
$this->settings = $settings;
- $this->logger = $logger;
+
$this->initialize();
}
@@ -105,10 +95,10 @@ class DrupalMemcacheFactory {
// object.
// @todo Can't add a custom memcache class here yet.
if ($this->extension == 'Memcached') {
- $memcache = new DrupalMemcached($this->settings, $this->logger);
+ $memcache = new DrupalMemcached($this->settings);
}
elseif ($this->extension == 'Memcache') {
- $memcache = new DrupalMemcache($this->settings, $this->logger);
+ $memcache = new DrupalMemcache($this->settings);
}
// A variable to track whether we've connected to the first server.
@@ -122,7 +112,6 @@ class DrupalMemcacheFactory {
}
if (!$init) {
- $this->logger->warning('Failed to connect to memcache server: !server', ['!server' => $s]);
$this->failedConnectionCache[$s] = FALSE;
}
}