Skip to content

Commit

Permalink
Add PDO cache driverOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
pagani-BETTERHOMES committed Sep 12, 2023
1 parent dc72146 commit 24b0106
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Neos.Cache/Classes/Backend/PdoBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class PdoBackend extends IndependentAbstractBackend implements TaggableBackendIn
*/
protected $password;

/**
* @var array
*/
protected $driverOptions = [];

/**
* @var \PDO
*/
Expand Down Expand Up @@ -118,6 +123,18 @@ protected function setPassword(string $password): void
$this->password = $password;
}

/**
* Sets the driverOptions to use
*
* @param array $driverOptions The options to use for connecting to the DB
* @return void
* @api
*/
protected function setDriverOptions(array $driverOptions): void
{
$this->driverOptions = $driverOptions;
}

/**
* Sets the name of the "cache" table
*
Expand Down Expand Up @@ -389,7 +406,7 @@ public function flushByTags(array $tags): int
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier" FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag" IN (' . $tagPlaceholders . ')');
$statementHandle->execute(array_merge([$this->context(), $this->cacheIdentifier], $tagList));
$result = $statementHandle->fetchAll();
$identifiers[]= array_column($result, 'identifier');
$identifiers[] = array_column($result, 'identifier');
}
$identifiers = array_merge([], ...$identifiers);

Expand Down Expand Up @@ -501,10 +518,10 @@ protected function connect()
throw new Exception(sprintf('Could not create directory for sqlite file "%s"', $splitdsn[1]), 1565359792, $exception);
}
}
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password, $this->driverOptions);
$this->createCacheTables();
} else {
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password, $this->driverOptions);
}
$this->databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

Expand Down

0 comments on commit 24b0106

Please sign in to comment.