{"action":"created","comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/comments/26723647","id":26723647,"diff_hunk":"@@ -58,124 +58,107 @@ public function extract($archive, $destination, array $options = array ())\n \n \t\tif (!extension_loaded('zlib'))\n \t\t{\n-\t\t\tif (class_exists('JError'))\n-\t\t\t{\n-\t\t\t\treturn JError::raiseWarning(100, 'The zlib extension is not available.');\n-\t\t\t}\n-\t\t\telse\n-\t\t\t{\n-\t\t\t\tthrow new RuntimeException('The zlib extension is not available.');\n-\t\t\t}\n+\t\t\treturn $this->raiseWarning(100, 'The zlib extension is not available.');\n \t\t}\n \n-\t\tif (!isset($options['use_streams']) || $options['use_streams'] == false)\n+\t\tif (isset($options['use_streams']) && $options['use_streams'] != false)\n \t\t{\n-\t\t\t$this->_data = file_get_contents($archive);\n+\t\t\treturn $this->extractStream($archive, $destination, $options);\n+\t\t}\n \n-\t\t\tif (!$this->_data)\n-\t\t\t{\n-\t\t\t\tif (class_exists('JError'))\n-\t\t\t\t{\n-\t\t\t\t\treturn JError::raiseWarning(100, 'Unable to read archive');\n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\tthrow new RuntimeException('Unable to read archive');\n-\t\t\t\t}\n-\t\t\t}\n+\t\t$this->_data = file_get_contents($archive);\n \n-\t\t\t$position = $this->_getFilePosition();\n-\t\t\t$buffer = gzinflate(substr($this->_data, $position, strlen($this->_data) - $position));\n+\t\tif (!$this->_data)\n+\t\t{\n+\t\t\treturn $this->raiseWarning(100, 'Unable to read archive');\n+\t\t}\n \n-\t\t\tif (empty($buffer))\n-\t\t\t{\n-\t\t\t\tif (class_exists('JError'))\n-\t\t\t\t{\n-\t\t\t\t\treturn JError::raiseWarning(100, 'Unable to decompress data');\n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\tthrow new RuntimeException('Unable to decompress data');\n-\t\t\t\t}\n-\t\t\t}\n+\t\t$position = $this->_getFilePosition();\n+\t\t$buffer = gzinflate(substr($this->_data, $position, strlen($this->_data) - $position));\n \n-\t\t\tif (JFile::write($destination, $buffer) === false)\n-\t\t\t{\n-\t\t\t\tif (class_exists('JError'))\n-\t\t\t\t{\n-\t\t\t\t\treturn JError::raiseWarning(100, 'Unable to write archive');\n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\tthrow new RuntimeException('Unable to write archive');\n-\t\t\t\t}\n-\t\t\t}\n+\t\tif (empty($buffer))\n+\t\t{\n+\t\t\treturn $this->raiseWarning(100, 'Unable to decompress data');\n \t\t}\n-\t\telse\n+\n+\t\tif (JFile::write($destination, $buffer) === false)\n \t\t{\n-\t\t\t// New style! streams!\n-\t\t\t$input = JFactory::getStream();\n+\t\t\treturn $this->raiseWarning(100, 'Unable to write archive');\n+\t\t}\n \n-\t\t\t// Use gz\n-\t\t\t$input->set('processingmethod', 'gz');\n+\t\treturn true;\n+\t}\n \n-\t\t\tif (!$input->open($archive))\n-\t\t\t{\n-\t\t\t\tif (class_exists('JError'))\n-\t\t\t\t{\n-\t\t\t\t\treturn JError::raiseWarning(100, 'Unable to read archive (gz)');\n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\tthrow new RuntimeException('Unable to read archive (gz)');\n-\t\t\t\t}\n-\t\t\t}\n+\t/**\n+\t * Method to extract archive using stream objects\n+\t *\n+\t * @param   string  $archive      Path to ZIP archive to extract\n+\t * @param   string  $destination  Path to extract archive to\n+\t * @param   array   $options      Extraction options [unused]\n+\t *\n+\t * @return  boolean  True if successful\n+\t */\n+\tprotected function extractStream($archive, $destination, $options = array ())\n+\t{\n+\t\t// New style! streams!\n+\t\t$input = JFactory::getStream();\n \n-\t\t\t$output = JFactory::getStream();\n+\t\t// Use gz\n+\t\t$input->set('processingmethod', 'gz');\n \n-\t\t\tif (!$output->open($destination, 'w'))\n-\t\t\t{\n-\t\t\t\t$input->close();\n+\t\tif (!$input->open($archive))\n+\t\t{\n+\t\t\treturn $this->raiseWarning(100, 'Unable to read archive (gz)');\n+\t\t}\n \n-\t\t\t\tif (class_exists('JError'))\n-\t\t\t\t{\n-\t\t\t\t\treturn JError::raiseWarning(100, 'Unable to write archive (gz)');\n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\tthrow new RuntimeException('Unable to write archive (gz)');\n-\t\t\t\t}\n-\t\t\t}\n+\t\t$output = JFactory::getStream();\n \n-\t\t\tdo\n-\t\t\t{\n-\t\t\t\t$this->_data = $input->read($input->get('chunksize', 8196));\n+\t\tif (!$output->open($destination, 'w'))\n+\t\t{\n+\t\t\t$input->close();\n \n-\t\t\t\tif ($this->_data)\n+\t\t\treturn $this->raiseWarning(100, 'Unable to write archive (gz)');\n+\t\t}\n+\n+\t\tdo\n+\t\t{\n+\t\t\t$this->_data = $input->read($input->get('chunksize', 8196));\n+\n+\t\t\tif ($this->_data)","path":"libraries/joomla/archive/gzip.php","position":148,"original_position":148,"commit_id":"d0be805eaaab74174233996f7bb6438de4adef36","original_commit_id":"d0be805eaaab74174233996f7bb6438de4adef36","user":{"login":"Mathewlenning","id":3743651,"avatar_url":"https://avatars.githubusercontent.com/u/3743651?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathewlenning","html_url":"https://github.com/Mathewlenning","followers_url":"https://api.github.com/users/Mathewlenning/followers","following_url":"https://api.github.com/users/Mathewlenning/following{/other_user}","gists_url":"https://api.github.com/users/Mathewlenning/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathewlenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathewlenning/subscriptions","organizations_url":"https://api.github.com/users/Mathewlenning/orgs","repos_url":"https://api.github.com/users/Mathewlenning/repos","events_url":"https://api.github.com/users/Mathewlenning/events{/privacy}","received_events_url":"https://api.github.com/users/Mathewlenning/received_events","type":"User","site_admin":false},"body":"@wilsonge honestly I don't know, but the best way to find out is to give it a try right!  Nice catch =^D","created_at":"2015-03-19T01:24:02Z","updated_at":"2015-03-19T01:24:02Z","html_url":"https://github.com/joomla/joomla-cms/pull/6497#discussion_r26723647","pull_request_url":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497","_links":{"self":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/comments/26723647"},"html":{"href":"https://github.com/joomla/joomla-cms/pull/6497#discussion_r26723647"},"pull_request":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497"}}},"pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497","id":31455135,"html_url":"https://github.com/joomla/joomla-cms/pull/6497","diff_url":"https://github.com/joomla/joomla-cms/pull/6497.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/6497.patch","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6497","number":6497,"state":"open","locked":false,"title":"Cleaning up JArchiveGzip.","user":{"login":"Mathewlenning","id":3743651,"avatar_url":"https://avatars.githubusercontent.com/u/3743651?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathewlenning","html_url":"https://github.com/Mathewlenning","followers_url":"https://api.github.com/users/Mathewlenning/followers","following_url":"https://api.github.com/users/Mathewlenning/following{/other_user}","gists_url":"https://api.github.com/users/Mathewlenning/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathewlenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathewlenning/subscriptions","organizations_url":"https://api.github.com/users/Mathewlenning/orgs","repos_url":"https://api.github.com/users/Mathewlenning/repos","events_url":"https://api.github.com/users/Mathewlenning/events{/privacy}","received_events_url":"https://api.github.com/users/Mathewlenning/received_events","type":"User","site_admin":false},"body":"Did the same refactoring as Bzip2.\r\n1. Isolated JError into temporary method\r\n2. separated old extraction logic from streaming logic.","created_at":"2015-03-18T17:57:55Z","updated_at":"2015-03-19T01:24:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf98ab62cf1be2bf144ec6e0444ff45ce356bd0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497/commits","review_comments_url":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497/comments","review_comment_url":"https://api.github.com/repos/joomla/joomla-cms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6497/comments","statuses_url":"https://api.github.com/repos/joomla/joomla-cms/statuses/d0be805eaaab74174233996f7bb6438de4adef36","head":{"label":"Mathewlenning:CLEANING-JArchiveGzip","ref":"CLEANING-JArchiveGzip","sha":"d0be805eaaab74174233996f7bb6438de4adef36","user":{"login":"Mathewlenning","id":3743651,"avatar_url":"https://avatars.githubusercontent.com/u/3743651?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathewlenning","html_url":"https://github.com/Mathewlenning","followers_url":"https://api.github.com/users/Mathewlenning/followers","following_url":"https://api.github.com/users/Mathewlenning/following{/other_user}","gists_url":"https://api.github.com/users/Mathewlenning/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathewlenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathewlenning/subscriptions","organizations_url":"https://api.github.com/users/Mathewlenning/orgs","repos_url":"https://api.github.com/users/Mathewlenning/repos","events_url":"https://api.github.com/users/Mathewlenning/events{/privacy}","received_events_url":"https://api.github.com/users/Mathewlenning/received_events","type":"User","site_admin":false},"repo":{"id":30701297,"name":"joomla-cms","full_name":"Mathewlenning/joomla-cms","owner":{"login":"Mathewlenning","id":3743651,"avatar_url":"https://avatars.githubusercontent.com/u/3743651?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathewlenning","html_url":"https://github.com/Mathewlenning","followers_url":"https://api.github.com/users/Mathewlenning/followers","following_url":"https://api.github.com/users/Mathewlenning/following{/other_user}","gists_url":"https://api.github.com/users/Mathewlenning/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathewlenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathewlenning/subscriptions","organizations_url":"https://api.github.com/users/Mathewlenning/orgs","repos_url":"https://api.github.com/users/Mathewlenning/repos","events_url":"https://api.github.com/users/Mathewlenning/events{/privacy}","received_events_url":"https://api.github.com/users/Mathewlenning/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mathewlenning/joomla-cms","description":"Home of the Joomla! Content Management System","fork":true,"url":"https://api.github.com/repos/Mathewlenning/joomla-cms","forks_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/forks","keys_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/teams","hooks_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/hooks","issue_events_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/issues/events{/number}","events_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/events","assignees_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/assignees{/user}","branches_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/branches{/branch}","tags_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/tags","blobs_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/statuses/{sha}","languages_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/languages","stargazers_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/stargazers","contributors_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/contributors","subscribers_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/subscribers","subscription_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/subscription","commits_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/contents/{+path}","compare_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/merges","archive_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/downloads","issues_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/issues{/number}","pulls_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/pulls{/number}","milestones_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/milestones{/number}","notifications_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/labels{/name}","releases_url":"https://api.github.com/repos/Mathewlenning/joomla-cms/releases{/id}","created_at":"2015-02-12T12:25:22Z","updated_at":"2015-02-12T12:25:36Z","pushed_at":"2015-03-19T01:20:39Z","git_url":"git://github.com/Mathewlenning/joomla-cms.git","ssh_url":"git@github.com:Mathewlenning/joomla-cms.git","clone_url":"https://github.com/Mathewlenning/joomla-cms.git","svn_url":"https://github.com/Mathewlenning/joomla-cms","homepage":"http://joomla.org","size":123620,"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":"staging"}},"base":{"label":"joomla:staging","ref":"staging","sha":"3fb7aeb45cb3f75a85e0d8d30110c6d4148e54bb","user":{"login":"joomla","id":751633,"avatar_url":"https://avatars.githubusercontent.com/u/751633?v=3","gravatar_id":"","url":"https://api.github.com/users/joomla","html_url":"https://github.com/joomla","followers_url":"https://api.github.com/users/joomla/followers","following_url":"https://api.github.com/users/joomla/following{/other_user}","gists_url":"https://api.github.com/users/joomla/gists{/gist_id}","starred_url":"https://api.github.com/users/joomla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joomla/subscriptions","organizations_url":"https://api.github.com/users/joomla/orgs","repos_url":"https://api.github.com/users/joomla/repos","events_url":"https://api.github.com/users/joomla/events{/privacy}","received_events_url":"https://api.github.com/users/joomla/received_events","type":"Organization","site_admin":false},"repo":{"id":2464908,"name":"joomla-cms","full_name":"joomla/joomla-cms","owner":{"login":"joomla","id":751633,"avatar_url":"https://avatars.githubusercontent.com/u/751633?v=3","gravatar_id":"","url":"https://api.github.com/users/joomla","html_url":"https://github.com/joomla","followers_url":"https://api.github.com/users/joomla/followers","following_url":"https://api.github.com/users/joomla/following{/other_user}","gists_url":"https://api.github.com/users/joomla/gists{/gist_id}","starred_url":"https://api.github.com/users/joomla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joomla/subscriptions","organizations_url":"https://api.github.com/users/joomla/orgs","repos_url":"https://api.github.com/users/joomla/repos","events_url":"https://api.github.com/users/joomla/events{/privacy}","received_events_url":"https://api.github.com/users/joomla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joomla/joomla-cms","description":"Home of the Joomla! Content Management System","fork":false,"url":"https://api.github.com/repos/joomla/joomla-cms","forks_url":"https://api.github.com/repos/joomla/joomla-cms/forks","keys_url":"https://api.github.com/repos/joomla/joomla-cms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joomla/joomla-cms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joomla/joomla-cms/teams","hooks_url":"https://api.github.com/repos/joomla/joomla-cms/hooks","issue_events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/events{/number}","events_url":"https://api.github.com/repos/joomla/joomla-cms/events","assignees_url":"https://api.github.com/repos/joomla/joomla-cms/assignees{/user}","branches_url":"https://api.github.com/repos/joomla/joomla-cms/branches{/branch}","tags_url":"https://api.github.com/repos/joomla/joomla-cms/tags","blobs_url":"https://api.github.com/repos/joomla/joomla-cms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joomla/joomla-cms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joomla/joomla-cms/git/refs{/sha}","trees_url":"https://api.github.com/repos/joomla/joomla-cms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joomla/joomla-cms/statuses/{sha}","languages_url":"https://api.github.com/repos/joomla/joomla-cms/languages","stargazers_url":"https://api.github.com/repos/joomla/joomla-cms/stargazers","contributors_url":"https://api.github.com/repos/joomla/joomla-cms/contributors","subscribers_url":"https://api.github.com/repos/joomla/joomla-cms/subscribers","subscription_url":"https://api.github.com/repos/joomla/joomla-cms/subscription","commits_url":"https://api.github.com/repos/joomla/joomla-cms/commits{/sha}","git_commits_url":"https://api.github.com/repos/joomla/joomla-cms/git/commits{/sha}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/comments{/number}","issue_comment_url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments{/number}","contents_url":"https://api.github.com/repos/joomla/joomla-cms/contents/{+path}","compare_url":"https://api.github.com/repos/joomla/joomla-cms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joomla/joomla-cms/merges","archive_url":"https://api.github.com/repos/joomla/joomla-cms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joomla/joomla-cms/downloads","issues_url":"https://api.github.com/repos/joomla/joomla-cms/issues{/number}","pulls_url":"https://api.github.com/repos/joomla/joomla-cms/pulls{/number}","milestones_url":"https://api.github.com/repos/joomla/joomla-cms/milestones{/number}","notifications_url":"https://api.github.com/repos/joomla/joomla-cms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joomla/joomla-cms/labels{/name}","releases_url":"https://api.github.com/repos/joomla/joomla-cms/releases{/id}","created_at":"2011-09-27T02:07:38Z","updated_at":"2015-03-18T13:57:56Z","pushed_at":"2015-03-18T14:20:36Z","git_url":"git://github.com/joomla/joomla-cms.git","ssh_url":"git@github.com:joomla/joomla-cms.git","clone_url":"https://github.com/joomla/joomla-cms.git","svn_url":"https://github.com/joomla/joomla-cms","homepage":"http://joomla.org","size":320621,"stargazers_count":1482,"watchers_count":1482,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1651,"mirror_url":null,"open_issues_count":541,"forks":1651,"open_issues":541,"watchers":1482,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497"},"html":{"href":"https://github.com/joomla/joomla-cms/pull/6497"},"issue":{"href":"https://api.github.com/repos/joomla/joomla-cms/issues/6497"},"comments":{"href":"https://api.github.com/repos/joomla/joomla-cms/issues/6497/comments"},"review_comments":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497/comments"},"review_comment":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joomla/joomla-cms/pulls/6497/commits"},"statuses":{"href":"https://api.github.com/repos/joomla/joomla-cms/statuses/d0be805eaaab74174233996f7bb6438de4adef36"}}}}