diff --git a/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php b/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php index ce7f15c..00ae2db 100644 --- a/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php +++ b/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php @@ -35,7 +35,7 @@ class ApplyController extends DisplayController if ($model->apply($this->getInput()->getUint('pull_id'))) { - $msg = \JText::_('COM_PATCHTESTER_APPLY_OK'); + $msg = \JText::_('COM_PATCHTESTER_APPLY_OK'); } else { diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php index 2a57012..c6fc3bd 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php @@ -142,7 +142,14 @@ class PullModel extends \JModelBase ); } - $pull = $github->pulls->get($this->getState()->get('github_user'), $this->getState()->get('github_repo'), $id); + try + { + $pull = $github->pulls->get($this->getState()->get('github_user'), $this->getState()->get('github_repo'), $id); + } + catch (\Exception $e) + { + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage())); + } if (is_null($pull->head->repo)) { @@ -164,7 +171,14 @@ class PullModel extends \JModelBase $transport = new \JHttp($options, $driver); - $patch = $transport->get($pull->diff_url)->body; + try + { + $patch = $transport->get($pull->diff_url)->body; + } + catch (\Exception $e) + { + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage())); + } $files = $this->parsePatch($patch); @@ -177,7 +191,7 @@ class PullModel extends \JModelBase { if ($file->action == 'deleted' && !file_exists(JPATH_ROOT . '/' . $file->old)) { - throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S'), $file->old)); + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S', $file->old)); } if ($file->action == 'added' || $file->action == 'modified') @@ -185,18 +199,25 @@ class PullModel extends \JModelBase // If the backup file already exists, we can't apply the patch if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->new) . '.txt')) { - throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_CONFLICT_S'), $file->new)); + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_CONFLICT_S', $file->new)); } if ($file->action == 'modified' && !file_exists(JPATH_ROOT . '/' . $file->old)) { - throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old)); + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S', $file->old)); } $url = 'https://raw.github.com/' . urlencode($pull->head->user->login) . '/' . urlencode($pull->head->repo->name) . '/' . urlencode($pull->head->ref) . '/' . $file->new; - $file->body = $transport->get($url)->body; + try + { + $file->body = $transport->get($url)->body; + } + catch (\Exception $e) + { + throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage())); + } } } diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index c54a275..7b77c51 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -13,6 +13,7 @@ COM_PATCHTESTER_COMPONENT_DESC="Joomla! Patch Tester Configuration Values" COM_PATCHTESTER_COMPONENT_LABEL="Joomla! Patch Tester" COM_PATCHTESTER_CONFIGURATION="Joomla! Patch Tester Settings" COM_PATCHTESTER_CONFLICT_S="The patch could not be applied because it conflicts with a previously applied patch: %s" +COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB="Could not connect to GitHub with the following error: %s" COM_PATCHTESTER_ERROR_APPLIED_PATCHES="Cannot fetch data from GitHub while there are applied patches. Please revert those patches before continuing." COM_PATCHTESTER_ERROR_GITHUB_FETCH="Error retrieving pull requests from GitHub: %s" COM_PATCHTESTER_ERROR_INSERT_DATABASE="Error inserting pull request data into the database: %s"