diff --git a/administrator/components/com_patchtester/controllers/pulls.php b/administrator/components/com_patchtester/controllers/pulls.php index ccfa51f..a7aafbd 100644 --- a/administrator/components/com_patchtester/controllers/pulls.php +++ b/administrator/components/com_patchtester/controllers/pulls.php @@ -14,7 +14,7 @@ defined('_JEXEC') or die; * @package PatchTester * @since 2.0 */ -class PatchtesterControllerPull extends JControllerLegacy +class PatchtesterControllerPulls extends JControllerLegacy { /** * Fetch pull request data from GitHub 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 fa0e95d..a2b4a87 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,8 @@ 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_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" COM_PATCHTESTER_FETCH_SUCCESSFUL="Successfully retrieved pull requests." COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL="GitHub Account Password" diff --git a/administrator/components/com_patchtester/models/pulls.php b/administrator/components/com_patchtester/models/pulls.php index 7918f62..f522bd2 100644 --- a/administrator/components/com_patchtester/models/pulls.php +++ b/administrator/components/com_patchtester/models/pulls.php @@ -192,10 +192,42 @@ class PatchtesterModelPulls extends JModelList // If over the API limit, we can't build this list if ($this->rate->remaining > 0) { - $db = $this->getDbo(); - $pulls = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open'); + // Sanity check, ensure there aren't any applied patches + if (count($this->getAppliedPatches()) >= 1) + { + throw new RuntimeException(JText::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES')); + } - foreach ($pulls as $i => &$pull) + $pulls = array(); + $page = 0; + + do + { + $page++; + + try + { + $items = $this->github->pulls->getList($this->getState('github_user'), $this->getState('github_repo'), 'open', $page, 100); + } + catch (DomainException $e) + { + throw new RuntimeException(JText::sprintf('COM_PATCHTESTER_ERROR_GITHUB_FETCH', $e->getMessage())); + } + + $count = is_array($items) ? count($items) : 0; + + if ($count) + { + $pulls = array_merge($pulls, $items); + } + + } + while ($count); + + // Dump the old data now + $this->getDbo()->truncateTable('#__patchtester_pulls'); + + foreach ($pulls as &$pull) { // Build the data object to store in the database $data = new stdClass; @@ -230,7 +262,7 @@ class PatchtesterModelPulls extends JModelList try { - $db->insertObject('#__patchtester_pulls', $data, 'id'); + $this->getDbo()->insertObject('#__patchtester_pulls', $data, 'id'); } catch (RuntimeException $e) { diff --git a/administrator/components/com_patchtester/views/pulls/tmpl/default.php b/administrator/components/com_patchtester/views/pulls/tmpl/default.php index 3646727..83d64b3 100644 --- a/administrator/components/com_patchtester/views/pulls/tmpl/default.php +++ b/administrator/components/com_patchtester/views/pulls/tmpl/default.php @@ -106,9 +106,9 @@ else : items)) : echo $this->loadTemplate('items'); - else : - echo JText::_('COM_PATCHTESTER_NO_ITEMS'); - endif; ?> + else : ?> + + pagination->getListFooter(); ?> diff --git a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php index f9013bd..9cd58fc 100644 --- a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php @@ -41,15 +41,9 @@ foreach ($this->items as $i => $item) : joomlacode_id) : $title = ' title="Open link::' . JText::_('COM_PATCHTESTER_OPEN_IN_JOOMLACODE') . '"'; - if (is_int($item->joomlacode_id)) : echo ''; echo '[#' . $item->joomlacode_id . ']'; - else : - echo ''; - echo '[#joomlacode]'; - endif; endif; ?>