Commit 2fbe2b56 authored by webchick's avatar webchick

Issue #2182423 by Berdir, joelpittet: Key_value_expire doesn't get reset and...

Issue #2182423 by Berdir, joelpittet: Key_value_expire doesn't get reset and balloons the PDO execution time for form pages.
parent be0139bd
......@@ -18,9 +18,9 @@ class KeyValueDatabaseExpirableFactory implements KeyValueExpirableFactoryInterf
/**
* Holds references to each instantiation so they can be terminated.
*
* @var array
* @var \Drupal\Core\KeyValueStore\DatabaseStorageExpirable[]
*/
protected $storages;
protected $storages = array();
/**
* The database connection.
......@@ -44,16 +44,20 @@ function __construct(Connection $connection) {
* {@inheritdoc}
*/
public function get($collection) {
$storage = new DatabaseStorageExpirable($collection, $this->connection);
$this->storages[] = $storage;
return $storage;
if (!isset($this->storages[$collection])) {
$this->storages[$collection] = new DatabaseStorageExpirable($collection, $this->connection);
}
return $this->storages[$collection];
}
/**
* Implements Drupal\Core\DestructableInterface::terminate().
* {@inheritdoc}
*/
public function destruct() {
foreach ($this->storages as $storage) {
if (!empty($this->storages)) {
// Each instance does garbage collection for all collections, so we can
// optimize and only have to call the first, avoids multiple DELETE.
$storage = reset($this->storages);
$storage->destruct();
}
}
......
......@@ -712,6 +712,7 @@ function system_schema() {
'primary key' => array('collection', 'name'),
'indexes' => array(
'all' => array('name', 'collection', 'expire'),
'expire' => array('expire'),
),
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment