Skip to content

Commit abc6526

Browse files
Merge branch '3.1'
* 3.1: (30 commits) Fix merge [HttpFoundation] Use UPSERT for sessions stored in PgSql >= 9.5 [Console] fixed PHPDoc [Cache] Fix double fetch in ProxyAdapter [travis] HHVM 3.12 LTS Fix feature detection for IE [Form] Fixed collapsed choice attributes [Console] added explanation of messages usage in a progress bar force enabling the external XML entity loaders [Yaml] properly count skipped comment lines [WebProfilerBundle] Fix invalid CSS style Added progressive jpeg to mime types guesser [Yaml] Fix wrong line number when comments are inserted in the middle of a block. Fixed singular of committee Fixed singular of committee Do not inject web debug toolbar on attachments Fixed issue with legacy client initialization [FrameworkBundle] Remove unused variable bumped Symfony version to 3.0.8 updated VERSION for 3.0.7 ...
2 parents 4ae0f63 + 4995f77 commit abc6526

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
372372
$cacheDef->addMethodCall('setRedis', array(new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))));
373373
break;
374374
case 'apc':
375+
case 'apcu':
375376
case 'array':
376377
case 'xcache':
377378
case 'wincache':

HttpFoundation/DbalSessionHandler.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function write($sessionId, $data)
180180
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
181181
$updateStmt->execute();
182182

183-
// When MERGE is not supported, like in Postgres, we have to use this approach that can result in
183+
// When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in
184184
// duplicate key errors when the same session is written simultaneously. We can just catch such an
185185
// error and re-execute the update. This is similar to a serializable transaction with retry logic
186186
// on serialization failures but without the overhead and without possible false positives due to
@@ -224,11 +224,11 @@ private function getMergeSql()
224224
{
225225
$platform = $this->con->getDatabasePlatform()->getName();
226226

227-
switch ($platform) {
228-
case 'mysql':
227+
switch (true) {
228+
case 'mysql' === $platform:
229229
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
230230
"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)";
231-
case 'oracle':
231+
case 'oracle' === $platform:
232232
// DUAL is Oracle specific dummy table
233233
return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ".
234234
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
@@ -239,8 +239,11 @@ private function getMergeSql()
239239
return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ".
240240
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
241241
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;";
242-
case 'sqlite':
242+
case 'sqlite' === $platform:
243243
return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)";
244+
case 'postgresql' === $platform && version_compare($this->con->getServerVersion(), '9.5', '>='):
245+
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
246+
"ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->timeCol) = (:data, :time) WHERE $this->idCol = :id";
244247
}
245248
}
246249
}

Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public function providerBasicDrivers()
174174
{
175175
return array(
176176
array('doctrine.orm.cache.apc.class', array('type' => 'apc')),
177+
array('doctrine.orm.cache.apcu.class', array('type' => 'apcu')),
177178
array('doctrine.orm.cache.array.class', array('type' => 'array')),
178179
array('doctrine.orm.cache.xcache.class', array('type' => 'xcache')),
179180
array('doctrine.orm.cache.wincache.class', array('type' => 'wincache')),

0 commit comments

Comments
 (0)