From 59ff677545bb5ee6065e2655f429effae80485cd Mon Sep 17 00:00:00 2001 From: Ian MacLennan Date: Tue, 11 Oct 2011 12:04:33 -0400 Subject: [PATCH] Fixed issues using JHttp --- .../components/com_patchtester/controllers/pull.php | 2 +- .../components/com_patchtester/models/pull.php | 13 +++++++++---- libraries/joomla/client/github.php | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_patchtester/controllers/pull.php b/administrator/components/com_patchtester/controllers/pull.php index 442c245..78d6d2b 100644 --- a/administrator/components/com_patchtester/controllers/pull.php +++ b/administrator/components/com_patchtester/controllers/pull.php @@ -23,7 +23,7 @@ class PatchtesterControllerPull extends JController if ($model->apply(JRequest::getVar('pull_id'))) { $msg = 'Patch successfully applied'; } else { - $msg = 'Patch did not apply'; + $msg = $model->getError(); } $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg); } diff --git a/administrator/components/com_patchtester/models/pull.php b/administrator/components/com_patchtester/models/pull.php index 4666a1c..dacac87 100644 --- a/administrator/components/com_patchtester/models/pull.php +++ b/administrator/components/com_patchtester/models/pull.php @@ -75,16 +75,21 @@ class PatchtesterModelPull extends JModel foreach ($files AS $file) { + $http = new JHttp; // we only create a backup if the file already exists if (file_exists(JPATH_ROOT . '/' . $file)) { JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file), JPATH_COMPONENT . '/backups/' . md5($file) . '.txt'); } $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . - $pull->head->ref . $file; - $newFile = $http->get($url); - JFile::write(JPath::clean(JPATH_ROOT . '/' . $file), $newFile->body); - + $pull->head->ref . '/' . $file; + try { + $newFile = $http->get($url); + JFile::write(JPath::clean(JPATH_ROOT . '/' . $file), $newFile->body); + } catch (Exception $e) { + echo $e->getMessage(); + echo $url; + } } $table->pull_id = $pull->number; $table->data = json_encode($files); diff --git a/libraries/joomla/client/github.php b/libraries/joomla/client/github.php index e4d76ca..5e65e86 100755 --- a/libraries/joomla/client/github.php +++ b/libraries/joomla/client/github.php @@ -171,7 +171,6 @@ class JGithub $response->code = $request_data['http_code']; curl_close($this->http); - return $response; } }