{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/67624243","id":67624243,"diff_hunk":"@@ -653,32 +647,65 @@ private function getSelectSql()\n     }\n \n     /**\n-     * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database for writing session data.\n+     * Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data.\n      *\n-     * @return string|null The SQL string or null when not supported\n+     * @param string $sessionId   Session ID\n+     * @param string $data        Encoded session data\n+     * @param int    $maxlifetime session.gc_maxlifetime\n+     *\n+     * @return \\PDOStatement|null The merge statement or null when not supported\n      */\n-    private function getMergeSql()\n+    private function getMergeStatement($sessionId, $data, $maxlifetime)\n     {\n+        $mergeSql = null;\n         switch (true) {\n             case 'mysql' === $this->driver:\n-                return \"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n+                $mergeSql = \"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n                     \"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)\";\n+                break;\n             case 'oci' === $this->driver:\n                 // DUAL is Oracle specific dummy table\n-                return \"MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) \".\n-                    \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n-                    \"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time\";\n+                $mergeSql = \"MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) \".\n+                    \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) \".\n+                    \"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?\";\n+                break;\n             case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\\PDO::ATTR_SERVER_VERSION), '10', '>='):\n                 // MERGE is only available since SQL Server 2008 and must be terminated by semicolon\n                 // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx\n-                return \"MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) \".\n-                    \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n-                    \"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time;\";\n+                $mergeSql = \"MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) \".\n+                    \"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) \".\n+                    \"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;\";\n+                break;\n             case 'sqlite' === $this->driver:\n-                return \"INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)\";\n+                $mergeSql = \"INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)\";\n+                break;\n             case 'pgsql' === $this->driver && version_compare($this->pdo->getAttribute(\\PDO::ATTR_SERVER_VERSION), '9.5', '>='):\n-                return \"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n+                $mergeSql = \"INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) \".\n                     \"ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)\";\n+                break;\n+        }\n+\n+        if (null !== $mergeSql) {\n+            $mergeStmt = $this->pdo->prepare($mergeSql);\n+\n+            if ('sqlsrv' === $this->driver || 'oci' === $this->driver) {\n+                $mergeStmt->bindParam(1, $sessionId, \\PDO::PARAM_STR);\n+                $mergeStmt->bindParam(2, $sessionId, \\PDO::PARAM_STR);\n+                $mergeStmt->bindParam(3, $data, \\PDO::PARAM_LOB);\n+                $mergeStmt->bindParam(4, $maxlifetime, \\PDO::PARAM_INT);\n+                $mergeStmt->bindValue(5, time(), \\PDO::PARAM_INT);\n+                $mergeStmt->bindParam(6, $data, \\PDO::PARAM_LOB);\n+                $mergeStmt->bindParam(7, $maxlifetime, \\PDO::PARAM_INT);\n+                $mergeStmt->bindValue(8, time(), \\PDO::PARAM_INT);\n+            }","path":"src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php","position":83,"original_position":83,"commit_id":"ebf3a2ffc8e778b255bb4786f19dba8ae4100575","original_commit_id":"ebf3a2ffc8e778b255bb4786f19dba8ae4100575","user":{"login":"phansys","id":1231441,"avatar_url":"https://avatars.githubusercontent.com/u/1231441?v=3","gravatar_id":"","url":"https://api.github.com/users/phansys","html_url":"https://github.com/phansys","followers_url":"https://api.github.com/users/phansys/followers","following_url":"https://api.github.com/users/phansys/following{/other_user}","gists_url":"https://api.github.com/users/phansys/gists{/gist_id}","starred_url":"https://api.github.com/users/phansys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phansys/subscriptions","organizations_url":"https://api.github.com/users/phansys/orgs","repos_url":"https://api.github.com/users/phansys/repos","events_url":"https://api.github.com/users/phansys/events{/privacy}","received_events_url":"https://api.github.com/users/phansys/received_events","type":"User","site_admin":false},"body":"Sure @hjkl, I refer to [PSR-2 5.1](http://www.php-fig.org/psr/psr-2/#5-1-if-elseif-else):\r\n```php\r\n} else {\r\n```\r\nThank you.","created_at":"2016-06-19T21:37:42Z","updated_at":"2016-06-19T21:37:42Z","html_url":"https://github.com/symfony/symfony/pull/18501#discussion_r67624243","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/18501","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/67624243"},"html":{"href":"https://github.com/symfony/symfony/pull/18501#discussion_r67624243"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/18501"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/18501","id":65918801,"html_url":"https://github.com/symfony/symfony/pull/18501","diff_url":"https://github.com/symfony/symfony/pull/18501.diff","patch_url":"https://github.com/symfony/symfony/pull/18501.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/18501","number":18501,"state":"closed","locked":false,"title":"[HttpFoundation] changed MERGE queries","user":{"login":"hjkl","id":151291,"avatar_url":"https://avatars.githubusercontent.com/u/151291?v=3","gravatar_id":"","url":"https://api.github.com/users/hjkl","html_url":"https://github.com/hjkl","followers_url":"https://api.github.com/users/hjkl/followers","following_url":"https://api.github.com/users/hjkl/following{/other_user}","gists_url":"https://api.github.com/users/hjkl/gists{/gist_id}","starred_url":"https://api.github.com/users/hjkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjkl/subscriptions","organizations_url":"https://api.github.com/users/hjkl/orgs","repos_url":"https://api.github.com/users/hjkl/repos","events_url":"https://api.github.com/users/hjkl/events{/privacy}","received_events_url":"https://api.github.com/users/hjkl/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | 2.7\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #17284\r\n| License | MIT\r\n| Doc PR | N/A\r\n\r\nChanged the MERGE queries for Oracle and SQL Server to use question mark parameter markers so they work with emulation disabled or enabled - fixes #17284","created_at":"2016-04-10T18:45:12Z","updated_at":"2016-06-19T21:37:42Z","closed_at":"2016-06-19T10:25:49Z","merged_at":"2016-06-19T10:25:49Z","merge_commit_sha":"ebf3a2ffc8e778b255bb4786f19dba8ae4100575","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/18501/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/18501/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/18501/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/ebf3a2ffc8e778b255bb4786f19dba8ae4100575","head":{"label":"hjkl:ticket_17284","ref":"ticket_17284","sha":"ebf3a2ffc8e778b255bb4786f19dba8ae4100575","user":{"login":"hjkl","id":151291,"avatar_url":"https://avatars.githubusercontent.com/u/151291?v=3","gravatar_id":"","url":"https://api.github.com/users/hjkl","html_url":"https://github.com/hjkl","followers_url":"https://api.github.com/users/hjkl/followers","following_url":"https://api.github.com/users/hjkl/following{/other_user}","gists_url":"https://api.github.com/users/hjkl/gists{/gist_id}","starred_url":"https://api.github.com/users/hjkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjkl/subscriptions","organizations_url":"https://api.github.com/users/hjkl/orgs","repos_url":"https://api.github.com/users/hjkl/repos","events_url":"https://api.github.com/users/hjkl/events{/privacy}","received_events_url":"https://api.github.com/users/hjkl/received_events","type":"User","site_admin":false},"repo":{"id":55913663,"name":"symfony","full_name":"hjkl/symfony","owner":{"login":"hjkl","id":151291,"avatar_url":"https://avatars.githubusercontent.com/u/151291?v=3","gravatar_id":"","url":"https://api.github.com/users/hjkl","html_url":"https://github.com/hjkl","followers_url":"https://api.github.com/users/hjkl/followers","following_url":"https://api.github.com/users/hjkl/following{/other_user}","gists_url":"https://api.github.com/users/hjkl/gists{/gist_id}","starred_url":"https://api.github.com/users/hjkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjkl/subscriptions","organizations_url":"https://api.github.com/users/hjkl/orgs","repos_url":"https://api.github.com/users/hjkl/repos","events_url":"https://api.github.com/users/hjkl/events{/privacy}","received_events_url":"https://api.github.com/users/hjkl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hjkl/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/hjkl/symfony","forks_url":"https://api.github.com/repos/hjkl/symfony/forks","keys_url":"https://api.github.com/repos/hjkl/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hjkl/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hjkl/symfony/teams","hooks_url":"https://api.github.com/repos/hjkl/symfony/hooks","issue_events_url":"https://api.github.com/repos/hjkl/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/hjkl/symfony/events","assignees_url":"https://api.github.com/repos/hjkl/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/hjkl/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/hjkl/symfony/tags","blobs_url":"https://api.github.com/repos/hjkl/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hjkl/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hjkl/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/hjkl/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hjkl/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/hjkl/symfony/languages","stargazers_url":"https://api.github.com/repos/hjkl/symfony/stargazers","contributors_url":"https://api.github.com/repos/hjkl/symfony/contributors","subscribers_url":"https://api.github.com/repos/hjkl/symfony/subscribers","subscription_url":"https://api.github.com/repos/hjkl/symfony/subscription","commits_url":"https://api.github.com/repos/hjkl/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/hjkl/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/hjkl/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/hjkl/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/hjkl/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/hjkl/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hjkl/symfony/merges","archive_url":"https://api.github.com/repos/hjkl/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hjkl/symfony/downloads","issues_url":"https://api.github.com/repos/hjkl/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/hjkl/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/hjkl/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/hjkl/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hjkl/symfony/labels{/name}","releases_url":"https://api.github.com/repos/hjkl/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/hjkl/symfony/deployments","created_at":"2016-04-10T17:46:53Z","updated_at":"2016-04-10T17:47:09Z","pushed_at":"2016-06-18T19:15:59Z","git_url":"git://github.com/hjkl/symfony.git","ssh_url":"git@github.com:hjkl/symfony.git","clone_url":"https://github.com/hjkl/symfony.git","svn_url":"https://github.com/hjkl/symfony","homepage":"symfony.com","size":71110,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"86552ea2dce6c7cd64b09540e6a19292e5d7db24","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2016-06-19T21:25:29Z","pushed_at":"2016-06-19T18:26:11Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":133751,"stargazers_count":12510,"watchers_count":12510,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4882,"mirror_url":null,"open_issues_count":703,"forks":4882,"open_issues":703,"watchers":12510,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/18501"},"html":{"href":"https://github.com/symfony/symfony/pull/18501"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/18501"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/18501/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/18501/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/18501/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/ebf3a2ffc8e778b255bb4786f19dba8ae4100575"}}}}
{"actor":{"display_login":"phansys"}}