mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-22 10:58:58 +00:00
Merge pull request #348 from joomla-extensions/psr12
Switching to PSR-12 and updating composer dependencies
This commit is contained in:
commit
3cfdc66072
15
.drone.yml
15
.drone.yml
@ -3,11 +3,13 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
clone:
|
||||
depth: 42
|
||||
|
||||
steps:
|
||||
- name: composer
|
||||
image: joomlaprojects/docker-tools:develop
|
||||
image: joomlaprojects/docker-images:php7.4
|
||||
volumes:
|
||||
- name: composer-cache
|
||||
path: /tmp/composer-cache
|
||||
commands:
|
||||
- composer validate --no-check-all --strict
|
||||
- composer install --no-progress --no-suggest
|
||||
@ -16,10 +18,15 @@ steps:
|
||||
image: joomlaprojects/docker-images:php7.2
|
||||
commands:
|
||||
- echo $(date)
|
||||
- ./administrator/components/com_patchtester/vendor/bin/phpcs --extensions=php -p --ignore=administrator/components/com_patchtester/vendor --standard=administrator/components/com_patchtester/vendor/joomla/cms-coding-standards/lib/Joomla-CMS administrator
|
||||
- ./administrator/components/com_patchtester/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .
|
||||
- echo $(date)
|
||||
|
||||
volumes:
|
||||
- name: composer-cache
|
||||
host:
|
||||
path: /tmp/composer-cache
|
||||
---
|
||||
kind: signature
|
||||
hmac: c5899584898d37d46fb70cb22487532d41719c7a836be7f67ad4ac3c2267dafa
|
||||
hmac: 6894a15e535673bd3eb1cf2c8ee3f9cbac4b5a6e52aa26773add3e4943f3bd86
|
||||
|
||||
...
|
||||
|
20
.editorconfig
Normal file
20
.editorconfig
Normal file
@ -0,0 +1,20 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style end of lines and a blank line at the end of the file
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{js,json,scss,css,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -21,88 +22,81 @@ use PatchTester\Model\AbstractModel;
|
||||
*/
|
||||
abstract class AbstractController
|
||||
{
|
||||
/**
|
||||
* The active application
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $app;
|
||||
/**
|
||||
* The active application
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $app;
|
||||
/**
|
||||
* The object context
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $context;
|
||||
/**
|
||||
* The default view to display
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $defaultView = 'pulls';
|
||||
/**
|
||||
* Instantiate the controller
|
||||
*
|
||||
* @param CMSApplication $app The application object.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function __construct(CMSApplication $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
// Set the context for the controller
|
||||
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
|
||||
}
|
||||
|
||||
/**
|
||||
* The object context
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $context;
|
||||
/**
|
||||
* Get the application object.
|
||||
*
|
||||
* @return CMSApplication
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default view to display
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $defaultView = 'pulls';
|
||||
/**
|
||||
* Get the input object.
|
||||
*
|
||||
* @return Input
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->app->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the controller
|
||||
*
|
||||
* @param CMSApplication $app The application object.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function __construct(CMSApplication $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
// Set the context for the controller
|
||||
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application object.
|
||||
*
|
||||
* @return CMSApplication
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input object.
|
||||
*
|
||||
* @return Input
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->app->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state for the model object
|
||||
*
|
||||
* @param AbstractModel $model Model object
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function initializeState($model)
|
||||
{
|
||||
$state = new Registry;
|
||||
|
||||
// Load the parameters.
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
|
||||
$state->set('github_user', $params->get('org', 'joomla'));
|
||||
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
|
||||
|
||||
return $state;
|
||||
}
|
||||
/**
|
||||
* Sets the state for the model object
|
||||
*
|
||||
* @param AbstractModel $model Model object
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function initializeState($model)
|
||||
{
|
||||
$state = new Registry();
|
||||
// Load the parameters.
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
$state->set('github_user', $params->get('org', 'joomla'));
|
||||
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -13,6 +14,11 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use PatchTester\Model\PullModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
|
||||
/**
|
||||
* Controller class to apply patches
|
||||
*
|
||||
@ -20,40 +26,32 @@ use PatchTester\Model\PullModel;
|
||||
*/
|
||||
class ApplyController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
$model = new PullModel(null, Factory::getDbo());
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$model = new PullModel(null, Factory::getDbo());
|
||||
// Initialize the state for the model
|
||||
$model->setState($this->initializeState($model));
|
||||
if ($model->apply($this->getInput()->getUint('pull_id'))) {
|
||||
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
|
||||
} else {
|
||||
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
|
||||
}
|
||||
|
||||
// Initialize the state for the model
|
||||
$model->setState($this->initializeState($model));
|
||||
$type = 'message';
|
||||
} catch (\Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
if ($model->apply($this->getInput()->getUint('pull_id')))
|
||||
{
|
||||
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
|
||||
}
|
||||
|
||||
$type = 'message';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$msg = $e->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -13,6 +14,11 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\Registry\Registry;
|
||||
use PatchTester\Model\AbstractModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
|
||||
/**
|
||||
* Default display controller
|
||||
*
|
||||
@ -20,138 +26,110 @@ use PatchTester\Model\AbstractModel;
|
||||
*/
|
||||
class DisplayController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Default ordering value
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $defaultFullOrdering = 'a.pull_id DESC';
|
||||
/**
|
||||
* Default ordering value
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $defaultFullOrdering = 'a.pull_id DESC';
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// Set up variables to build our classes
|
||||
$view = $this->getInput()->getCmd('view', $this->defaultView);
|
||||
$format = $this->getInput()->getCmd('format', 'html');
|
||||
// Register the layout paths for the view
|
||||
$paths = new \SplPriorityQueue();
|
||||
// Add the path for template overrides
|
||||
$paths->insert(JPATH_THEMES . '/' . $this->getApplication()->getTemplate() . '/html/com_patchtester/' . $view, 2);
|
||||
// Add the path for the default layouts
|
||||
$paths->insert(dirname(__DIR__) . '/View/' . ucfirst($view) . '/tmpl', 1);
|
||||
// Build the class names for the model and view
|
||||
$viewClass = '\\PatchTester\\View\\' . ucfirst($view) . '\\' . ucfirst($view) . ucfirst($format) . 'View';
|
||||
$modelClass = '\\PatchTester\\Model\\' . ucfirst($view) . 'Model';
|
||||
// Sanity check - Ensure our classes exist
|
||||
if (!class_exists($viewClass)) {
|
||||
// Try to use a default view
|
||||
$viewClass = '\\PatchTester\\View\\Default' . ucfirst($format) . 'View';
|
||||
if (!class_exists($viewClass)) {
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_VIEW_NOT_FOUND', $view, $format), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return boolean True on success
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// Set up variables to build our classes
|
||||
$view = $this->getInput()->getCmd('view', $this->defaultView);
|
||||
$format = $this->getInput()->getCmd('format', 'html');
|
||||
if (!class_exists($modelClass)) {
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_MODEL_NOT_FOUND', $modelClass), 500);
|
||||
}
|
||||
|
||||
// Register the layout paths for the view
|
||||
$paths = new \SplPriorityQueue;
|
||||
// Initialize the model class now; need to do it before setting the state to get required data from it
|
||||
$model = new $modelClass($this->context, null, Factory::getDbo());
|
||||
// Initialize the state for the model
|
||||
$state = $this->initializeState($model);
|
||||
foreach ($state as $key => $value) {
|
||||
$model->setState($key, $value);
|
||||
}
|
||||
|
||||
// Add the path for template overrides
|
||||
$paths->insert(JPATH_THEMES . '/' . $this->getApplication()->getTemplate() . '/html/com_patchtester/' . $view, 2);
|
||||
// Initialize the view class now
|
||||
$view = new $viewClass($model, $paths);
|
||||
// Echo the rendered view for the application
|
||||
echo $view->render();
|
||||
// Finished!
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the path for the default layouts
|
||||
$paths->insert(dirname(__DIR__) . '/View/' . ucfirst($view) . '/tmpl', 1);
|
||||
/**
|
||||
* Sets the state for the model object
|
||||
*
|
||||
* @param AbstractModel $model Model object
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function initializeState($model)
|
||||
{
|
||||
$state = parent::initializeState($model);
|
||||
$app = $this->getApplication();
|
||||
// Load the filter state.
|
||||
$state->set('filter.search', $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''));
|
||||
$state->set('filter.applied', $app->getUserStateFromRequest($this->context . '.filter.applied', 'filter_applied', ''));
|
||||
$state->set('filter.branch', $app->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', ''));
|
||||
$state->set('filter.rtc', $app->getUserStateFromRequest($this->context . '.filter.rtc', 'filter_rtc', ''));
|
||||
$state->set('filter.npm', $app->getUserStateFromRequest($this->context . '.filter.npm', 'filter_npm', ''));
|
||||
$state->set('filter.label', $app->getUserStateFromRequest($this->context . '.filter.label', 'filter_label', ''));
|
||||
// Pre-fill the limits.
|
||||
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->input->get('list_limit', 20), 'uint');
|
||||
$state->set('list.limit', $limit);
|
||||
$fullOrdering = $app->getUserStateFromRequest($this->context . '.fullorder', 'list_fullordering', $this->defaultFullOrdering);
|
||||
$orderingParts = explode(' ', $fullOrdering);
|
||||
if (count($orderingParts) !== 2) {
|
||||
$fullOrdering = $this->defaultFullOrdering;
|
||||
$orderingParts = explode(' ', $fullOrdering);
|
||||
}
|
||||
|
||||
// Build the class names for the model and view
|
||||
$viewClass = '\\PatchTester\\View\\' . ucfirst($view) . '\\' . ucfirst($view) . ucfirst($format) . 'View';
|
||||
$modelClass = '\\PatchTester\\Model\\' . ucfirst($view) . 'Model';
|
||||
$state->set('list.fullordering', $fullOrdering);
|
||||
// The 2nd part will be considered the direction
|
||||
$direction = $orderingParts[array_key_last($orderingParts)];
|
||||
if (in_array(strtoupper($direction), ['ASC', 'DESC', ''])) {
|
||||
$state->set('list.direction', $direction);
|
||||
}
|
||||
|
||||
// Sanity check - Ensure our classes exist
|
||||
if (!class_exists($viewClass))
|
||||
{
|
||||
// Try to use a default view
|
||||
$viewClass = '\\PatchTester\\View\\Default' . ucfirst($format) . 'View';
|
||||
// The 1st part will be the ordering
|
||||
$ordering = $orderingParts[array_key_first($orderingParts)];
|
||||
if (in_array($ordering, $model->getSortFields())) {
|
||||
$state->set('list.ordering', $ordering);
|
||||
}
|
||||
|
||||
if (!class_exists($viewClass))
|
||||
{
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_VIEW_NOT_FOUND', $view, $format), 500);
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($modelClass))
|
||||
{
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_MODEL_NOT_FOUND', $modelClass), 500);
|
||||
}
|
||||
|
||||
// Initialize the model class now; need to do it before setting the state to get required data from it
|
||||
$model = new $modelClass($this->context, null, Factory::getDbo());
|
||||
|
||||
// Initialize the state for the model
|
||||
$state = $this->initializeState($model);
|
||||
|
||||
foreach ($state as $key => $value)
|
||||
{
|
||||
$model->setState($key, $value);
|
||||
}
|
||||
|
||||
// Initialize the view class now
|
||||
$view = new $viewClass($model, $paths);
|
||||
|
||||
// Echo the rendered view for the application
|
||||
echo $view->render();
|
||||
|
||||
// Finished!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state for the model object
|
||||
*
|
||||
* @param AbstractModel $model Model object
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function initializeState($model)
|
||||
{
|
||||
$state = parent::initializeState($model);
|
||||
$app = $this->getApplication();
|
||||
|
||||
// Load the filter state.
|
||||
$state->set('filter.search', $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', ''));
|
||||
$state->set('filter.applied', $app->getUserStateFromRequest($this->context . '.filter.applied', 'filter_applied', ''));
|
||||
$state->set('filter.branch', $app->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', ''));
|
||||
$state->set('filter.rtc', $app->getUserStateFromRequest($this->context . '.filter.rtc', 'filter_rtc', ''));
|
||||
$state->set('filter.npm', $app->getUserStateFromRequest($this->context . '.filter.npm', 'filter_npm', ''));
|
||||
$state->set('filter.label', $app->getUserStateFromRequest($this->context . '.filter.label', 'filter_label', ''));
|
||||
|
||||
// Pre-fill the limits.
|
||||
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->input->get('list_limit', 20), 'uint');
|
||||
$state->set('list.limit', $limit);
|
||||
|
||||
$fullOrdering = $app->getUserStateFromRequest($this->context . '.fullorder', 'list_fullordering', $this->defaultFullOrdering);
|
||||
|
||||
$orderingParts = explode(' ', $fullOrdering);
|
||||
|
||||
if (count($orderingParts) !== 2)
|
||||
{
|
||||
$fullOrdering = $this->defaultFullOrdering;
|
||||
|
||||
$orderingParts = explode(' ', $fullOrdering);
|
||||
}
|
||||
|
||||
$state->set('list.fullordering', $fullOrdering);
|
||||
|
||||
// The 2nd part will be considered the direction
|
||||
$direction = $orderingParts[array_key_last($orderingParts)];
|
||||
|
||||
if (in_array(strtoupper($direction), ['ASC', 'DESC', '']))
|
||||
{
|
||||
$state->set('list.direction', $direction);
|
||||
}
|
||||
|
||||
// The 1st part will be the ordering
|
||||
$ordering = $orderingParts[array_key_first($orderingParts)];
|
||||
|
||||
if (in_array($ordering, $model->getSortFields()))
|
||||
{
|
||||
$state->set('list.ordering', $ordering);
|
||||
}
|
||||
|
||||
$value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0);
|
||||
$limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0);
|
||||
$state->set('list.start', $limitstart);
|
||||
|
||||
return $state;
|
||||
}
|
||||
$value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0);
|
||||
$limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0);
|
||||
$state->set('list.start', $limitstart);
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -13,6 +14,10 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Response\JsonResponse;
|
||||
use PatchTester\Model\PullsModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Controller class to fetch remote data
|
||||
*
|
||||
@ -20,84 +25,66 @@ use PatchTester\Model\PullsModel;
|
||||
*/
|
||||
class FetchController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// We don't want this request to be cached.
|
||||
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
|
||||
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
|
||||
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
|
||||
$this->getApplication()->setHeader('Pragma', 'no-cache');
|
||||
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// We don't want this request to be cached.
|
||||
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
|
||||
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
|
||||
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
|
||||
$this->getApplication()->setHeader('Pragma', 'no-cache');
|
||||
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
|
||||
$session = Factory::getSession();
|
||||
try {
|
||||
// Fetch our page from the session
|
||||
$page = $session->get('com_patchtester_fetcher_page', 1);
|
||||
$model = new PullsModel();
|
||||
// Initialize the state for the model
|
||||
$state = $this->initializeState($model);
|
||||
foreach ($state as $key => $value) {
|
||||
$model->setState($key, $value);
|
||||
}
|
||||
|
||||
$session = Factory::getSession();
|
||||
$status = $model->requestFromGithub($page);
|
||||
} catch (\Exception $e) {
|
||||
$response = new JsonResponse($e);
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Fetch our page from the session
|
||||
$page = $session->get('com_patchtester_fetcher_page', 1);
|
||||
// Store the last page to the session if given one
|
||||
if (isset($status['lastPage']) && $status['lastPage'] !== false) {
|
||||
$session->set('com_patchtester_fetcher_last_page', $status['lastPage']);
|
||||
}
|
||||
|
||||
$model = new PullsModel;
|
||||
// Update the UI and session now
|
||||
if ($status['complete'] || $page === $session->get('com_patchtester_fetcher_last_page', false)) {
|
||||
$status['complete'] = true;
|
||||
$status['header'] = Text::_('COM_PATCHTESTER_FETCH_SUCCESSFUL', true);
|
||||
$message = Text::_('COM_PATCHTESTER_FETCH_COMPLETE_CLOSE_WINDOW', true);
|
||||
} elseif (isset($status['page'])) {
|
||||
$session->set('com_patchtester_fetcher_page', $status['page']);
|
||||
$message = Text::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', $status['page']);
|
||||
|
||||
// Initialize the state for the model
|
||||
$state = $this->initializeState($model);
|
||||
if ($session->has('com_patchtester_fetcher_last_page')) {
|
||||
$message = Text::sprintf(
|
||||
'COM_PATCHTESTER_FETCH_PAGE_NUMBER_OF_TOTAL',
|
||||
$status['page'],
|
||||
$session->get('com_patchtester_fetcher_last_page')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($state as $key => $value)
|
||||
{
|
||||
$model->setState($key, $value);
|
||||
}
|
||||
|
||||
$status = $model->requestFromGithub($page);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$response = new JsonResponse($e);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
// Store the last page to the session if given one
|
||||
if (isset($status['lastPage']) && $status['lastPage'] !== false)
|
||||
{
|
||||
$session->set('com_patchtester_fetcher_last_page', $status['lastPage']);
|
||||
}
|
||||
|
||||
// Update the UI and session now
|
||||
if ($status['complete'] || $page === $session->get('com_patchtester_fetcher_last_page', false))
|
||||
{
|
||||
$status['complete'] = true;
|
||||
$status['header'] = Text::_('COM_PATCHTESTER_FETCH_SUCCESSFUL', true);
|
||||
|
||||
$message = Text::_('COM_PATCHTESTER_FETCH_COMPLETE_CLOSE_WINDOW', true);
|
||||
}
|
||||
elseif (isset($status['page']))
|
||||
{
|
||||
$session->set('com_patchtester_fetcher_page', $status['page']);
|
||||
|
||||
$message = Text::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', $status['page']);
|
||||
|
||||
if ($session->has('com_patchtester_fetcher_last_page'))
|
||||
{
|
||||
$message = Text::sprintf(
|
||||
'COM_PATCHTESTER_FETCH_PAGE_NUMBER_OF_TOTAL', $status['page'], $session->get('com_patchtester_fetcher_last_page')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$response = new JsonResponse($status, $message, false, true);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close();
|
||||
}
|
||||
$response = new JsonResponse($status, $message, false, true);
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -18,6 +19,10 @@ use PatchTester\Model\PullModel;
|
||||
use PatchTester\Model\PullsModel;
|
||||
use PatchTester\Model\TestsModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Controller class to reset the system state
|
||||
*
|
||||
@ -25,131 +30,104 @@ use PatchTester\Model\TestsModel;
|
||||
*/
|
||||
class ResetController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$hasErrors = false;
|
||||
$revertErrored = false;
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try {
|
||||
$hasErrors = false;
|
||||
$revertErrored = false;
|
||||
$pullModel = new PullModel(null, Factory::getDbo());
|
||||
$pullsModel = new PullsModel($this->context, null, Factory::getDbo());
|
||||
$testsModel = new TestsModel(null, Factory::getDbo());
|
||||
// Check the applied patches in the database first
|
||||
$appliedPatches = $testsModel->getAppliedPatches();
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
// Decide based on repository settings whether patch will be applied through Github or CIServer
|
||||
if ((bool) $params->get('ci_switch', 1)) {
|
||||
// Let's try to cleanly revert all applied patches with ci
|
||||
foreach ($appliedPatches as $patch) {
|
||||
try {
|
||||
$pullModel->revertWithCIServer($patch->id);
|
||||
} catch (\RuntimeException $e) {
|
||||
$revertErrored = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Let's try to cleanly revert all applied patches
|
||||
foreach ($appliedPatches as $patch) {
|
||||
try {
|
||||
$pullModel->revertWithGitHub($patch->id);
|
||||
} catch (\RuntimeException $e) {
|
||||
$revertErrored = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pullModel = new PullModel(null, Factory::getDbo());
|
||||
$pullsModel = new PullsModel($this->context, null, Factory::getDbo());
|
||||
$testsModel = new TestsModel(null, Factory::getDbo());
|
||||
// If we errored out reverting patches, we'll need to truncate the table
|
||||
if ($revertErrored) {
|
||||
try {
|
||||
$testsModel->truncateTable();
|
||||
} catch (\RuntimeException $e) {
|
||||
$hasErrors = true;
|
||||
|
||||
// Check the applied patches in the database first
|
||||
$appliedPatches = $testsModel->getAppliedPatches();
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_PULLS_TABLE', $e->getMessage()),
|
||||
'error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
// Now truncate the pulls table
|
||||
try {
|
||||
$pullsModel->truncateTable();
|
||||
} catch (\RuntimeException $e) {
|
||||
$hasErrors = true;
|
||||
|
||||
// Decide based on repository settings whether patch will be applied through Github or CIServer
|
||||
if ((bool) $params->get('ci_switch', 1))
|
||||
{
|
||||
// Let's try to cleanly revert all applied patches with ci
|
||||
foreach ($appliedPatches as $patch)
|
||||
{
|
||||
try
|
||||
{
|
||||
$pullModel->revertWithCIServer($patch->id);
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$revertErrored = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let's try to cleanly revert all applied patches
|
||||
foreach ($appliedPatches as $patch)
|
||||
{
|
||||
try
|
||||
{
|
||||
$pullModel->revertWithGitHub($patch->id);
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$revertErrored = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_TESTS_TABLE', $e->getMessage()),
|
||||
'error'
|
||||
);
|
||||
}
|
||||
|
||||
// If we errored out reverting patches, we'll need to truncate the table
|
||||
if ($revertErrored)
|
||||
{
|
||||
try
|
||||
{
|
||||
$testsModel->truncateTable();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$hasErrors = true;
|
||||
// Check the backups directory to see if any .txt files remain; clear them if so
|
||||
$backups = Folder::files(JPATH_COMPONENT . '/backups', '.txt');
|
||||
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_PULLS_TABLE', $e->getMessage()), 'error'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (count($backups)) {
|
||||
foreach ($backups as $file) {
|
||||
if (!File::delete(JPATH_COMPONENT . '/backups/' . $file)) {
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE', JPATH_COMPONENT . '/backups/' . $file),
|
||||
'error'
|
||||
);
|
||||
$hasErrors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now truncate the pulls table
|
||||
try
|
||||
{
|
||||
$pullsModel->truncateTable();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$hasErrors = true;
|
||||
// Processing completed, inform the user of a success or fail
|
||||
if ($hasErrors) {
|
||||
$msg = Text::sprintf(
|
||||
'COM_PATCHTESTER_RESET_HAS_ERRORS',
|
||||
JPATH_COMPONENT . '/backups',
|
||||
Factory::getDbo()->replacePrefix('#__patchtester_tests')
|
||||
);
|
||||
$type = 'warning';
|
||||
} else {
|
||||
$msg = Text::_('COM_PATCHTESTER_RESET_OK');
|
||||
$type = 'notice';
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
$msg = $exception->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_TRUNCATING_TESTS_TABLE', $e->getMessage()), 'error'
|
||||
);
|
||||
}
|
||||
|
||||
// Check the backups directory to see if any .txt files remain; clear them if so
|
||||
$backups = Folder::files(JPATH_COMPONENT . '/backups', '.txt');
|
||||
|
||||
if (count($backups))
|
||||
{
|
||||
foreach ($backups as $file)
|
||||
{
|
||||
if (!File::delete(JPATH_COMPONENT . '/backups/' . $file))
|
||||
{
|
||||
$this->getApplication()->enqueueMessage(
|
||||
Text::sprintf('COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE', JPATH_COMPONENT . '/backups/' . $file), 'error'
|
||||
);
|
||||
|
||||
$hasErrors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Processing completed, inform the user of a success or fail
|
||||
if ($hasErrors)
|
||||
{
|
||||
$msg = Text::sprintf(
|
||||
'COM_PATCHTESTER_RESET_HAS_ERRORS', JPATH_COMPONENT . '/backups', Factory::getDbo()->replacePrefix('#__patchtester_tests')
|
||||
);
|
||||
$type = 'warning';
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = Text::_('COM_PATCHTESTER_RESET_OK');
|
||||
$type = 'notice';
|
||||
}
|
||||
}
|
||||
catch (\Exception $exception)
|
||||
{
|
||||
$msg = $exception->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -13,6 +14,10 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use PatchTester\Model\PullModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Controller class to revert patches
|
||||
*
|
||||
@ -20,34 +25,28 @@ use PatchTester\Model\PullModel;
|
||||
*/
|
||||
class RevertController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
$model = new PullModel(null, Factory::getDbo());
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$model = new PullModel(null, Factory::getDbo());
|
||||
// Initialize the state for the model
|
||||
$model->setState($this->initializeState($model));
|
||||
$model->revert($this->getInput()->getUint('pull_id'));
|
||||
$msg = Text::_('COM_PATCHTESTER_REVERT_OK');
|
||||
$type = 'message';
|
||||
} catch (\Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
// Initialize the state for the model
|
||||
$model->setState($this->initializeState($model));
|
||||
|
||||
$model->revert($this->getInput()->getUint('pull_id'));
|
||||
|
||||
$msg = Text::_('COM_PATCHTESTER_REVERT_OK');
|
||||
$type = 'message';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$msg = $e->getMessage();
|
||||
$type = 'error';
|
||||
}
|
||||
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
$this->getApplication()->enqueueMessage($msg, $type);
|
||||
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -15,6 +16,10 @@ use Joomla\CMS\Session\Session;
|
||||
use PatchTester\Helper;
|
||||
use PatchTester\Model\TestsModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Controller class to start fetching remote data
|
||||
*
|
||||
@ -22,109 +27,69 @@ use PatchTester\Model\TestsModel;
|
||||
*/
|
||||
class StartfetchController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// We don't want this request to be cached.
|
||||
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
|
||||
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
|
||||
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
|
||||
$this->getApplication()->setHeader('Pragma', 'no-cache');
|
||||
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
|
||||
/**
|
||||
* Execute the controller.
|
||||
*
|
||||
* @return void Redirects the application
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// We don't want this request to be cached.
|
||||
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
|
||||
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
|
||||
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
|
||||
$this->getApplication()->setHeader('Pragma', 'no-cache');
|
||||
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
|
||||
// Check for a valid token. If invalid, send a 403 with the error message.
|
||||
if (!Session::checkToken('request')) {
|
||||
$response = new JsonResponse(new \Exception(Text::_('JINVALID_TOKEN'), 403));
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
// Check for a valid token. If invalid, send a 403 with the error message.
|
||||
if (!Session::checkToken('request'))
|
||||
{
|
||||
$response = new JsonResponse(new \Exception(Text::_('JINVALID_TOKEN'), 403));
|
||||
// Make sure we can fetch the data from GitHub - throw an error on < 10 available requests
|
||||
try {
|
||||
$rateResponse = Helper::initializeGithub()->getRateLimit();
|
||||
$rate = json_decode($rateResponse->body);
|
||||
} catch (\Exception $e) {
|
||||
$response = new JsonResponse(new \Exception(Text::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()), $e->getCode(), $e));
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
// If over the API limit, we can't build this list
|
||||
if ($rate->resources->core->remaining < 10) {
|
||||
$response = new JsonResponse(new \Exception(Text::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', Factory::getDate($rate->resources->core->reset)), 429));
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
$testsModel = new TestsModel(null, Factory::getDbo());
|
||||
try {
|
||||
// Sanity check, ensure there aren't any applied patches
|
||||
if (count($testsModel->getAppliedPatches()) >= 1) {
|
||||
$response = new JsonResponse(new \Exception(Text::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES'), 500));
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$response = new JsonResponse($e);
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
// Make sure we can fetch the data from GitHub - throw an error on < 10 available requests
|
||||
try
|
||||
{
|
||||
$rateResponse = Helper::initializeGithub()->getRateLimit();
|
||||
$rate = json_decode($rateResponse->body);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$response = new JsonResponse(
|
||||
new \Exception(
|
||||
Text::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()),
|
||||
$e->getCode(),
|
||||
$e
|
||||
)
|
||||
);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
// If over the API limit, we can't build this list
|
||||
if ($rate->resources->core->remaining < 10)
|
||||
{
|
||||
$response = new JsonResponse(
|
||||
new \Exception(
|
||||
Text::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', Factory::getDate($rate->resources->core->reset)),
|
||||
429
|
||||
)
|
||||
);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
$testsModel = new TestsModel(null, Factory::getDbo());
|
||||
|
||||
try
|
||||
{
|
||||
// Sanity check, ensure there aren't any applied patches
|
||||
if (count($testsModel->getAppliedPatches()) >= 1)
|
||||
{
|
||||
$response = new JsonResponse(new \Exception(Text::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES'), 500));
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$response = new JsonResponse($e);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close(1);
|
||||
}
|
||||
|
||||
// We're able to successfully pull data, prepare our environment
|
||||
Factory::getSession()->set('com_patchtester_fetcher_page', 1);
|
||||
|
||||
$response = new JsonResponse(
|
||||
array('complete' => false, 'header' => Text::_('COM_PATCHTESTER_FETCH_PROCESSING', true)),
|
||||
Text::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', 1),
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
|
||||
$this->getApplication()->close();
|
||||
}
|
||||
// We're able to successfully pull data, prepare our environment
|
||||
Factory::getSession()->set('com_patchtester_fetcher_page', 1);
|
||||
$response = new JsonResponse(array('complete' => false, 'header' => Text::_('COM_PATCHTESTER_FETCH_PROCESSING', true)), Text::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', 1), false, true);
|
||||
$this->getApplication()->sendHeaders();
|
||||
echo json_encode($response);
|
||||
$this->getApplication()->close();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -11,7 +12,9 @@ namespace PatchTester\Field;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Field\ListField;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* List of available branches.
|
||||
@ -21,34 +24,30 @@ defined('_JEXEC') or die;
|
||||
*/
|
||||
class BranchField extends ListField
|
||||
{
|
||||
/**
|
||||
* Type of field
|
||||
*
|
||||
* @var string
|
||||
* @since 4.1.0
|
||||
*/
|
||||
protected $type = 'Branch';
|
||||
|
||||
/**
|
||||
* Build a list of available branches.
|
||||
*
|
||||
* @return array List of options
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('DISTINCT(' . $db->quoteName('branch') . ') AS ' . $db->quoteName('text'))
|
||||
->select($db->quoteName('branch', 'value'))
|
||||
->from('#__patchtester_pulls')
|
||||
->where($db->quoteName('branch') . ' != ' . $db->quote(''))
|
||||
->order($db->quoteName('branch') . ' ASC');
|
||||
|
||||
$options = $db->setQuery($query)->loadAssocList();
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
/**
|
||||
* Type of field
|
||||
*
|
||||
* @var string
|
||||
* @since 4.1.0
|
||||
*/
|
||||
protected $type = 'Branch';
|
||||
/**
|
||||
* Build a list of available branches.
|
||||
*
|
||||
* @return array List of options
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('DISTINCT(' . $db->quoteName('branch') . ') AS ' . $db->quoteName('text'))
|
||||
->select($db->quoteName('branch', 'value'))
|
||||
->from('#__patchtester_pulls')
|
||||
->where($db->quoteName('branch') . ' != ' . $db->quote(''))
|
||||
->order($db->quoteName('branch') . ' ASC');
|
||||
$options = $db->setQuery($query)->loadAssocList();
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -11,7 +12,9 @@ namespace PatchTester\Field;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Field\ListField;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* List of available banks.
|
||||
@ -21,33 +24,29 @@ defined('_JEXEC') or die;
|
||||
*/
|
||||
class LabelField extends ListField
|
||||
{
|
||||
/**
|
||||
* Type of field
|
||||
*
|
||||
* @var string
|
||||
* @since 4.1.0
|
||||
*/
|
||||
protected $type = 'Label';
|
||||
|
||||
/**
|
||||
* Build a list of available fields.
|
||||
*
|
||||
* @return array List of options
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('DISTINCT(' . $db->quoteName('name') . ') AS ' . $db->quoteName('text'))
|
||||
->select($db->quoteName('name', 'value'))
|
||||
->from($db->quoteName('#__patchtester_pulls_labels'))
|
||||
->order($db->quoteName('name') . ' ASC');
|
||||
|
||||
$options = $db->setQuery($query)->loadAssocList();
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
/**
|
||||
* Type of field
|
||||
*
|
||||
* @var string
|
||||
* @since 4.1.0
|
||||
*/
|
||||
protected $type = 'Label';
|
||||
/**
|
||||
* Build a list of available fields.
|
||||
*
|
||||
* @return array List of options
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function getOptions(): array
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('DISTINCT(' . $db->quoteName('name') . ') AS ' . $db->quoteName('text'))
|
||||
->select($db->quoteName('name', 'value'))
|
||||
->from($db->quoteName('#__patchtester_pulls_labels'))
|
||||
->order($db->quoteName('name') . ' ASC');
|
||||
$options = $db->setQuery($query)->loadAssocList();
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -17,40 +18,38 @@ use Joomla\CMS\Http\Response;
|
||||
*/
|
||||
class UnexpectedResponse extends \DomainException
|
||||
{
|
||||
/**
|
||||
* The Response object.
|
||||
*
|
||||
* @var Response
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private $response;
|
||||
/**
|
||||
* The Response object.
|
||||
*
|
||||
* @var Response
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private $response;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Response $response The Response object.
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param integer $code The Exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct(Response $response, $message = '', $code = 0, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Response $response The Response object.
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param integer $code The Exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct(Response $response, $message = '', $code = 0, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response object.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
/**
|
||||
* Get the Response object.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -21,332 +22,304 @@ use Joomla\Registry\Registry;
|
||||
*/
|
||||
class GitHub
|
||||
{
|
||||
/**
|
||||
* Options for the connector.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $options;
|
||||
/**
|
||||
* Options for the connector.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $options;
|
||||
/**
|
||||
* The HTTP client object to use in sending HTTP requests.
|
||||
*
|
||||
* @var Http
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $client;
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Registry $options Connector options.
|
||||
* @param Http $client The HTTP client object.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct(Registry $options = null, Http $client = null)
|
||||
{
|
||||
$this->options = $options ?: new Registry();
|
||||
$this->client = $client ?: HttpFactory::getHttp($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* The HTTP client object to use in sending HTTP requests.
|
||||
*
|
||||
* @var Http
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $client;
|
||||
/**
|
||||
* Get the HTTP client for this connector.
|
||||
*
|
||||
* @return Http
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Registry $options Connector options.
|
||||
* @param Http $client The HTTP client object.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct(Registry $options = null, Http $client = null)
|
||||
{
|
||||
$this->options = $options ?: new Registry;
|
||||
$this->client = $client ?: HttpFactory::getHttp($options);
|
||||
}
|
||||
/**
|
||||
* Get the diff for a pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getDiffForPullRequest($user, $repo, $pullId)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId;
|
||||
// Build the request headers.
|
||||
$headers = array('Accept' => 'application/vnd.github.diff');
|
||||
$prepared = $this->prepareRequest($path, 0, 0, $headers);
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP client for this connector.
|
||||
*
|
||||
* @return Http
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
/**
|
||||
* Method to build and return a full request URL for the request.
|
||||
*
|
||||
* This method will add appropriate pagination details if necessary and also prepend the API url to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path Path to process
|
||||
* @param integer $page Page to request
|
||||
* @param integer $limit Number of results to return per page
|
||||
* @param array $headers The headers to send with the request
|
||||
*
|
||||
* @return array Associative array containing the prepared URL and request headers
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function prepareRequest(
|
||||
$path,
|
||||
$page = 0,
|
||||
$limit = 0,
|
||||
array $headers = array()
|
||||
) {
|
||||
$url = $this->fetchUrl($path, $page, $limit);
|
||||
if ($token = $this->options->get('gh.token', false)) {
|
||||
$headers['Authorization'] = "token $token";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the diff for a pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getDiffForPullRequest($user, $repo, $pullId)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId;
|
||||
return array('url' => $url, 'headers' => $headers);
|
||||
}
|
||||
|
||||
// Build the request headers.
|
||||
$headers = array('Accept' => 'application/vnd.github.diff');
|
||||
/**
|
||||
* Build and return a full request URL.
|
||||
*
|
||||
* This method will add appropriate pagination details and basic authentication credentials if necessary
|
||||
* and also prepend the API url to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
* @param integer $page Page to request
|
||||
* @param integer $limit Number of results to return per page
|
||||
*
|
||||
* @return string The request URL.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function fetchUrl($path, $page = 0, $limit = 0)
|
||||
{
|
||||
// Get a new Uri object using the API URL and given path.
|
||||
$uri = new Uri($this->options->get('api.url') . $path);
|
||||
// If we have a defined page number add it to the JUri object.
|
||||
if ($page > 0) {
|
||||
$uri->setVar('page', (int) $page);
|
||||
}
|
||||
|
||||
$prepared = $this->prepareRequest($path, 0, 0, $headers);
|
||||
// If we have a defined items per page add it to the JUri object.
|
||||
if ($limit > 0) {
|
||||
$uri->setVar('per_page', (int) $limit);
|
||||
}
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
return (string) $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request.
|
||||
*
|
||||
* This method will add appropriate pagination details if necessary and also prepend the API url to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path Path to process
|
||||
* @param integer $page Page to request
|
||||
* @param integer $limit Number of results to return per page
|
||||
* @param array $headers The headers to send with the request
|
||||
*
|
||||
* @return array Associative array containing the prepared URL and request headers
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function prepareRequest($path, $page = 0, $limit = 0,
|
||||
array $headers = array()
|
||||
) {
|
||||
$url = $this->fetchUrl($path, $page, $limit);
|
||||
/**
|
||||
* Process the response and return it.
|
||||
*
|
||||
* @param Response $response The response.
|
||||
* @param integer $expectedCode The expected response code.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @throws Exception\UnexpectedResponse
|
||||
*/
|
||||
protected function processResponse(Response $response, $expectedCode = 200)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode) {
|
||||
// Decode the error response and throw an exception.
|
||||
$body = json_decode($response->body);
|
||||
$error = isset($body->error) ? $body->error
|
||||
: (isset($body->message) ? $body->message : 'Unknown Error');
|
||||
|
||||
if ($token = $this->options->get('gh.token', false))
|
||||
{
|
||||
$headers['Authorization'] = "token $token";
|
||||
}
|
||||
throw new Exception\UnexpectedResponse(
|
||||
$response,
|
||||
$error,
|
||||
$response->code
|
||||
);
|
||||
}
|
||||
|
||||
return array('url' => $url, 'headers' => $headers);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and return a full request URL.
|
||||
*
|
||||
* This method will add appropriate pagination details and basic authentication credentials if necessary
|
||||
* and also prepend the API url to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
* @param integer $page Page to request
|
||||
* @param integer $limit Number of results to return per page
|
||||
*
|
||||
* @return string The request URL.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function fetchUrl($path, $page = 0, $limit = 0)
|
||||
{
|
||||
// Get a new Uri object using the API URL and given path.
|
||||
$uri = new Uri($this->options->get('api.url') . $path);
|
||||
/**
|
||||
* Get a file's contents from a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param string $path The content path.
|
||||
* @param string $ref The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getFileContents($user, $repo, $path, $ref = null)
|
||||
{
|
||||
$path = "/repos/$user/$repo/contents/$path";
|
||||
$prepared = $this->prepareRequest($path);
|
||||
if ($ref) {
|
||||
$url = new Uri($prepared['url']);
|
||||
$url->setVar('ref', $ref);
|
||||
$prepared['url'] = (string) $url;
|
||||
}
|
||||
|
||||
// If we have a defined page number add it to the JUri object.
|
||||
if ($page > 0)
|
||||
{
|
||||
$uri->setVar('page', (int) $page);
|
||||
}
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
// If we have a defined items per page add it to the JUri object.
|
||||
if ($limit > 0)
|
||||
{
|
||||
$uri->setVar('per_page', (int) $limit);
|
||||
}
|
||||
/**
|
||||
* Get the list of modified files for a pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getFilesForPullRequest($user, $repo, $pullId, $page = 1)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId . '/files?page=' . $page;
|
||||
$prepared = $this->prepareRequest($path);
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
return (string) $uri;
|
||||
}
|
||||
/**
|
||||
* Get a list of the open issues for a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $page The page number from which to get items.
|
||||
* @param integer $limit The number of items on a page.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOpenIssues($user, $repo, $page = 0, $limit = 0)
|
||||
{
|
||||
$prepared = $this->prepareRequest(
|
||||
"/repos/$user/$repo/issues",
|
||||
$page,
|
||||
$limit
|
||||
);
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the response and return it.
|
||||
*
|
||||
* @param Response $response The response.
|
||||
* @param integer $expectedCode The expected response code.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @throws Exception\UnexpectedResponse
|
||||
*/
|
||||
protected function processResponse(Response $response, $expectedCode = 200)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$body = json_decode($response->body);
|
||||
$error = isset($body->error) ? $body->error
|
||||
: (isset($body->message) ? $body->message : 'Unknown Error');
|
||||
/**
|
||||
* Get a list of the open pull requests for a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $page The page number from which to get items.
|
||||
* @param integer $limit The number of items on a page.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOpenPulls($user, $repo, $page = 0, $limit = 0)
|
||||
{
|
||||
$prepared = $this->prepareRequest(
|
||||
"/repos/$user/$repo/pulls",
|
||||
$page,
|
||||
$limit
|
||||
);
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
throw new Exception\UnexpectedResponse(
|
||||
$response, $error, $response->code
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get an option from the connector.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
* @param mixed $default The default value if the option is not set.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOption($key, $default = null)
|
||||
{
|
||||
return $this->options->get($key, $default);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
/**
|
||||
* Get a single pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getPullRequest($user, $repo, $pullId)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId;
|
||||
$prepared = $this->prepareRequest($path);
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file's contents from a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param string $path The content path.
|
||||
* @param string $ref The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getFileContents($user, $repo, $path, $ref = null)
|
||||
{
|
||||
$path = "/repos/$user/$repo/contents/$path";
|
||||
/**
|
||||
* Get the rate limit for the authenticated user.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getRateLimit()
|
||||
{
|
||||
$prepared = $this->prepareRequest('/rate_limit');
|
||||
return $this->processResponse($this->client->get($prepared['url'], $prepared['headers']));
|
||||
}
|
||||
|
||||
$prepared = $this->prepareRequest($path);
|
||||
|
||||
if ($ref)
|
||||
{
|
||||
$url = new Uri($prepared['url']);
|
||||
$url->setVar('ref', $ref);
|
||||
|
||||
$prepared['url'] = (string) $url;
|
||||
}
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of modified files for a pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getFilesForPullRequest($user, $repo, $pullId, $page = 1)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId . '/files?page=' . $page;
|
||||
|
||||
$prepared = $this->prepareRequest($path);
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the open issues for a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $page The page number from which to get items.
|
||||
* @param integer $limit The number of items on a page.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOpenIssues($user, $repo, $page = 0, $limit = 0)
|
||||
{
|
||||
$prepared = $this->prepareRequest(
|
||||
"/repos/$user/$repo/issues", $page, $limit
|
||||
);
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the open pull requests for a repository.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $page The page number from which to get items.
|
||||
* @param integer $limit The number of items on a page.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOpenPulls($user, $repo, $page = 0, $limit = 0)
|
||||
{
|
||||
$prepared = $this->prepareRequest(
|
||||
"/repos/$user/$repo/pulls", $page, $limit
|
||||
);
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the connector.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
* @param mixed $default The default value if the option is not set.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getOption($key, $default = null)
|
||||
{
|
||||
return $this->options->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single pull request.
|
||||
*
|
||||
* @param string $user The name of the owner of the GitHub repository.
|
||||
* @param string $repo The name of the GitHub repository.
|
||||
* @param integer $pullId The pull request number.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getPullRequest($user, $repo, $pullId)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/$user/$repo/pulls/" . (int) $pullId;
|
||||
|
||||
$prepared = $this->prepareRequest($path);
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limit for the authenticated user.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function getRateLimit()
|
||||
{
|
||||
$prepared = $this->prepareRequest('/rate_limit');
|
||||
|
||||
return $this->processResponse(
|
||||
$this->client->get($prepared['url'], $prepared['headers'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the connector.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set an option for the connector.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -14,6 +15,10 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\Registry\Registry;
|
||||
use PatchTester\GitHub\GitHub;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper class for the patch tester component
|
||||
*
|
||||
@ -21,69 +26,55 @@ use PatchTester\GitHub\GitHub;
|
||||
*/
|
||||
abstract class Helper
|
||||
{
|
||||
/**
|
||||
* Initializes the GitHub object
|
||||
*
|
||||
* @return GitHub
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static function initializeGithub()
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
/**
|
||||
* Initializes the GitHub object
|
||||
*
|
||||
* @return GitHub
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static function initializeGithub()
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
$options = new Registry();
|
||||
// Set a user agent for the request
|
||||
$options->set('userAgent', 'PatchTester/3.0');
|
||||
// Set the default timeout to 120 seconds
|
||||
$options->set('timeout', 120);
|
||||
// Set the API URL
|
||||
$options->set('api.url', 'https://api.github.com');
|
||||
// If an API token is set in the params, use it for authentication
|
||||
if ($params->get('gh_token', '')) {
|
||||
$options->set('headers', ['Authorization' => 'token ' . $params->get('gh_token', '')]);
|
||||
} else {
|
||||
// Display a message about the lowered API limit without credentials
|
||||
Factory::getApplication()->enqueueMessage(Text::_('COM_PATCHTESTER_NO_CREDENTIALS'), 'notice');
|
||||
}
|
||||
|
||||
$options = new Registry;
|
||||
return new GitHub($options);
|
||||
}
|
||||
|
||||
// Set a user agent for the request
|
||||
$options->set('userAgent', 'PatchTester/3.0');
|
||||
|
||||
// Set the default timeout to 120 seconds
|
||||
$options->set('timeout', 120);
|
||||
|
||||
// Set the API URL
|
||||
$options->set('api.url', 'https://api.github.com');
|
||||
|
||||
// If an API token is set in the params, use it for authentication
|
||||
if ($params->get('gh_token', ''))
|
||||
{
|
||||
$options->set('headers', ['Authorization' => 'token ' . $params->get('gh_token', '')]);
|
||||
}
|
||||
// Display a message about the lowered API limit without credentials
|
||||
else
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage(Text::_('COM_PATCHTESTER_NO_CREDENTIALS'), 'notice');
|
||||
}
|
||||
|
||||
return new GitHub($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the CI Settings
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function initializeCISettings()
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
|
||||
$options = new Registry;
|
||||
|
||||
// Set CI server address for the request
|
||||
$options->set('server.url', $params->get('ci_server', 'https://ci.joomla.org:444'));
|
||||
|
||||
// Set name of the zip archive
|
||||
$options->set('zip.name', 'build.zip');
|
||||
$options->set('zip.log.name', 'deleted_files.log');
|
||||
|
||||
// Set temp archive for extracting and downloading files
|
||||
$options->set('folder.temp', Factory::getConfig()->get('tmp_path'));
|
||||
$options->set('folder.backups', JPATH_COMPONENT . '/backups');
|
||||
|
||||
// Set full url for addressing the file
|
||||
$options->set('zip.url', $options->get('server.url') . '/artifacts/joomla/joomla-cms/4.0-dev/%s/patchtester/' . $options->get('zip.name'));
|
||||
|
||||
return $options;
|
||||
}
|
||||
/**
|
||||
* Initializes the CI Settings
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function initializeCISettings()
|
||||
{
|
||||
$params = ComponentHelper::getParams('com_patchtester');
|
||||
$options = new Registry();
|
||||
// Set CI server address for the request
|
||||
$options->set('server.url', $params->get('ci_server', 'https://ci.joomla.org:444'));
|
||||
// Set name of the zip archive
|
||||
$options->set('zip.name', 'build.zip');
|
||||
$options->set('zip.log.name', 'deleted_files.log');
|
||||
// Set temp archive for extracting and downloading files
|
||||
$options->set('folder.temp', Factory::getConfig()->get('tmp_path'));
|
||||
$options->set('folder.backups', JPATH_COMPONENT . '/backups');
|
||||
// Set full url for addressing the file
|
||||
$options->set('zip.url', $options->get('server.url') . '/artifacts/joomla/joomla-cms/4.0-dev/%s/patchtester/' . $options->get('zip.name'));
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -18,85 +19,83 @@ use Joomla\Registry\Registry;
|
||||
*/
|
||||
abstract class AbstractModel
|
||||
{
|
||||
/**
|
||||
* The database driver.
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $db;
|
||||
/**
|
||||
* The database driver.
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $db;
|
||||
/**
|
||||
* The model state.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param Registry $state The model state.
|
||||
* @param \JDatabaseDriver $db The database adpater.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct(Registry $state = null, \JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->state = $state ?: new Registry();
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
|
||||
/**
|
||||
* The model state.
|
||||
*
|
||||
* @var Registry
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
/**
|
||||
* Get the database driver.
|
||||
*
|
||||
* @return \JDatabaseDriver
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getDb()
|
||||
{
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the model.
|
||||
*
|
||||
* @param Registry $state The model state.
|
||||
* @param \JDatabaseDriver $db The database adpater.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct(Registry $state = null, \JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->state = $state ?: new Registry;
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
/**
|
||||
* Get the model state.
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database driver.
|
||||
*
|
||||
* @return \JDatabaseDriver
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getDb()
|
||||
{
|
||||
return $this->db;
|
||||
}
|
||||
/**
|
||||
* Set the database driver.
|
||||
*
|
||||
* @param \JDatabaseDriver $db The database driver.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setDb(\JDatabaseDriver $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model state.
|
||||
*
|
||||
* @return Registry
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the database driver.
|
||||
*
|
||||
* @param \JDatabaseDriver $db The database driver.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setDb(\JDatabaseDriver $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the model state.
|
||||
*
|
||||
* @param Registry $state The state object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setState(Registry $state)
|
||||
{
|
||||
$this->state = $state;
|
||||
}
|
||||
/**
|
||||
* Set the model state.
|
||||
*
|
||||
* @param Registry $state The state object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setState(Registry $state)
|
||||
{
|
||||
$this->state = $state;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -8,6 +9,10 @@
|
||||
|
||||
namespace PatchTester\Model;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Model class for the fetch modal view
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -15,6 +16,10 @@ use Joomla\CMS\MVC\Model\ListModel;
|
||||
use PatchTester\GitHub\Exception\UnexpectedResponse;
|
||||
use PatchTester\Helper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Model class for the pulls list view
|
||||
*
|
||||
@ -22,533 +27,403 @@ use PatchTester\Helper;
|
||||
*/
|
||||
class PullsModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* The object context
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Array of fields the list can be sorted on
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $sortFields = array('pulls.pull_id', 'pulls.title');
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
$config = [];
|
||||
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = [
|
||||
'applied',
|
||||
'rtc',
|
||||
'npm',
|
||||
'draft',
|
||||
'label',
|
||||
'branch',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$store = $this->getStoreId();
|
||||
|
||||
if (isset($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
$items = $this->getList(
|
||||
$this->getListQueryCache(), $this->getStart(),
|
||||
$this->getState()->get('list.limit')
|
||||
);
|
||||
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(['name', 'color']))
|
||||
->from($db->quoteName('#__patchtester_pulls_labels'));
|
||||
|
||||
array_walk(
|
||||
$items,
|
||||
static function ($item) use ($db, $query) {
|
||||
$query->clear('where');
|
||||
$query->where(
|
||||
$db->quoteName('pull_id') . ' = ' . $item->pull_id
|
||||
);
|
||||
$db->setQuery($query);
|
||||
|
||||
$item->labels = $db->loadObjectList();
|
||||
}
|
||||
);
|
||||
|
||||
$this->cache[$store] = $items;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on the model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id An identifier string to generate the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Add the list state to the store id.
|
||||
$id .= ':' . $this->getState()->get('list.start');
|
||||
$id .= ':' . $this->getState()->get('list.limit');
|
||||
$id .= ':' . $this->getState()->get('list.ordering');
|
||||
$id .= ':' . $this->getState()->get('list.direction');
|
||||
|
||||
return md5($this->context . ':' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of objects from the results of database query.
|
||||
*
|
||||
* @param \JDatabaseQuery|string $query The query.
|
||||
* @param integer $limitstart Offset.
|
||||
* @param integer $limit The number of records.
|
||||
*
|
||||
* @return array An array of results.
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function getList($query, $limitstart = 0, $limit = 0)
|
||||
{
|
||||
return $this->getDbo()->setQuery($query, $limitstart, $limit)
|
||||
->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cache the last query constructed.
|
||||
*
|
||||
* This method ensures that the query is constructed only once for a given state of the model.
|
||||
*
|
||||
* @return \JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getListQueryCache()
|
||||
{
|
||||
// Capture the last store id used.
|
||||
static $lastStoreId;
|
||||
|
||||
// Compute the current store id.
|
||||
$currentStoreId = $this->getStoreId();
|
||||
|
||||
// If the last store id is different from the current, refresh the query.
|
||||
if ($lastStoreId != $currentStoreId || empty($this->query))
|
||||
{
|
||||
$lastStoreId = $currentStoreId;
|
||||
$this->query = $this->getListQuery();
|
||||
}
|
||||
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a JDatabaseQuery object for retrieving the data set from a database.
|
||||
*
|
||||
* @return \JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$labelQuery = $db->getQuery(true);
|
||||
|
||||
$query->select('pulls.*')
|
||||
->select($db->quoteName('tests.id', 'applied'))
|
||||
->from($db->quoteName('#__patchtester_pulls', 'pulls'))
|
||||
->leftJoin(
|
||||
$db->quoteName('#__patchtester_tests', 'tests')
|
||||
. ' ON ' . $db->quoteName('tests.pull_id') . ' = '
|
||||
. $db->quoteName('pulls.pull_id')
|
||||
);
|
||||
|
||||
$search = $this->getState()->get('filter.search');
|
||||
|
||||
if (!empty($search))
|
||||
{
|
||||
if (stripos($search, 'id:') === 0)
|
||||
{
|
||||
$query->where(
|
||||
$db->quoteName('pulls.pull_id') . ' = ' . (int) substr(
|
||||
$search, 3
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif (is_numeric($search))
|
||||
{
|
||||
$query->where(
|
||||
$db->quoteName('pulls.pull_id') . ' = ' . (int) $search
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where(
|
||||
'(' . $db->quoteName('pulls.title') . ' LIKE ' . $db->quote(
|
||||
'%' . $db->escape($search, true) . '%'
|
||||
) . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$applied = $this->getState()->get('filter.applied');
|
||||
|
||||
if (!empty($applied))
|
||||
{
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $applied === 'no' ? ' IS NULL' : ' = 1';
|
||||
|
||||
$query->where($db->quoteName('applied') . $value);
|
||||
}
|
||||
|
||||
$branch = $this->getState()->get('filter.branch');
|
||||
|
||||
if (!empty($branch))
|
||||
{
|
||||
$query->where(
|
||||
$db->quoteName('pulls.branch') . ' IN (' . implode(',', $db->quote($branch)) . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$applied = $this->getState()->get('filter.rtc');
|
||||
|
||||
if (!empty($applied))
|
||||
{
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $applied === 'no' ? '0' : '1';
|
||||
|
||||
$query->where($db->quoteName('pulls.is_rtc') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$npm = $this->getState()->get('filter.npm');
|
||||
|
||||
if (!empty($npm))
|
||||
{
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $npm === 'no' ? '0' : '1';
|
||||
|
||||
$query->where($db->quoteName('pulls.is_npm') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$draft = $this->getState()->get('filter.draft');
|
||||
|
||||
if (!empty($draft))
|
||||
{
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $draft === 'no' ? '0' : '1';
|
||||
|
||||
$query->where($db->quoteName('pulls.is_draft') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$labels = $this->getState()->get('filter.label');
|
||||
|
||||
if (!empty($labels) && $labels[0] !== '')
|
||||
{
|
||||
$labelQuery
|
||||
->select($db->quoteName('pulls_labels.pull_id'))
|
||||
->select(
|
||||
'COUNT(' . $db->quoteName('pulls_labels.name') . ') AS '
|
||||
. $db->quoteName('labelCount')
|
||||
)
|
||||
->from(
|
||||
$db->quoteName(
|
||||
'#__patchtester_pulls_labels', 'pulls_labels'
|
||||
)
|
||||
)
|
||||
->where(
|
||||
$db->quoteName('pulls_labels.name') . ' IN (' . implode(
|
||||
',', $db->quote($labels)
|
||||
) . ')'
|
||||
)
|
||||
->group($db->quoteName('pulls_labels.pull_id'));
|
||||
|
||||
$query->leftJoin(
|
||||
'(' . $labelQuery->__toString() . ') AS ' . $db->quoteName(
|
||||
'pulls_labels'
|
||||
)
|
||||
. ' ON ' . $db->quoteName('pulls_labels.pull_id') . ' = '
|
||||
. $db->quoteName('pulls.pull_id')
|
||||
)
|
||||
->where(
|
||||
$db->quoteName('pulls_labels.labelCount') . ' = ' . count(
|
||||
$labels
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$ordering = $this->getState()->get('list.ordering', 'pulls.pull_id');
|
||||
$direction = $this->getState()->get('list.direction', 'DESC');
|
||||
|
||||
if (!empty($ordering))
|
||||
{
|
||||
$query->order(
|
||||
$db->escape($ordering) . ' ' . $db->escape($direction)
|
||||
);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the array of authorized sort fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getSortFields()
|
||||
{
|
||||
return $this->sortFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to request new data from GitHub
|
||||
*
|
||||
* @param integer $page The page of the request
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function requestFromGithub($page)
|
||||
{
|
||||
if ($page === 1)
|
||||
{
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls');
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls_labels');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// TODO - Option to configure the batch size
|
||||
$batchSize = 100;
|
||||
|
||||
$pullsResponse = Helper::initializeGithub()->getOpenPulls(
|
||||
$this->getState()->get('github_user'),
|
||||
$this->getState()->get('github_repo'),
|
||||
$page,
|
||||
$batchSize
|
||||
);
|
||||
|
||||
$pulls = json_decode($pullsResponse->body);
|
||||
}
|
||||
catch (UnexpectedResponse $exception)
|
||||
{
|
||||
throw new \RuntimeException(
|
||||
Text::sprintf(
|
||||
'COM_PATCHTESTER_ERROR_GITHUB_FETCH',
|
||||
$exception->getMessage()
|
||||
),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
|
||||
// If this is page 1, let's check to see if we need to paginate
|
||||
if ($page === 1)
|
||||
{
|
||||
// Default this to being a single page of results
|
||||
$lastPage = 1;
|
||||
|
||||
if (isset($pullsResponse->headers['link']))
|
||||
{
|
||||
$linkHeader = $pullsResponse->headers['link'];
|
||||
|
||||
// The `joomla/http` 2.0 package uses PSR-7 Responses which has a different format for headers, check for this
|
||||
if (is_array($linkHeader))
|
||||
{
|
||||
$linkHeader = $linkHeader[0];
|
||||
}
|
||||
|
||||
preg_match(
|
||||
'/(\?page=[0-9]{1,3}&per_page=' . $batchSize
|
||||
. '+>; rel=\"last\")/', $linkHeader, $matches
|
||||
);
|
||||
|
||||
if ($matches && isset($matches[0]))
|
||||
{
|
||||
$pageSegment = str_replace(
|
||||
'&per_page=' . $batchSize, '', $matches[0]
|
||||
);
|
||||
|
||||
preg_match('/\d+/', $pageSegment, $pages);
|
||||
$lastPage = (int) $pages[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no pulls to insert then bail, assume we're finished
|
||||
if (count($pulls) === 0)
|
||||
{
|
||||
return ['complete' => true];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$labels = [];
|
||||
|
||||
foreach ($pulls as $pull)
|
||||
{
|
||||
// Check if this PR is RTC and has a `PR-` branch label
|
||||
$isRTC = false;
|
||||
$isNPM = false;
|
||||
$branch = $pull->base->ref;
|
||||
|
||||
foreach ($pull->labels as $label)
|
||||
{
|
||||
if (strtolower($label->name) === 'rtc')
|
||||
{
|
||||
$isRTC = true;
|
||||
}
|
||||
elseif (in_array(
|
||||
strtolower($label->name),
|
||||
['npm resource changed', 'composer dependency changed'],
|
||||
true
|
||||
))
|
||||
{
|
||||
$isNPM = true;
|
||||
}
|
||||
|
||||
$labels[] = implode(
|
||||
',',
|
||||
[
|
||||
(int) $pull->number,
|
||||
$this->getDbo()->quote($label->name),
|
||||
$this->getDbo()->quote($label->color),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Build the data object to store in the database
|
||||
$pullData = [
|
||||
(int) $pull->number,
|
||||
$this->getDbo()->quote(
|
||||
HTMLHelper::_('string.truncate', $pull->title, 150)
|
||||
),
|
||||
$this->getDbo()->quote(
|
||||
HTMLHelper::_('string.truncate', $pull->body, 100)
|
||||
),
|
||||
$this->getDbo()->quote($pull->html_url),
|
||||
(int) $isRTC,
|
||||
(int) $isNPM,
|
||||
$this->getDbo()->quote($branch),
|
||||
($pull->draft ? 1 : 0)
|
||||
];
|
||||
|
||||
$data[] = implode(',', $pullData);
|
||||
}
|
||||
|
||||
// If there are no pulls to insert then bail, assume we're finished
|
||||
if (count($data) === 0)
|
||||
{
|
||||
return array('complete' => true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->getDbo()->setQuery(
|
||||
$this->getDbo()->getQuery(true)
|
||||
->insert('#__patchtester_pulls')
|
||||
->columns(
|
||||
['pull_id', 'title', 'description', 'pull_url',
|
||||
'is_rtc', 'is_npm', 'branch', 'is_draft']
|
||||
)
|
||||
->values($data)
|
||||
);
|
||||
|
||||
$this->getDbo()->execute();
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException(
|
||||
Text::sprintf(
|
||||
'COM_PATCHTESTER_ERROR_INSERT_DATABASE',
|
||||
$exception->getMessage()
|
||||
),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
|
||||
if ($labels)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->getDbo()->setQuery(
|
||||
$this->getDbo()->getQuery(true)
|
||||
->insert('#__patchtester_pulls_labels')
|
||||
->columns(['pull_id', 'name', 'color'])
|
||||
->values($labels)
|
||||
);
|
||||
$this->getDbo()->execute();
|
||||
}
|
||||
catch (\RuntimeException $exception)
|
||||
{
|
||||
throw new \RuntimeException(
|
||||
Text::sprintf(
|
||||
'COM_PATCHTESTER_ERROR_INSERT_DATABASE',
|
||||
$exception->getMessage()
|
||||
),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'complete' => false,
|
||||
'page' => ($page + 1),
|
||||
'lastPage' => $lastPage ?? false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the pulls table
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function truncateTable()
|
||||
{
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls');
|
||||
}
|
||||
/**
|
||||
* The object context
|
||||
*
|
||||
* @var string
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $context;
|
||||
/**
|
||||
* Array of fields the list can be sorted on
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $sortFields = array('pulls.pull_id', 'pulls.title');
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
$config = [];
|
||||
if (empty($config['filter_fields'])) {
|
||||
$config['filter_fields'] = [
|
||||
'applied',
|
||||
'rtc',
|
||||
'npm',
|
||||
'draft',
|
||||
'label',
|
||||
'branch',
|
||||
];
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$store = $this->getStoreId();
|
||||
if (isset($this->cache[$store])) {
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
$items = $this->getList(
|
||||
$this->getListQueryCache(),
|
||||
$this->getStart(),
|
||||
$this->getState()->get('list.limit')
|
||||
);
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(['name', 'color']))
|
||||
->from($db->quoteName('#__patchtester_pulls_labels'));
|
||||
array_walk($items, static function ($item) use ($db, $query) {
|
||||
|
||||
$query->clear('where');
|
||||
$query->where($db->quoteName('pull_id') . ' = ' . $item->pull_id);
|
||||
$db->setQuery($query);
|
||||
$item->labels = $db->loadObjectList();
|
||||
});
|
||||
$this->cache[$store] = $items;
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on the model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id An identifier string to generate the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Add the list state to the store id.
|
||||
$id .= ':' . $this->getState()->get('list.start');
|
||||
$id .= ':' . $this->getState()->get('list.limit');
|
||||
$id .= ':' . $this->getState()->get('list.ordering');
|
||||
$id .= ':' . $this->getState()->get('list.direction');
|
||||
return md5($this->context . ':' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of objects from the results of database query.
|
||||
*
|
||||
* @param \JDatabaseQuery|string $query The query.
|
||||
* @param integer $limitstart Offset.
|
||||
* @param integer $limit The number of records.
|
||||
*
|
||||
* @return array An array of results.
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function getList($query, $limitstart = 0, $limit = 0)
|
||||
{
|
||||
return $this->getDbo()->setQuery($query, $limitstart, $limit)
|
||||
->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cache the last query constructed.
|
||||
*
|
||||
* This method ensures that the query is constructed only once for a given state of the model.
|
||||
*
|
||||
* @return \JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getListQueryCache()
|
||||
{
|
||||
// Capture the last store id used.
|
||||
static $lastStoreId;
|
||||
// Compute the current store id.
|
||||
$currentStoreId = $this->getStoreId();
|
||||
// If the last store id is different from the current, refresh the query.
|
||||
if ($lastStoreId != $currentStoreId || empty($this->query)) {
|
||||
$lastStoreId = $currentStoreId;
|
||||
$this->query = $this->getListQuery();
|
||||
}
|
||||
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a JDatabaseQuery object for retrieving the data set from a database.
|
||||
*
|
||||
* @return \JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$labelQuery = $db->getQuery(true);
|
||||
$query->select('pulls.*')
|
||||
->select($db->quoteName('tests.id', 'applied'))
|
||||
->from($db->quoteName('#__patchtester_pulls', 'pulls'))
|
||||
->leftJoin($db->quoteName('#__patchtester_tests', 'tests')
|
||||
. ' ON ' . $db->quoteName('tests.pull_id') . ' = '
|
||||
. $db->quoteName('pulls.pull_id'));
|
||||
$search = $this->getState()->get('filter.search');
|
||||
|
||||
if (!empty($search)) {
|
||||
if (stripos($search, 'id:') === 0) {
|
||||
$query->where($db->quoteName('pulls.pull_id') . ' = ' . (int) substr(
|
||||
$search,
|
||||
3
|
||||
));
|
||||
} elseif (is_numeric($search)) {
|
||||
$query->where($db->quoteName('pulls.pull_id') . ' = ' . (int) $search);
|
||||
} else {
|
||||
$query->where('(' . $db->quoteName('pulls.title') . ' LIKE ' . $db->quote('%' . $db->escape($search, true) . '%') . ')');
|
||||
}
|
||||
}
|
||||
|
||||
$applied = $this->getState()->get('filter.applied');
|
||||
if (!empty($applied)) {
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $applied === 'no' ? ' IS NULL' : ' = 1';
|
||||
$query->where($db->quoteName('applied') . $value);
|
||||
}
|
||||
|
||||
$branch = $this->getState()->get('filter.branch');
|
||||
if (!empty($branch)) {
|
||||
$query->where($db->quoteName('pulls.branch') . ' IN (' . implode(',', $db->quote($branch)) . ')');
|
||||
}
|
||||
|
||||
$applied = $this->getState()->get('filter.rtc');
|
||||
if (!empty($applied)) {
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $applied === 'no' ? '0' : '1';
|
||||
$query->where($db->quoteName('pulls.is_rtc') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$npm = $this->getState()->get('filter.npm');
|
||||
if (!empty($npm)) {
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $npm === 'no' ? '0' : '1';
|
||||
$query->where($db->quoteName('pulls.is_npm') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$draft = $this->getState()->get('filter.draft');
|
||||
if (!empty($draft)) {
|
||||
// Not applied patches have a NULL value, so build our value part of the query based on this
|
||||
$value = $draft === 'no' ? '0' : '1';
|
||||
$query->where($db->quoteName('pulls.is_draft') . ' = ' . $value);
|
||||
}
|
||||
|
||||
$labels = $this->getState()->get('filter.label');
|
||||
|
||||
if (!empty($labels) && $labels[0] !== '') {
|
||||
$labelQuery
|
||||
->select($db->quoteName('pulls_labels.pull_id'))
|
||||
->select('COUNT(' . $db->quoteName('pulls_labels.name') . ') AS '
|
||||
. $db->quoteName('labelCount'))
|
||||
->from($db->quoteName(
|
||||
'#__patchtester_pulls_labels',
|
||||
'pulls_labels'
|
||||
))
|
||||
->where($db->quoteName('pulls_labels.name') . ' IN (' . implode(
|
||||
',',
|
||||
$db->quote($labels)
|
||||
) . ')')
|
||||
->group($db->quoteName('pulls_labels.pull_id'));
|
||||
$query->leftJoin('(' . $labelQuery->__toString() . ') AS ' . $db->quoteName('pulls_labels')
|
||||
. ' ON ' . $db->quoteName('pulls_labels.pull_id') . ' = '
|
||||
. $db->quoteName('pulls.pull_id'))
|
||||
->where($db->quoteName('pulls_labels.labelCount') . ' = ' . count($labels));
|
||||
}
|
||||
|
||||
$ordering = $this->getState()->get('list.ordering', 'pulls.pull_id');
|
||||
$direction = $this->getState()->get('list.direction', 'DESC');
|
||||
if (!empty($ordering)) {
|
||||
$query->order($db->escape($ordering) . ' ' . $db->escape($direction));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the array of authorized sort fields
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getSortFields()
|
||||
{
|
||||
return $this->sortFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to request new data from GitHub
|
||||
*
|
||||
* @param integer $page The page of the request
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function requestFromGithub($page)
|
||||
{
|
||||
if ($page === 1) {
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls');
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls_labels');
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO - Option to configure the batch size
|
||||
$batchSize = 100;
|
||||
$pullsResponse = Helper::initializeGithub()->getOpenPulls($this->getState()->get('github_user'), $this->getState()->get('github_repo'), $page, $batchSize);
|
||||
$pulls = json_decode($pullsResponse->body);
|
||||
} catch (UnexpectedResponse $exception) {
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_GITHUB_FETCH', $exception->getMessage()), $exception->getCode(), $exception);
|
||||
}
|
||||
|
||||
// If this is page 1, let's check to see if we need to paginate
|
||||
if ($page === 1) {
|
||||
// Default this to being a single page of results
|
||||
$lastPage = 1;
|
||||
if (isset($pullsResponse->headers['link'])) {
|
||||
$linkHeader = $pullsResponse->headers['link'];
|
||||
// The `joomla/http` 2.0 package uses PSR-7 Responses which has a different format for headers, check for this
|
||||
if (is_array($linkHeader)) {
|
||||
$linkHeader = $linkHeader[0];
|
||||
}
|
||||
|
||||
preg_match(
|
||||
'/(\?page=[0-9]{1,3}&per_page=' . $batchSize
|
||||
. '+>; rel=\"last\")/',
|
||||
$linkHeader,
|
||||
$matches
|
||||
);
|
||||
|
||||
if ($matches && isset($matches[0])) {
|
||||
$pageSegment = str_replace(
|
||||
'&per_page=' . $batchSize,
|
||||
'',
|
||||
$matches[0]
|
||||
);
|
||||
preg_match('/\d+/', $pageSegment, $pages);
|
||||
$lastPage = (int) $pages[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no pulls to insert then bail, assume we're finished
|
||||
if (count($pulls) === 0) {
|
||||
return ['complete' => true];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$labels = [];
|
||||
foreach ($pulls as $pull) {
|
||||
// Check if this PR is RTC and has a `PR-` branch label
|
||||
$isRTC = false;
|
||||
$isNPM = false;
|
||||
$branch = $pull->base->ref;
|
||||
foreach ($pull->labels as $label) {
|
||||
if (strtolower($label->name) === 'rtc') {
|
||||
$isRTC = true;
|
||||
} elseif (
|
||||
in_array(strtolower($label->name), ['npm resource changed', 'composer dependency changed'], true)
|
||||
) {
|
||||
$isNPM = true;
|
||||
}
|
||||
|
||||
$labels[] = implode(',', [
|
||||
(int) $pull->number,
|
||||
$this->getDbo()->quote($label->name),
|
||||
$this->getDbo()->quote($label->color),
|
||||
]);
|
||||
}
|
||||
|
||||
// Build the data object to store in the database
|
||||
$pullData = [
|
||||
(int) $pull->number,
|
||||
$this->getDbo()->quote(HTMLHelper::_('string.truncate', $pull->title, 150)),
|
||||
$this->getDbo()->quote(HTMLHelper::_('string.truncate', $pull->body, 100)),
|
||||
$this->getDbo()->quote($pull->html_url),
|
||||
(int) $isRTC,
|
||||
(int) $isNPM,
|
||||
$this->getDbo()->quote($branch),
|
||||
($pull->draft ? 1 : 0)
|
||||
];
|
||||
$data[] = implode(',', $pullData);
|
||||
}
|
||||
|
||||
// If there are no pulls to insert then bail, assume we're finished
|
||||
if (count($data) === 0) {
|
||||
return array('complete' => true);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->getDbo()->setQuery($this->getDbo()->getQuery(true)
|
||||
->insert('#__patchtester_pulls')
|
||||
->columns(['pull_id', 'title', 'description', 'pull_url',
|
||||
'is_rtc', 'is_npm', 'branch', 'is_draft'])
|
||||
->values($data));
|
||||
$this->getDbo()->execute();
|
||||
} catch (\RuntimeException $exception) {
|
||||
throw new \RuntimeException(Text::sprintf('COM_PATCHTESTER_ERROR_INSERT_DATABASE', $exception->getMessage()), $exception->getCode(), $exception);
|
||||
}
|
||||
|
||||
if ($labels) {
|
||||
try {
|
||||
$this->getDbo()->setQuery($this->getDbo()->getQuery(true)
|
||||
->insert('#__patchtester_pulls_labels')
|
||||
->columns(['pull_id', 'name', 'color'])
|
||||
->values($labels));
|
||||
$this->getDbo()->execute();
|
||||
} catch (\RuntimeException $exception) {
|
||||
throw new \RuntimeException(
|
||||
Text::sprintf(
|
||||
'COM_PATCHTESTER_ERROR_INSERT_DATABASE',
|
||||
$exception->getMessage()
|
||||
),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'complete' => false,
|
||||
'page' => ($page + 1),
|
||||
'lastPage' => $lastPage ?? false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the pulls table
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function truncateTable()
|
||||
{
|
||||
$this->getDbo()->truncateTable('#__patchtester_pulls');
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -8,6 +9,10 @@
|
||||
|
||||
namespace PatchTester\Model;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Methods supporting applied pull requests.
|
||||
*
|
||||
@ -15,36 +20,32 @@ namespace PatchTester\Model;
|
||||
*/
|
||||
class TestsModel extends AbstractModel
|
||||
{
|
||||
/**
|
||||
* Retrieves a list of applied patches
|
||||
*
|
||||
* @return array List of applied patches
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getAppliedPatches(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
/**
|
||||
* Retrieves a list of applied patches
|
||||
*
|
||||
* @return array List of applied patches
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function getAppliedPatches(): array
|
||||
{
|
||||
$db = $this->getDb();
|
||||
$db->setQuery($db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__patchtester_tests'))
|
||||
->where($db->quoteName('applied') . ' = 1'));
|
||||
return $db->loadObjectList('pull_id');
|
||||
}
|
||||
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__patchtester_tests'))
|
||||
->where($db->quoteName('applied') . ' = 1')
|
||||
);
|
||||
|
||||
return $db->loadObjectList('pull_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the tests table
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function truncateTable(): void
|
||||
{
|
||||
$this->getDb()->truncateTable('#__patchtester_tests');
|
||||
}
|
||||
/**
|
||||
* Truncates the tests table
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public function truncateTable(): void
|
||||
{
|
||||
$this->getDb()->truncateTable('#__patchtester_tests');
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -15,55 +16,53 @@ namespace PatchTester;
|
||||
*/
|
||||
abstract class TrackerHelper
|
||||
{
|
||||
/**
|
||||
* Array containing the supported repositories integrated with the Joomla! Issue Tracker
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
private static $projects = array(
|
||||
'joomla-cms' => array(
|
||||
'githubUser' => 'joomla',
|
||||
'githubrepo' => 'joomla-cms',
|
||||
'projectAlias' => 'joomla-cms',
|
||||
),
|
||||
'patchtester' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'patchtester',
|
||||
'projectAlias' => 'patchtester',
|
||||
),
|
||||
'weblinks' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'weblinks',
|
||||
'projectAlias' => 'weblinks',
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Array containing the supported repositories integrated with the Joomla! Issue Tracker
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
private static $projects = array(
|
||||
'joomla-cms' => array(
|
||||
'githubUser' => 'joomla',
|
||||
'githubrepo' => 'joomla-cms',
|
||||
'projectAlias' => 'joomla-cms',
|
||||
),
|
||||
'patchtester' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'patchtester',
|
||||
'projectAlias' => 'patchtester',
|
||||
),
|
||||
'weblinks' => array(
|
||||
'githubUser' => 'joomla-extensions',
|
||||
'githubrepo' => 'weblinks',
|
||||
'projectAlias' => 'weblinks',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the issue tracker project alias for a GitHub repository
|
||||
*
|
||||
* @param string $githubUser The owner of the GitHub repository (user or organization)
|
||||
* @param string $githubRepo The GitHub repository name
|
||||
*
|
||||
* @return string|boolean The project alias if supported or boolean false
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static function getTrackerAlias($githubUser, $githubRepo)
|
||||
{
|
||||
// If the repo isn't even listed, no point in going further
|
||||
if (!array_key_exists($githubRepo, self::$projects))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the issue tracker project alias for a GitHub repository
|
||||
*
|
||||
* @param string $githubUser The owner of the GitHub repository (user or organization)
|
||||
* @param string $githubRepo The GitHub repository name
|
||||
*
|
||||
* @return string|boolean The project alias if supported or boolean false
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public static function getTrackerAlias($githubUser, $githubRepo)
|
||||
{
|
||||
// If the repo isn't even listed, no point in going further
|
||||
if (!array_key_exists($githubRepo, self::$projects)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now the GitHub user must match the project (we don't support forks, sorry!)
|
||||
if (self::$projects[$githubRepo]['githubUser'] !== $githubUser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Now the GitHub user must match the project (we don't support forks, sorry!)
|
||||
if (self::$projects[$githubRepo]['githubUser'] !== $githubUser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This project is supported
|
||||
return self::$projects[$githubRepo]['projectAlias'];
|
||||
}
|
||||
// This project is supported
|
||||
return self::$projects[$githubRepo]['projectAlias'];
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -12,6 +13,10 @@ use Joomla\CMS\Filesystem\Path;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use PatchTester\Model\AbstractModel;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Base HTML view for the patch testing component
|
||||
*
|
||||
@ -19,204 +24,184 @@ use PatchTester\Model\AbstractModel;
|
||||
*/
|
||||
abstract class AbstractHtmlView extends AbstractView
|
||||
{
|
||||
/**
|
||||
* The view layout.
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $layout = 'default';
|
||||
/**
|
||||
* The view layout.
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $layout = 'default';
|
||||
/**
|
||||
* The paths queue.
|
||||
*
|
||||
* @var SplPriorityQueue
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $paths;
|
||||
/**
|
||||
* Method to instantiate the view.
|
||||
*
|
||||
* @param AbstractModel $model The model object.
|
||||
* @param SplPriorityQueue $paths The paths queue.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct($model, \SplPriorityQueue $paths = null)
|
||||
{
|
||||
parent::__construct($model);
|
||||
// Setup dependencies.
|
||||
$this->paths = $paths ?: new \SplPriorityQueue();
|
||||
}
|
||||
|
||||
/**
|
||||
* The paths queue.
|
||||
*
|
||||
* @var SplPriorityQueue
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $paths;
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function escape($output)
|
||||
{
|
||||
// Escape the output.
|
||||
return htmlspecialchars($output, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to instantiate the view.
|
||||
*
|
||||
* @param AbstractModel $model The model object.
|
||||
* @param SplPriorityQueue $paths The paths queue.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct($model, \SplPriorityQueue $paths = null)
|
||||
{
|
||||
parent::__construct($model);
|
||||
/**
|
||||
* Method to get the view layout.
|
||||
*
|
||||
* @return string The layout name.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
|
||||
// Setup dependencies.
|
||||
$this->paths = $paths ?: new \SplPriorityQueue;
|
||||
}
|
||||
/**
|
||||
* Method to get the layout path.
|
||||
*
|
||||
* @param string $layout The layout name.
|
||||
*
|
||||
* @return mixed The layout file name if found, false otherwise.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getPath($layout)
|
||||
{
|
||||
// Get the layout file name.
|
||||
$file = Path::clean($layout . '.php');
|
||||
// Find the layout file path.
|
||||
$path = Path::find(clone $this->paths, $file);
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function escape($output)
|
||||
{
|
||||
// Escape the output.
|
||||
return htmlspecialchars($output, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
/**
|
||||
* Method to get the view paths.
|
||||
*
|
||||
* @return SplPriorityQueue The paths queue.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the view layout.
|
||||
*
|
||||
* @return string The layout name.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
return $this->layout;
|
||||
}
|
||||
/**
|
||||
* Load a template file -- first look in the templates folder for an override
|
||||
*
|
||||
* @param string $tpl The name of the template source file; automatically searches the template paths and compiles as needed.
|
||||
*
|
||||
* @return string The output of the the template script.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function loadTemplate($tpl = null)
|
||||
{
|
||||
// Get the path to the file
|
||||
$file = $this->getLayout();
|
||||
if (isset($tpl)) {
|
||||
$file .= '_' . $tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the layout path.
|
||||
*
|
||||
* @param string $layout The layout name.
|
||||
*
|
||||
* @return mixed The layout file name if found, false otherwise.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getPath($layout)
|
||||
{
|
||||
// Get the layout file name.
|
||||
$file = Path::clean($layout . '.php');
|
||||
$path = $this->getPath($file);
|
||||
if (!$path) {
|
||||
throw new \RuntimeException(Text::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
|
||||
}
|
||||
|
||||
// Find the layout file path.
|
||||
$path = Path::find(clone $this->paths, $file);
|
||||
// Unset so as not to introduce into template scope
|
||||
unset($tpl);
|
||||
unset($file);
|
||||
// Never allow a 'this' property
|
||||
if (isset($this->this)) {
|
||||
unset($this->this);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
// Start an output buffer.
|
||||
ob_start();
|
||||
// Load the template.
|
||||
include $path;
|
||||
// Get the layout contents.
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the view paths.
|
||||
*
|
||||
* @return SplPriorityQueue The paths queue.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
/**
|
||||
* Method to render the view.
|
||||
*
|
||||
* @return string The rendered view.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
// Get the layout path.
|
||||
$path = $this->getPath($this->getLayout());
|
||||
// Check if the layout path was found.
|
||||
if (!$path) {
|
||||
throw new \RuntimeException('Layout Path Not Found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a template file -- first look in the templates folder for an override
|
||||
*
|
||||
* @param string $tpl The name of the template source file; automatically searches the template paths and compiles as needed.
|
||||
*
|
||||
* @return string The output of the the template script.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function loadTemplate($tpl = null)
|
||||
{
|
||||
// Get the path to the file
|
||||
$file = $this->getLayout();
|
||||
// Start an output buffer.
|
||||
ob_start();
|
||||
// Load the layout.
|
||||
include $path;
|
||||
// Get the layout contents.
|
||||
$output = ob_get_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
if (isset($tpl))
|
||||
{
|
||||
$file .= '_' . $tpl;
|
||||
}
|
||||
/**
|
||||
* Method to set the view layout.
|
||||
*
|
||||
* @param string $layout The layout name.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setLayout($layout)
|
||||
{
|
||||
$this->layout = $layout;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$path = $this->getPath($file);
|
||||
|
||||
if (!$path)
|
||||
{
|
||||
throw new \RuntimeException(Text::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
|
||||
}
|
||||
|
||||
// Unset so as not to introduce into template scope
|
||||
unset($tpl);
|
||||
unset($file);
|
||||
|
||||
// Never allow a 'this' property
|
||||
if (isset($this->this))
|
||||
{
|
||||
unset($this->this);
|
||||
}
|
||||
|
||||
// Start an output buffer.
|
||||
ob_start();
|
||||
|
||||
// Load the template.
|
||||
include $path;
|
||||
|
||||
// Get the layout contents.
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the view.
|
||||
*
|
||||
* @return string The rendered view.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
// Get the layout path.
|
||||
$path = $this->getPath($this->getLayout());
|
||||
|
||||
// Check if the layout path was found.
|
||||
if (!$path)
|
||||
{
|
||||
throw new \RuntimeException('Layout Path Not Found');
|
||||
}
|
||||
|
||||
// Start an output buffer.
|
||||
ob_start();
|
||||
|
||||
// Load the layout.
|
||||
include $path;
|
||||
|
||||
// Get the layout contents.
|
||||
$output = ob_get_clean();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the view layout.
|
||||
*
|
||||
* @param string $layout The layout name.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setLayout($layout)
|
||||
{
|
||||
$this->layout = $layout;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the view paths.
|
||||
*
|
||||
* @param \SplPriorityQueue $paths The paths queue.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setPaths(\SplPriorityQueue $paths)
|
||||
{
|
||||
$this->paths = $paths;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Method to set the view paths.
|
||||
*
|
||||
* @param \SplPriorityQueue $paths The paths queue.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function setPaths(\SplPriorityQueue $paths)
|
||||
{
|
||||
$this->paths = $paths;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -17,37 +18,36 @@ use PatchTester\Model\AbstractModel;
|
||||
*/
|
||||
abstract class AbstractView
|
||||
{
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var AbstractModel
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $model;
|
||||
/**
|
||||
* The model object.
|
||||
*
|
||||
* @var AbstractModel
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $model;
|
||||
/**
|
||||
* Method to instantiate the view.
|
||||
*
|
||||
* @param AbstractModel $model The model object.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to instantiate the view.
|
||||
*
|
||||
* @param AbstractModel $model The model object.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function escape($output)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function escape($output)
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -8,6 +9,10 @@
|
||||
|
||||
namespace PatchTester\View;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Default HTML view class.
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -10,6 +11,10 @@ use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/** @var \PatchTester\View\DefaultHtmlView $this */
|
||||
|
||||
HTMLHelper::_('jquery.framework');
|
||||
@ -20,10 +25,10 @@ Text::script('COM_PATCHTESTER_FETCH_AN_ERROR_HAS_OCCURRED');
|
||||
?>
|
||||
|
||||
<div id="patchtester-container">
|
||||
<h1 id="patchtester-progress-header"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
|
||||
<p id="patchtester-progress-message"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
|
||||
<div id="progress" class="progress">
|
||||
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated bg-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" role="progressbar"></div>
|
||||
</div>
|
||||
<input id="patchtester-token" type="hidden" name="<?php echo Factory::getSession()->getFormToken(); ?>" value="1" />
|
||||
<h1 id="patchtester-progress-header"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
|
||||
<p id="patchtester-progress-message"><?php echo Text::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
|
||||
<div id="progress" class="progress">
|
||||
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated bg-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" role="progressbar"></div>
|
||||
</div>
|
||||
<input id="patchtester-token" type="hidden" name="<?php echo Factory::getSession()->getFormToken(); ?>" value="1" />
|
||||
</div>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -18,6 +19,10 @@ use Joomla\Registry\Registry;
|
||||
use PatchTester\TrackerHelper;
|
||||
use PatchTester\View\DefaultHtmlView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class for a list of pull requests.
|
||||
*
|
||||
@ -27,140 +32,109 @@ use PatchTester\View\DefaultHtmlView;
|
||||
*/
|
||||
class PullsHtmlView extends DefaultHtmlView
|
||||
{
|
||||
/**
|
||||
* Array containing environment errors
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $envErrors = [];
|
||||
/**
|
||||
* Array containing environment errors
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $envErrors = [];
|
||||
/**
|
||||
* Array of open pull requests
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $items;
|
||||
/**
|
||||
* Pagination object
|
||||
*
|
||||
* @var Pagination
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $pagination;
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var Form
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public $filterForm;
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public $activeFilters;
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var Registry
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $state;
|
||||
/**
|
||||
* The issue tracker project alias
|
||||
*
|
||||
* @var string|boolean
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $trackerAlias;
|
||||
/**
|
||||
* Method to render the view.
|
||||
*
|
||||
* @return string The rendered view.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @throws Exception
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
if (!extension_loaded('openssl')) {
|
||||
$this->envErrors[] = Text::_('COM_PATCHTESTER_REQUIREMENT_OPENSSL');
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of open pull requests
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $items;
|
||||
if (!in_array('https', stream_get_wrappers(), true)) {
|
||||
$this->envErrors[] = Text::_('COM_PATCHTESTER_REQUIREMENT_HTTPS');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination object
|
||||
*
|
||||
* @var Pagination
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $pagination;
|
||||
if (!count($this->envErrors)) {
|
||||
$this->state = $this->model->getState();
|
||||
$this->items = $this->model->getItems();
|
||||
$this->pagination = $this->model->getPagination();
|
||||
$this->filterForm = $this->model->getFilterForm();
|
||||
$this->activeFilters = $this->model->getActiveFilters();
|
||||
$this->trackerAlias = TrackerHelper::getTrackerAlias($this->state->get('github_user'), $this->state->get('github_repo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var Form
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public $filterForm;
|
||||
// Change the layout if there are environment errors
|
||||
if (count($this->envErrors)) {
|
||||
$this->setLayout('errors');
|
||||
}
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public $activeFilters;
|
||||
$this->addToolbar();
|
||||
Text::script('COM_PATCHTESTER_CONFIRM_RESET');
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var Registry
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected $state;
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title(Text::_('COM_PATCHTESTER'), 'patchtester fas fa-save');
|
||||
if (!count($this->envErrors)) {
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
$toolbar->appendButton('Popup', 'sync', 'COM_PATCHTESTER_TOOLBAR_FETCH_DATA', 'index.php?option=com_patchtester&view=fetch&tmpl=component', 500, 210, 0, 0, 'window.parent.location.reload()', Text::_('COM_PATCHTESTER_HEADING_FETCH_DATA'));
|
||||
// Add a reset button.
|
||||
$toolbar->appendButton('Standard', 'expired', 'COM_PATCHTESTER_TOOLBAR_RESET', 'reset', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The issue tracker project alias
|
||||
*
|
||||
* @var string|boolean
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $trackerAlias;
|
||||
|
||||
/**
|
||||
* Method to render the view.
|
||||
*
|
||||
* @return string The rendered view.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @throws Exception
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
if (!extension_loaded('openssl'))
|
||||
{
|
||||
$this->envErrors[] = Text::_('COM_PATCHTESTER_REQUIREMENT_OPENSSL');
|
||||
}
|
||||
|
||||
if (!in_array('https', stream_get_wrappers(), true))
|
||||
{
|
||||
$this->envErrors[] = Text::_('COM_PATCHTESTER_REQUIREMENT_HTTPS');
|
||||
}
|
||||
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
$this->state = $this->model->getState();
|
||||
$this->items = $this->model->getItems();
|
||||
$this->pagination = $this->model->getPagination();
|
||||
$this->filterForm = $this->model->getFilterForm();
|
||||
$this->activeFilters = $this->model->getActiveFilters();
|
||||
$this->trackerAlias = TrackerHelper::getTrackerAlias(
|
||||
$this->state->get('github_user'),
|
||||
$this->state->get('github_repo')
|
||||
);
|
||||
}
|
||||
|
||||
// Change the layout if there are environment errors
|
||||
if (count($this->envErrors))
|
||||
{
|
||||
$this->setLayout('errors');
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
Text::script('COM_PATCHTESTER_CONFIRM_RESET');
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title(Text::_('COM_PATCHTESTER'), 'patchtester fas fa-save');
|
||||
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
|
||||
$toolbar->appendButton(
|
||||
'Popup',
|
||||
'sync',
|
||||
'COM_PATCHTESTER_TOOLBAR_FETCH_DATA',
|
||||
'index.php?option=com_patchtester&view=fetch&tmpl=component',
|
||||
500,
|
||||
210,
|
||||
0,
|
||||
0,
|
||||
'window.parent.location.reload()',
|
||||
Text::_('COM_PATCHTESTER_HEADING_FETCH_DATA')
|
||||
);
|
||||
|
||||
// Add a reset button.
|
||||
$toolbar->appendButton('Standard', 'expired', 'COM_PATCHTESTER_TOOLBAR_RESET', 'reset', false);
|
||||
}
|
||||
|
||||
ToolbarHelper::preferences('com_patchtester');
|
||||
}
|
||||
ToolbarHelper::preferences('com_patchtester');
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -11,63 +12,71 @@ use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */
|
||||
|
||||
HTMLHelper::_('stylesheet', 'com_patchtester/octicons.css', ['version' => '3.5.0', 'relative' => true]);
|
||||
HTMLHelper::_('script', 'com_patchtester/patchtester.js', ['version' => 'auto', 'relative' => true]);
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php if (empty($this->items)) : ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<table class="table">
|
||||
<caption id="captionTable" class="sr-only">
|
||||
<?php echo Text::_('COM_PATCHTESTER_PULLS_TABLE_CAPTION'); ?>, <?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="width:5%" class="text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_PULL_ID'); ?>
|
||||
</th>
|
||||
<th scope="col" style="min-width:100px">
|
||||
<?php echo Text::_('JGLOBAL_TITLE'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_BRANCH'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:10%" class="text-center">
|
||||
<?php echo Text::_('JSTATUS'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:15%" class="text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php echo $this->loadTemplate('items'); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
<div id="j-main-container" class="j-main-container">
|
||||
<?php if (empty($this->items)) :
|
||||
?>
|
||||
<div class="alert alert-info">
|
||||
<span class="fa fa-info-circle" aria-hidden="true"></span><span class="sr-only"><?php echo Text::_('INFO'); ?></span>
|
||||
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<table class="table">
|
||||
<caption id="captionTable" class="sr-only">
|
||||
<?php echo Text::_('COM_PATCHTESTER_PULLS_TABLE_CAPTION'); ?>, <?php echo Text::_('JGLOBAL_SORTED_BY'); ?>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="width:5%" class="text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_PULL_ID'); ?>
|
||||
</th>
|
||||
<th scope="col" style="min-width:100px">
|
||||
<?php echo Text::_('JGLOBAL_TITLE'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_BRANCH'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:8%" class="d-none d-md-table-cell text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_READY_TO_COMMIT'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:10%" class="text-center">
|
||||
<?php echo Text::_('JSTATUS'); ?>
|
||||
</th>
|
||||
<th scope="col" style="width:15%" class="text-center">
|
||||
<?php echo Text::_('COM_PATCHTESTER_TEST_THIS_PATCH'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php echo $this->loadTemplate('items'); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
endif; ?>
|
||||
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
<input type="hidden" name="pull_id" id="pull_id" value="" />
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
<input type="hidden" name="pull_id" id="pull_id" value="" />
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -9,114 +10,141 @@
|
||||
use Joomla\CMS\Language\Text;
|
||||
use PatchTester\View\Pulls\PullsHtmlView;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/** @var PullsHtmlView $this */
|
||||
|
||||
foreach ($this->items as $i => $item) :
|
||||
$status = '';
|
||||
|
||||
if ($item->applied) :
|
||||
$status = ' class="table-active"';
|
||||
endif;
|
||||
?>
|
||||
<tr<?php echo $status; ?>>
|
||||
<th scope="row" class="text-center">
|
||||
<?php echo $item->pull_id; ?>
|
||||
<?php if ($item->is_draft) : ?>
|
||||
<span class="badge" style="color: #FFFFFF; background-color: #6e7681">
|
||||
<?php echo Text::_('COM_PATCHTESTER_IS_DRAFT'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<span><?php echo $this->escape($item->title); ?></span>
|
||||
<div role="tooltip" id="tip<?php echo $i; ?>">
|
||||
<?php echo $this->escape($item->description); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-auto">
|
||||
<a class="badge bg-info" href="<?php echo $item->pull_url; ?>" target="_blank">
|
||||
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_GITHUB'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($this->trackerAlias) : ?>
|
||||
<div class="col-md-auto">
|
||||
<a class="badge bg-info"
|
||||
href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>"
|
||||
target="_blank">
|
||||
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_JOOMLA_ISSUE_TRACKER'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->applied) : ?>
|
||||
<div class="col-md-auto">
|
||||
<span class="badge bg-info"><?php echo Text::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (count($item->labels) > 0) : ?>
|
||||
$status = '';
|
||||
if ($item->applied) :
|
||||
$status = ' class="table-active"';
|
||||
endif;
|
||||
?>
|
||||
<tr<?php echo $status; ?>>
|
||||
<th scope="row" class="text-center">
|
||||
<?php echo $item->pull_id; ?>
|
||||
<?php if ($item->is_draft) :
|
||||
?>
|
||||
<span class="badge" style="color: #FFFFFF; background-color: #6e7681">
|
||||
<?php echo Text::_('COM_PATCHTESTER_IS_DRAFT'); ?>
|
||||
</span>
|
||||
<?php
|
||||
endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<span><?php echo $this->escape($item->title); ?></span>
|
||||
<div role="tooltip" id="tip<?php echo $i; ?>">
|
||||
<?php echo $this->escape($item->description); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-auto">
|
||||
<a class="badge bg-info" href="<?php echo $item->pull_url; ?>" target="_blank">
|
||||
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_GITHUB'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($this->trackerAlias) :
|
||||
?>
|
||||
<div class="col-md-auto">
|
||||
<a class="badge bg-info"
|
||||
href="https://issues.joomla.org/tracker/<?php echo $this->trackerAlias; ?>/<?php echo $item->pull_id; ?>"
|
||||
target="_blank">
|
||||
<?php echo Text::_('COM_PATCHTESTER_VIEW_ON_JOOMLA_ISSUE_TRACKER'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
endif; ?>
|
||||
<?php if ($item->applied) :
|
||||
?>
|
||||
<div class="col-md-auto">
|
||||
<span class="badge bg-info"><?php echo Text::sprintf('COM_PATCHTESTER_APPLIED_COMMIT_SHA', substr($item->sha, 0, 10)); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php if (count($item->labels) > 0) :
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-auto">
|
||||
<?php foreach ($item->labels as $label): ?>
|
||||
<?php foreach ($item->labels as $label) :
|
||||
?>
|
||||
<?php
|
||||
switch (strtolower($label->name))
|
||||
{
|
||||
case 'a11y':
|
||||
case 'conflicting files':
|
||||
case 'documentation required':
|
||||
case 'information required':
|
||||
case 'j3 issue':
|
||||
case 'language change':
|
||||
case 'mysql 5.7':
|
||||
case 'needs new owner':
|
||||
case 'no code attached yet':
|
||||
case 'pbf':
|
||||
case 'pr-3.9-dev':
|
||||
case 'pr-3.10-dev':
|
||||
case 'pr-4.1-dev':
|
||||
case 'pr-i10n_4.0-dev':
|
||||
case 'pr-staging':
|
||||
case 'release blocker':
|
||||
case 'rfc':
|
||||
case 'test instructions missing':
|
||||
case 'updates requested':
|
||||
$textColor = '000000';
|
||||
break;
|
||||
default:
|
||||
$textColor = 'FFFFFF';
|
||||
break;
|
||||
}
|
||||
switch (strtolower($label->name)) {
|
||||
case 'a11y':
|
||||
case 'conflicting files':
|
||||
case 'documentation required':
|
||||
case 'information required':
|
||||
case 'j3 issue':
|
||||
case 'language change':
|
||||
case 'mysql 5.7':
|
||||
case 'needs new owner':
|
||||
case 'no code attached yet':
|
||||
case 'pbf':
|
||||
case 'pr-3.9-dev':
|
||||
case 'pr-3.10-dev':
|
||||
case 'pr-4.1-dev':
|
||||
case 'pr-i10n_4.0-dev':
|
||||
case 'pr-staging':
|
||||
case 'release blocker':
|
||||
case 'rfc':
|
||||
case 'test instructions missing':
|
||||
case 'updates requested':
|
||||
$textColor = '000000';
|
||||
|
||||
break;
|
||||
default:
|
||||
$textColor = 'FFFFFF';
|
||||
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<span class="badge" style="color: #<?php echo $textColor; ?>; background-color: #<?php echo $label->color; ?>"><?php echo $label->name; ?></span>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-center">
|
||||
<?php echo $this->escape($item->branch); ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-center">
|
||||
<?php if ($item->is_rtc) : ?>
|
||||
<span class="badge bg-success"><?php echo Text::_('JYES'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="badge bg-secondary"><?php echo Text::_('JNO'); ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<span class="badge bg-success"><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="badge bg-secondary"><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($item->applied) : ?>
|
||||
<button type="button" class="btn btn-sm btn-success submitPatch"
|
||||
data-task="revert" data-id="<?php echo (int) $item->applied; ?>"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
|
||||
<?php else : ?>
|
||||
<button type="button" class="btn btn-sm btn-primary submitPatch"
|
||||
data-task="apply" data-id="<?php echo (int) $item->pull_id; ?>"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-center">
|
||||
<?php echo $this->escape($item->branch); ?>
|
||||
</td>
|
||||
<td class="d-none d-md-table-cell text-center">
|
||||
<?php if ($item->is_rtc) :
|
||||
?>
|
||||
<span class="badge bg-success"><?php echo Text::_('JYES'); ?></span>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<span class="badge bg-secondary"><?php echo Text::_('JNO'); ?></span>
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($item->applied) :
|
||||
?>
|
||||
<span class="badge bg-success"><?php echo Text::_('COM_PATCHTESTER_APPLIED'); ?></span>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<span class="badge bg-secondary"><?php echo Text::_('COM_PATCHTESTER_NOT_APPLIED'); ?></span>
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($item->applied) :
|
||||
?>
|
||||
<button type="button" class="btn btn-sm btn-success submitPatch"
|
||||
data-task="revert" data-id="<?php echo (int) $item->applied; ?>"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<button type="button" class="btn btn-sm btn-primary submitPatch"
|
||||
data-task="apply" data-id="<?php echo (int) $item->pull_id; ?>"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
|
||||
<?php
|
||||
endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -8,12 +9,18 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */
|
||||
?>
|
||||
<h3><?php echo Text::_('COM_PATCHTESTER_REQUIREMENTS_HEADING'); ?></h3>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_REQUIREMENTS_NOT_MET'); ?></p>
|
||||
<ul>
|
||||
<?php foreach ($this->envErrors as $error) : ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($this->envErrors as $error) :
|
||||
?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -6,36 +7,27 @@
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
if (!Factory::getUser()->authorise('core.manage', 'com_patchtester'))
|
||||
{
|
||||
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
if (!Factory::getUser()->authorise('core.manage', 'com_patchtester')) {
|
||||
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
// Application reference
|
||||
$app = Factory::getApplication();
|
||||
|
||||
// Import our Composer autoloader to load the component classes
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Build the controller class name based on task
|
||||
$task = $app->input->getCmd('task', 'display');
|
||||
|
||||
// If $task is an empty string, apply our default since JInput might not
|
||||
if ($task === '')
|
||||
{
|
||||
$task = 'display';
|
||||
if ($task === '') {
|
||||
$task = 'display';
|
||||
}
|
||||
|
||||
$class = '\\PatchTester\\Controller\\' . ucfirst(strtolower($task)) . 'Controller';
|
||||
|
||||
if (!class_exists($class))
|
||||
{
|
||||
throw new InvalidArgumentException(Text::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class), 404);
|
||||
if (!class_exists($class)) {
|
||||
throw new InvalidArgumentException(Text::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class), 404);
|
||||
}
|
||||
|
||||
// Instantiate and execute the controller
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Patch testing component for the Joomla! CMS
|
||||
*
|
||||
@ -12,6 +13,10 @@ use Joomla\CMS\Installer\Adapter\ComponentAdapter;
|
||||
use Joomla\CMS\Installer\InstallerScript;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Installation class to perform additional changes during install/uninstall/update
|
||||
*
|
||||
@ -19,103 +24,99 @@ use Joomla\CMS\Language\Text;
|
||||
*/
|
||||
class Com_PatchtesterInstallerScript extends InstallerScript
|
||||
{
|
||||
/**
|
||||
* Extension script constructor.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->minimumJoomla = '4.0';
|
||||
$this->minimumPhp = JOOMLA_MINIMUM_PHP;
|
||||
$this->deleteFiles = array(
|
||||
'/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_errors.php',
|
||||
);
|
||||
$this->deleteFolders = array(
|
||||
'/administrator/components/com_patchtester/PatchTester/Table',
|
||||
'/components/com_patchtester',
|
||||
);
|
||||
Factory::getApplication()
|
||||
->getLanguage()
|
||||
->load('com_patchtester.sys', JPATH_ADMINISTRATOR, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension script constructor.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->minimumJoomla = '4.0';
|
||||
$this->minimumPhp = JOOMLA_MINIMUM_PHP;
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function install(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
<?php echo Text::_('COM_PATCHTESTER'); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_INSTALL_INSTRUCTIONS'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
$this->deleteFiles = array(
|
||||
'/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_errors.php',
|
||||
);
|
||||
|
||||
$this->deleteFolders = array(
|
||||
'/administrator/components/com_patchtester/PatchTester/Table',
|
||||
'/components/com_patchtester',
|
||||
);
|
||||
|
||||
Factory::getApplication()
|
||||
->getLanguage()
|
||||
->load('com_patchtester.sys', JPATH_ADMINISTRATOR, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function install(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
<?php echo Text::_('COM_PATCHTESTER'); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_INSTALL_INSTRUCTIONS'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function update(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
<?php echo Text::_('COM_PATCHTESTER'); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_UPDATE_INSTRUCTIONS'); ?></p>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function update(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
<?php echo Text::_('COM_PATCHTESTER'); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_UPDATE_INSTRUCTIONS'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function uninstall(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_UNINSTALL_THANK_YOU'); ?></p>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Show the message on install.
|
||||
*
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function uninstall(ComponentAdapter $parent): void
|
||||
{
|
||||
?>
|
||||
<h1>
|
||||
<?php echo HTMLHelper::_('image', 'media/com_patchtester/images/icon-48-patchtester.png', Text::_('COM_PATCHTESTER')); ?>
|
||||
</h1>
|
||||
<p><?php echo Text::_('COM_PATCHTESTER_UNINSTALL_THANK_YOU'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to perform changes during postflight
|
||||
*
|
||||
* @param string $type The action being performed
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function postflight(string $type, ComponentAdapter $parent): void
|
||||
{
|
||||
$this->removeFiles();
|
||||
}
|
||||
/**
|
||||
* Function to perform changes during postflight
|
||||
*
|
||||
* @param string $type The action being performed
|
||||
* @param ComponentAdapter $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function postflight(string $type, ComponentAdapter $parent): void
|
||||
{
|
||||
$this->removeFiles();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Script used to generate hashes for release packages
|
||||
*
|
||||
@ -14,16 +15,14 @@ $packageDir = dirname(__DIR__) . '/packages';
|
||||
$hashes = array();
|
||||
|
||||
/** @var DirectoryIterator $file */
|
||||
foreach (new DirectoryIterator($packageDir) as $file)
|
||||
{
|
||||
if ($file->isDir() || $file->isDot())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (new DirectoryIterator($packageDir) as $file) {
|
||||
if ($file->isDir() || $file->isDot()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hashes[$file->getFilename()] = array(
|
||||
'sha384' => hash_file('sha384', $file->getPathname()),
|
||||
);
|
||||
$hashes[$file->getFilename()] = array(
|
||||
'sha384' => hash_file('sha384', $file->getPathname()),
|
||||
);
|
||||
}
|
||||
|
||||
$jsonOptions = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT : 0;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Script used to prepare a patchtester release
|
||||
*
|
||||
@ -25,12 +26,12 @@ const PHP_TAB = "\t";
|
||||
// Functions.
|
||||
function usage($command)
|
||||
{
|
||||
echo PHP_EOL;
|
||||
echo 'Usage: php ' . $command . ' [options]' . PHP_EOL;
|
||||
echo PHP_TAB . '[options]:'.PHP_EOL;
|
||||
echo PHP_TAB . PHP_TAB . '-v <version>:' . PHP_TAB . 'Version (ex: 3.0.0, 3.0.1-dev)' . PHP_EOL;
|
||||
echo PHP_TAB . PHP_TAB . '--exclude-manifest: Exclude updating the update server manifest';
|
||||
echo PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
echo 'Usage: php ' . $command . ' [options]' . PHP_EOL;
|
||||
echo PHP_TAB . '[options]:' . PHP_EOL;
|
||||
echo PHP_TAB . PHP_TAB . '-v <version>:' . PHP_TAB . 'Version (ex: 3.0.0, 3.0.1-dev)' . PHP_EOL;
|
||||
echo PHP_TAB . PHP_TAB . '--exclude-manifest: Exclude updating the update server manifest';
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
$manifestFile = '/administrator/components/com_patchtester/patchtester.xml';
|
||||
@ -39,31 +40,27 @@ $updateServerFile = '/manifest.xml';
|
||||
// Check arguments (exit if incorrect cli arguments).
|
||||
$opts = getopt('v:', array('exclude-manifest'));
|
||||
|
||||
if (empty($opts['v']))
|
||||
{
|
||||
usage($argv[0]);
|
||||
die();
|
||||
if (empty($opts['v'])) {
|
||||
usage($argv[0]);
|
||||
die();
|
||||
}
|
||||
|
||||
// Check version string (exit if not correct).
|
||||
$versionParts = explode('-', $opts['v']);
|
||||
|
||||
if (!preg_match('#^[0-9]+\.[0-9]+\.[0-9]+$#', $versionParts[0]))
|
||||
{
|
||||
usage($argv[0]);
|
||||
die();
|
||||
if (!preg_match('#^[0-9]+\.[0-9]+\.[0-9]+$#', $versionParts[0])) {
|
||||
usage($argv[0]);
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($versionParts[1]) && !preg_match('#(dev|alpha|beta|rc)[0-9]*#', $versionParts[1]))
|
||||
{
|
||||
usage($argv[0]);
|
||||
die();
|
||||
if (isset($versionParts[1]) && !preg_match('#(dev|alpha|beta|rc)[0-9]*#', $versionParts[1])) {
|
||||
usage($argv[0]);
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($versionParts[2]) && $versionParts[2] !== 'dev')
|
||||
{
|
||||
usage($argv[0]);
|
||||
die();
|
||||
if (isset($versionParts[2]) && $versionParts[2] !== 'dev') {
|
||||
usage($argv[0]);
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure we use the correct language and timezone.
|
||||
@ -77,15 +74,15 @@ umask(022);
|
||||
$versionSubParts = explode('.', $versionParts[0]);
|
||||
|
||||
$version = array(
|
||||
'main' => $versionSubParts[0] . '.' . $versionSubParts[1],
|
||||
'release' => $versionSubParts[0] . '.' . $versionSubParts[1] . '.' . $versionSubParts[2],
|
||||
'dev_devel' => $versionSubParts[2] . (!empty($versionParts[1]) ? '-' . $versionParts[1] : '') . (!empty($versionParts[2]) ? '-' . $versionParts[2] : ''),
|
||||
'credate' => date('d-F-Y'),
|
||||
'main' => $versionSubParts[0] . '.' . $versionSubParts[1],
|
||||
'release' => $versionSubParts[0] . '.' . $versionSubParts[1] . '.' . $versionSubParts[2],
|
||||
'dev_devel' => $versionSubParts[2] . (!empty($versionParts[1]) ? '-' . $versionParts[1] : '') . (!empty($versionParts[2]) ? '-' . $versionParts[2] : ''),
|
||||
'credate' => date('d-F-Y'),
|
||||
);
|
||||
|
||||
// Prints version information.
|
||||
echo PHP_EOL;
|
||||
echo 'Version data:'. PHP_EOL;
|
||||
echo 'Version data:' . PHP_EOL;
|
||||
echo '- Main:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . PHP_EOL;
|
||||
echo '- Release:' . PHP_TAB . PHP_TAB . $version['release'] . PHP_EOL;
|
||||
echo '- Full:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . '.' . $version['dev_devel'] . PHP_EOL;
|
||||
@ -96,33 +93,30 @@ echo PHP_EOL;
|
||||
$rootPath = dirname(dirname(__DIR__));
|
||||
|
||||
// Updates the version and creation date in the component manifest file.
|
||||
if (file_exists($rootPath . $manifestFile))
|
||||
{
|
||||
$fileContents = file_get_contents($rootPath . $manifestFile);
|
||||
$fileContents = preg_replace('#<version>[^<]*</version>#', '<version>' . $version['main'] . '.' . $version['dev_devel'] . '</version>', $fileContents);
|
||||
$fileContents = preg_replace('#<creationDate>[^<]*</creationDate>#', '<creationDate>' . $version['credate'] . '</creationDate>', $fileContents);
|
||||
file_put_contents($rootPath . $manifestFile, $fileContents);
|
||||
if (file_exists($rootPath . $manifestFile)) {
|
||||
$fileContents = file_get_contents($rootPath . $manifestFile);
|
||||
$fileContents = preg_replace('#<version>[^<]*</version>#', '<version>' . $version['main'] . '.' . $version['dev_devel'] . '</version>', $fileContents);
|
||||
$fileContents = preg_replace('#<creationDate>[^<]*</creationDate>#', '<creationDate>' . $version['credate'] . '</creationDate>', $fileContents);
|
||||
file_put_contents($rootPath . $manifestFile, $fileContents);
|
||||
}
|
||||
|
||||
// Replaces the `__DEPLOY_VERSION__` marker with the "release" version number
|
||||
system('cd ' . $rootPath . ' && find administrator -name "*.php" -type f -exec sed -i "s/__DEPLOY_VERSION__/' . $version['release'] . '/g" "{}" \;');
|
||||
|
||||
// If not instructed to exclude it, update the update server's manifest
|
||||
if (!isset($opts['exclude-manifest']))
|
||||
{
|
||||
if (file_exists($rootPath . $updateServerFile))
|
||||
{
|
||||
$fileContents = file_get_contents($rootPath . $updateServerFile);
|
||||
$fileContents = preg_replace('#<infourl title="Patch Tester Component">[^<]*</infourl>#', '<infourl title="Patch Tester Component">https://github.com/joomla-extensions/patchtester/releases/tag/' . $version['release'] . '</infourl>', $fileContents);
|
||||
$fileContents = preg_replace('#<downloadurl type="full" format="zip">[^<]*</downloadurl>#', '<downloadurl type="full" format="zip">https://github.com/joomla-extensions/patchtester/releases/download/' . $version['release'] . '/com_patchtester_' . $version['release'] . '.zip</downloadurl>', $fileContents);
|
||||
file_put_contents($rootPath . $updateServerFile, $fileContents);
|
||||
if (!isset($opts['exclude-manifest'])) {
|
||||
if (file_exists($rootPath . $updateServerFile)) {
|
||||
$fileContents = file_get_contents($rootPath . $updateServerFile);
|
||||
$fileContents = preg_replace('#<infourl title="Patch Tester Component">[^<]*</infourl>#', '<infourl title="Patch Tester Component">https://github.com/joomla-extensions/patchtester/releases/tag/' . $version['release'] . '</infourl>', $fileContents);
|
||||
$fileContents = preg_replace('#<downloadurl type="full" format="zip">[^<]*</downloadurl>#', '<downloadurl type="full" format="zip">https://github.com/joomla-extensions/patchtester/releases/download/' . $version['release'] . '/com_patchtester_' . $version['release'] . '.zip</downloadurl>', $fileContents);
|
||||
file_put_contents($rootPath . $updateServerFile, $fileContents);
|
||||
|
||||
echo '*************' . PHP_EOL;
|
||||
echo '* IMPORTANT *' . PHP_EOL;
|
||||
echo '*************' . PHP_EOL;
|
||||
echo '' . PHP_EOL;
|
||||
echo 'Ensure you regenerate the SHA384 package hash before publishing the updated manifest!!!' . PHP_EOL;
|
||||
}
|
||||
echo '*************' . PHP_EOL;
|
||||
echo '* IMPORTANT *' . PHP_EOL;
|
||||
echo '*************' . PHP_EOL;
|
||||
echo '' . PHP_EOL;
|
||||
echo 'Ensure you regenerate the SHA384 package hash before publishing the updated manifest!!!' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Version bump complete!' . PHP_EOL . PHP_EOL;
|
||||
|
@ -14,8 +14,6 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"joomla/crowdin-sync": "dev-master",
|
||||
"joomla/cms-coding-standards": "~2.0.0-alpha2@dev",
|
||||
"joomla/coding-standards": "~3.0@dev",
|
||||
"squizlabs/php_codesniffer": "~3.0"
|
||||
},
|
||||
"autoload": {
|
||||
|
980
composer.lock
generated
980
composer.lock
generated
File diff suppressed because it is too large
Load Diff
32
ruleset.xml
Normal file
32
ruleset.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Joomla-CMS">
|
||||
<description>The Joomla CMS PSR-12 exceptions.</description>
|
||||
|
||||
<!-- Exclude folders not containing production code -->
|
||||
<exclude-pattern type="relative">build/packag*</exclude-pattern>
|
||||
<exclude-pattern type="relative">administrator/components/com_patchtester/vendor/*</exclude-pattern>
|
||||
|
||||
<rule ref="PSR12">
|
||||
<exclude name="Generic.Files.LineEndings"/>
|
||||
</rule>
|
||||
|
||||
<!-- temporary extend the line length -->
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="560"/>
|
||||
<property name="absoluteLineLimit" value="560"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR1.Files.SideEffects">
|
||||
<exclude-pattern type="relative">build/patchtester/release\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR1.Classes.ClassDeclaration">
|
||||
<exclude-pattern type="relative">administrator/components/com_patchtester/script\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="Squiz.Classes.ValidClassName">
|
||||
<exclude-pattern type="relative">administrator/components/com_patchtester/script\.php</exclude-pattern>
|
||||
</rule>
|
||||
</ruleset>
|
Loading…
Reference in New Issue
Block a user