Fixed issues using JHttp

This commit is contained in:
Ian MacLennan 2011-10-11 12:04:33 -04:00
parent d973d114e7
commit 59ff677545
3 changed files with 10 additions and 6 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -171,7 +171,6 @@ class JGithub
$response->code = $request_data['http_code'];
curl_close($this->http);
return $response;
}
}