diff --git a/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php b/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php index a7a4fbf..07097e0 100644 --- a/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php +++ b/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php @@ -15,7 +15,7 @@ use PatchTester\Model\PullModel; * * @since 2.0 */ -class ApplyController extends \JControllerBase +class ApplyController extends DisplayController { /** * Execute the controller. @@ -29,6 +29,10 @@ class ApplyController extends \JControllerBase try { $model = new PullModel; + + // Initialize the state for the model + $model->setState($this->initializeState($model)); + $model->apply($this->getInput()->getUint('pull_id')); $msg = \JText::_('COM_PATCHTESTER_APPLY_OK'); diff --git a/administrator/components/com_patchtester/PatchTester/Controller/RevertController.php b/administrator/components/com_patchtester/PatchTester/Controller/RevertController.php index f407c8c..b865c80 100644 --- a/administrator/components/com_patchtester/PatchTester/Controller/RevertController.php +++ b/administrator/components/com_patchtester/PatchTester/Controller/RevertController.php @@ -15,7 +15,7 @@ use PatchTester\Model\PullModel; * * @since 2.0 */ -class RevertController extends \JControllerBase +class RevertController extends DisplayController { /** * Execute the controller. @@ -29,6 +29,10 @@ class RevertController extends \JControllerBase try { $model = new PullModel; + + // Initialize the state for the model + $model->setState($this->initializeState($model)); + $model->revert($this->getInput()->getUint('pull_id')); $msg = \JText::_('COM_PATCHTESTER_APPLY_OK'); diff --git a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php index ebf641b..254b1ac 100644 --- a/administrator/components/com_patchtester/PatchTester/Model/PullModel.php +++ b/administrator/components/com_patchtester/PatchTester/Model/PullModel.php @@ -27,25 +27,6 @@ class PullModel extends \JModelBase */ protected $nonProductionFolders = array('build', 'docs', 'installation', 'tests'); - /** - * Method to auto-populate the model state. - * - * @return void - * - * @note Calling getState() in this method will result in recursion. - * @since 2.0 - */ - protected function populateState() - { - // Load the parameters. - $params = JComponentHelper::getParams('com_patchtester'); - $this->setState('params', $params); - $this->setState('github_user', $params->get('org', 'joomla')); - $this->setState('github_repo', $params->get('repo', 'joomla-cms')); - - parent::populateState(); - } - /** * Method to parse a patch and extract the affected files * @@ -149,7 +130,7 @@ class PullModel extends \JModelBase // Only act if there are API hits remaining if ($github->authorization->getRateLimit()->rate->remaining > 0) { - $pull = $github->pulls->get($this->getState('github_user'), $this->getState('github_repo'), $id); + $pull = $github->pulls->get($this->getState()->get('github_user'), $this->getState()->get('github_repo'), $id); if (is_null($pull->head->repo)) { @@ -203,7 +184,7 @@ class PullModel extends \JModelBase throw new \RuntimeException(sprintf(\JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old)); } - $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . $pull->head->ref . '/' . $file->new; + $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; } diff --git a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php index 9001f39..2f8c411 100644 --- a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php @@ -45,9 +45,9 @@ foreach ($this->items as $i => $item) :