GitHub PullRequestReviewCommentEvent at 2014-12-18 18:47:35
Repository: guzzle3
Actor: mtdowling
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/guzzle/guzzle3/pulls/comments/22061620","id":22061620,"diff_hunk":"@@ -30,6 +32,21 @@ public function __construct(EntityBodyInterface $body, $limit, $offset = 0)\n      */\n     public function __toString()\n     {\n+        // If the body implements the StreamInterface use a memory optimised read\n+\t\tif ($this->body instanceof StreamInterface)","path":"src/Guzzle/Http/ReadLimitEntityBody.php","position":14,"original_position":14,"commit_id":"ec8759d9400cf92ce5929488e071b6bf2b1ac59d","original_commit_id":"ec8759d9400cf92ce5929488e071b6bf2b1ac59d","user":{"login":"mtdowling","id":190930,"avatar_url":"https://avatars.githubusercontent.com/u/190930?v=3","gravatar_id":"","url":"https://api.github.com/users/mtdowling","html_url":"https://github.com/mtdowling","followers_url":"https://api.github.com/users/mtdowling/followers","following_url":"https://api.github.com/users/mtdowling/following{/other_user}","gists_url":"https://api.github.com/users/mtdowling/gists{/gist_id}","starred_url":"https://api.github.com/users/mtdowling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtdowling/subscriptions","organizations_url":"https://api.github.com/users/mtdowling/orgs","repos_url":"https://api.github.com/users/mtdowling/repos","events_url":"https://api.github.com/users/mtdowling/events{/privacy}","received_events_url":"https://api.github.com/users/mtdowling/received_events","type":"User","site_admin":false},"body":"I think `$this->body` is always a StreamInterface, so this is unnecessary.","created_at":"2014-12-18T18:47:35Z","updated_at":"2014-12-18T18:47:35Z","html_url":"https://github.com/guzzle/guzzle3/pull/46#discussion_r22061620","pull_request_url":"https://api.github.com/repos/guzzle/guzzle3/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/comments/22061620"},"html":{"href":"https://github.com/guzzle/guzzle3/pull/46#discussion_r22061620"},"pull_request":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/guzzle/guzzle3/pulls/46","id":24894492,"html_url":"https://github.com/guzzle/guzzle3/pull/46","diff_url":"https://github.com/guzzle/guzzle3/pull/46.diff","patch_url":"https://github.com/guzzle/guzzle3/pull/46.patch","issue_url":"https://api.github.com/repos/guzzle/guzzle3/issues/46","number":46,"state":"open","locked":false,"title":"Memory exhausted processing large streams","user":{"login":"nikosdion","id":256041,"avatar_url":"https://avatars.githubusercontent.com/u/256041?v=3","gravatar_id":"","url":"https://api.github.com/users/nikosdion","html_url":"https://github.com/nikosdion","followers_url":"https://api.github.com/users/nikosdion/followers","following_url":"https://api.github.com/users/nikosdion/following{/other_user}","gists_url":"https://api.github.com/users/nikosdion/gists{/gist_id}","starred_url":"https://api.github.com/users/nikosdion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikosdion/subscriptions","organizations_url":"https://api.github.com/users/nikosdion/orgs","repos_url":"https://api.github.com/users/nikosdion/repos","events_url":"https://api.github.com/users/nikosdion/events{/privacy}","received_events_url":"https://api.github.com/users/nikosdion/received_events","type":"User","site_admin":false},"body":"# Executive summary\r\n\r\nMemory exhaustion error when using ReadLimitEntityBody with streams larger thant the available PHP memory.\r\n\r\n# Technical explanation\r\n\r\nThe __toString() method in Guzzle\\Http\\ReadLimitEntityBody will try to read the entire stream into memory, then use substr() to select a subset. If you have a stream larger than the available PHP memory your script will crash due to lack of sufficient PHP memory.\r\n\r\nThis can be fixed by duplicating some of the code in Guzzle\\Stream\\Stream's __toString method. This allows us to only read into memory the part of the stream defined by the $limit and $offset in the ReadLimitEntityBody instance. It's not as elegant or academically correct as the existing code but it solves a serious practical shortcoming.\r\n\r\n# Use case\r\n\r\nI've hit this issue while using Amazon SDK for PHP to perform a multipart upload of a 2Gb file to S3 using the AWS4 (v4) signature method. When using the unmodified Guzzle 3 sources it resulted in an immediate PHP memory limit error. After the proposed change the upload completes successfully.\r\n\r\n# Backwards compatibility issues\r\n\r\nNo backwards compatibility issues are expected. The proposed change is enclosed in an if-block which makes it run only when $body implements StreamInterface. In any other case it works as a simple decorator (prior behaviour).","created_at":"2014-11-22T22:32:03Z","updated_at":"2014-12-18T18:47:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ed7a71de8e1bc63f3d1a3352bcaa0edb5fa3e1d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guzzle/guzzle3/pulls/46/commits","review_comments_url":"https://api.github.com/repos/guzzle/guzzle3/pulls/46/comments","review_comment_url":"https://api.github.com/repos/guzzle/guzzle3/pulls/comments/{number}","comments_url":"https://api.github.com/repos/guzzle/guzzle3/issues/46/comments","statuses_url":"https://api.github.com/repos/guzzle/guzzle3/statuses/ec8759d9400cf92ce5929488e071b6bf2b1ac59d","head":{"label":"nikosdion:patch-1","ref":"patch-1","sha":"ec8759d9400cf92ce5929488e071b6bf2b1ac59d","user":{"login":"nikosdion","id":256041,"avatar_url":"https://avatars.githubusercontent.com/u/256041?v=3","gravatar_id":"","url":"https://api.github.com/users/nikosdion","html_url":"https://github.com/nikosdion","followers_url":"https://api.github.com/users/nikosdion/followers","following_url":"https://api.github.com/users/nikosdion/following{/other_user}","gists_url":"https://api.github.com/users/nikosdion/gists{/gist_id}","starred_url":"https://api.github.com/users/nikosdion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikosdion/subscriptions","organizations_url":"https://api.github.com/users/nikosdion/orgs","repos_url":"https://api.github.com/users/nikosdion/repos","events_url":"https://api.github.com/users/nikosdion/events{/privacy}","received_events_url":"https://api.github.com/users/nikosdion/received_events","type":"User","site_admin":false},"repo":{"id":27014424,"name":"guzzle3","full_name":"nikosdion/guzzle3","owner":{"login":"nikosdion","id":256041,"avatar_url":"https://avatars.githubusercontent.com/u/256041?v=3","gravatar_id":"","url":"https://api.github.com/users/nikosdion","html_url":"https://github.com/nikosdion","followers_url":"https://api.github.com/users/nikosdion/followers","following_url":"https://api.github.com/users/nikosdion/following{/other_user}","gists_url":"https://api.github.com/users/nikosdion/gists{/gist_id}","starred_url":"https://api.github.com/users/nikosdion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikosdion/subscriptions","organizations_url":"https://api.github.com/users/nikosdion/orgs","repos_url":"https://api.github.com/users/nikosdion/repos","events_url":"https://api.github.com/users/nikosdion/events{/privacy}","received_events_url":"https://api.github.com/users/nikosdion/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nikosdion/guzzle3","description":"Guzzle version 3. This is somewhat maintained, but upgrading to Guzzle 5 is strongly recommended.","fork":true,"url":"https://api.github.com/repos/nikosdion/guzzle3","forks_url":"https://api.github.com/repos/nikosdion/guzzle3/forks","keys_url":"https://api.github.com/repos/nikosdion/guzzle3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nikosdion/guzzle3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nikosdion/guzzle3/teams","hooks_url":"https://api.github.com/repos/nikosdion/guzzle3/hooks","issue_events_url":"https://api.github.com/repos/nikosdion/guzzle3/issues/events{/number}","events_url":"https://api.github.com/repos/nikosdion/guzzle3/events","assignees_url":"https://api.github.com/repos/nikosdion/guzzle3/assignees{/user}","branches_url":"https://api.github.com/repos/nikosdion/guzzle3/branches{/branch}","tags_url":"https://api.github.com/repos/nikosdion/guzzle3/tags","blobs_url":"https://api.github.com/repos/nikosdion/guzzle3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nikosdion/guzzle3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nikosdion/guzzle3/git/refs{/sha}","trees_url":"https://api.github.com/repos/nikosdion/guzzle3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nikosdion/guzzle3/statuses/{sha}","languages_url":"https://api.github.com/repos/nikosdion/guzzle3/languages","stargazers_url":"https://api.github.com/repos/nikosdion/guzzle3/stargazers","contributors_url":"https://api.github.com/repos/nikosdion/guzzle3/contributors","subscribers_url":"https://api.github.com/repos/nikosdion/guzzle3/subscribers","subscription_url":"https://api.github.com/repos/nikosdion/guzzle3/subscription","commits_url":"https://api.github.com/repos/nikosdion/guzzle3/commits{/sha}","git_commits_url":"https://api.github.com/repos/nikosdion/guzzle3/git/commits{/sha}","comments_url":"https://api.github.com/repos/nikosdion/guzzle3/comments{/number}","issue_comment_url":"https://api.github.com/repos/nikosdion/guzzle3/issues/comments/{number}","contents_url":"https://api.github.com/repos/nikosdion/guzzle3/contents/{+path}","compare_url":"https://api.github.com/repos/nikosdion/guzzle3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nikosdion/guzzle3/merges","archive_url":"https://api.github.com/repos/nikosdion/guzzle3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nikosdion/guzzle3/downloads","issues_url":"https://api.github.com/repos/nikosdion/guzzle3/issues{/number}","pulls_url":"https://api.github.com/repos/nikosdion/guzzle3/pulls{/number}","milestones_url":"https://api.github.com/repos/nikosdion/guzzle3/milestones{/number}","notifications_url":"https://api.github.com/repos/nikosdion/guzzle3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nikosdion/guzzle3/labels{/name}","releases_url":"https://api.github.com/repos/nikosdion/guzzle3/releases{/id}","created_at":"2014-11-22T22:19:42Z","updated_at":"2014-11-22T22:19:45Z","pushed_at":"2014-11-22T22:31:39Z","git_url":"git://github.com/nikosdion/guzzle3.git","ssh_url":"git@github.com:nikosdion/guzzle3.git","clone_url":"https://github.com/nikosdion/guzzle3.git","svn_url":"https://github.com/nikosdion/guzzle3","homepage":"","size":8272,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"guzzle:master","ref":"master","sha":"5e6fb7097efac7180bd75006079144025255eb63","user":{"login":"guzzle","id":638632,"avatar_url":"https://avatars.githubusercontent.com/u/638632?v=3","gravatar_id":"","url":"https://api.github.com/users/guzzle","html_url":"https://github.com/guzzle","followers_url":"https://api.github.com/users/guzzle/followers","following_url":"https://api.github.com/users/guzzle/following{/other_user}","gists_url":"https://api.github.com/users/guzzle/gists{/gist_id}","starred_url":"https://api.github.com/users/guzzle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guzzle/subscriptions","organizations_url":"https://api.github.com/users/guzzle/orgs","repos_url":"https://api.github.com/users/guzzle/repos","events_url":"https://api.github.com/users/guzzle/events{/privacy}","received_events_url":"https://api.github.com/users/guzzle/received_events","type":"Organization","site_admin":false},"repo":{"id":17785073,"name":"guzzle3","full_name":"guzzle/guzzle3","owner":{"login":"guzzle","id":638632,"avatar_url":"https://avatars.githubusercontent.com/u/638632?v=3","gravatar_id":"","url":"https://api.github.com/users/guzzle","html_url":"https://github.com/guzzle","followers_url":"https://api.github.com/users/guzzle/followers","following_url":"https://api.github.com/users/guzzle/following{/other_user}","gists_url":"https://api.github.com/users/guzzle/gists{/gist_id}","starred_url":"https://api.github.com/users/guzzle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guzzle/subscriptions","organizations_url":"https://api.github.com/users/guzzle/orgs","repos_url":"https://api.github.com/users/guzzle/repos","events_url":"https://api.github.com/users/guzzle/events{/privacy}","received_events_url":"https://api.github.com/users/guzzle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guzzle/guzzle3","description":"Guzzle version 3. This is somewhat maintained, but upgrading to Guzzle 5 is strongly recommended.","fork":false,"url":"https://api.github.com/repos/guzzle/guzzle3","forks_url":"https://api.github.com/repos/guzzle/guzzle3/forks","keys_url":"https://api.github.com/repos/guzzle/guzzle3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guzzle/guzzle3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guzzle/guzzle3/teams","hooks_url":"https://api.github.com/repos/guzzle/guzzle3/hooks","issue_events_url":"https://api.github.com/repos/guzzle/guzzle3/issues/events{/number}","events_url":"https://api.github.com/repos/guzzle/guzzle3/events","assignees_url":"https://api.github.com/repos/guzzle/guzzle3/assignees{/user}","branches_url":"https://api.github.com/repos/guzzle/guzzle3/branches{/branch}","tags_url":"https://api.github.com/repos/guzzle/guzzle3/tags","blobs_url":"https://api.github.com/repos/guzzle/guzzle3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guzzle/guzzle3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guzzle/guzzle3/git/refs{/sha}","trees_url":"https://api.github.com/repos/guzzle/guzzle3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guzzle/guzzle3/statuses/{sha}","languages_url":"https://api.github.com/repos/guzzle/guzzle3/languages","stargazers_url":"https://api.github.com/repos/guzzle/guzzle3/stargazers","contributors_url":"https://api.github.com/repos/guzzle/guzzle3/contributors","subscribers_url":"https://api.github.com/repos/guzzle/guzzle3/subscribers","subscription_url":"https://api.github.com/repos/guzzle/guzzle3/subscription","commits_url":"https://api.github.com/repos/guzzle/guzzle3/commits{/sha}","git_commits_url":"https://api.github.com/repos/guzzle/guzzle3/git/commits{/sha}","comments_url":"https://api.github.com/repos/guzzle/guzzle3/comments{/number}","issue_comment_url":"https://api.github.com/repos/guzzle/guzzle3/issues/comments/{number}","contents_url":"https://api.github.com/repos/guzzle/guzzle3/contents/{+path}","compare_url":"https://api.github.com/repos/guzzle/guzzle3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guzzle/guzzle3/merges","archive_url":"https://api.github.com/repos/guzzle/guzzle3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guzzle/guzzle3/downloads","issues_url":"https://api.github.com/repos/guzzle/guzzle3/issues{/number}","pulls_url":"https://api.github.com/repos/guzzle/guzzle3/pulls{/number}","milestones_url":"https://api.github.com/repos/guzzle/guzzle3/milestones{/number}","notifications_url":"https://api.github.com/repos/guzzle/guzzle3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guzzle/guzzle3/labels{/name}","releases_url":"https://api.github.com/repos/guzzle/guzzle3/releases{/id}","created_at":"2014-03-15T20:44:46Z","updated_at":"2014-12-18T18:45:39Z","pushed_at":"2014-12-18T18:45:39Z","git_url":"git://github.com/guzzle/guzzle3.git","ssh_url":"git@github.com:guzzle/guzzle3.git","clone_url":"https://github.com/guzzle/guzzle3.git","svn_url":"https://github.com/guzzle/guzzle3","homepage":"","size":9049,"stargazers_count":35,"watchers_count":35,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":7,"forks":24,"open_issues":7,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/46"},"html":{"href":"https://github.com/guzzle/guzzle3/pull/46"},"issue":{"href":"https://api.github.com/repos/guzzle/guzzle3/issues/46"},"comments":{"href":"https://api.github.com/repos/guzzle/guzzle3/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/guzzle/guzzle3/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/guzzle/guzzle3/statuses/ec8759d9400cf92ce5929488e071b6bf2b1ac59d"}}}}