mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-02-02 11:58:26 +00:00
Fixed issues using JHttp
This commit is contained in:
parent
d973d114e7
commit
59ff677545
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -171,7 +171,6 @@ class JGithub
|
||||
$response->code = $request_data['http_code'];
|
||||
|
||||
curl_close($this->http);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user