mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-02-13 09:18:49 +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'))) {
|
if ($model->apply(JRequest::getVar('pull_id'))) {
|
||||||
$msg = 'Patch successfully applied';
|
$msg = 'Patch successfully applied';
|
||||||
} else {
|
} else {
|
||||||
$msg = 'Patch did not apply';
|
$msg = $model->getError();
|
||||||
}
|
}
|
||||||
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg);
|
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg);
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,21 @@ class PatchtesterModelPull extends JModel
|
|||||||
|
|
||||||
foreach ($files AS $file)
|
foreach ($files AS $file)
|
||||||
{
|
{
|
||||||
|
$http = new JHttp;
|
||||||
// we only create a backup if the file already exists
|
// we only create a backup if the file already exists
|
||||||
if (file_exists(JPATH_ROOT . '/' . $file)) {
|
if (file_exists(JPATH_ROOT . '/' . $file)) {
|
||||||
JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file), JPATH_COMPONENT . '/backups/' . md5($file) . '.txt');
|
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 . '/' .
|
$url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' .
|
||||||
$pull->head->ref . $file;
|
$pull->head->ref . '/' . $file;
|
||||||
|
try {
|
||||||
$newFile = $http->get($url);
|
$newFile = $http->get($url);
|
||||||
JFile::write(JPath::clean(JPATH_ROOT . '/' . $file), $newFile->body);
|
JFile::write(JPath::clean(JPATH_ROOT . '/' . $file), $newFile->body);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
echo $url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$table->pull_id = $pull->number;
|
$table->pull_id = $pull->number;
|
||||||
$table->data = json_encode($files);
|
$table->data = json_encode($files);
|
||||||
|
@ -171,7 +171,6 @@ class JGithub
|
|||||||
$response->code = $request_data['http_code'];
|
$response->code = $request_data['http_code'];
|
||||||
|
|
||||||
curl_close($this->http);
|
curl_close($this->http);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user