Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libraries/src/TUF/DatabaseStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

/**
* @since 5.1.0
*
* @internal Currently this class is only used for Joomla! updates and will be extended in the future to support 3rd party updates
* Don't extend this class in your own code, it is subject to change without notice.
*/
class DatabaseStorage extends StorageBase
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/src/TUF/HttpLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

/**
* @since 5.1.0
*
* @internal Currently this class is only used for Joomla! updates and will be extended in the future to support 3rd party updates
* Don't extend this class in your own code, it is subject to change without notice.
*/
class HttpLoader implements LoaderInterface
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/src/TUF/TufFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

/**
* @since 5.1.0
*
* @internal Currently this class is only used for Joomla! updates and will be extended in the future to support 3rd party updates
* Don't extend this class in your own code, it is subject to change without notice.
*/
class TufFetcher
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/src/Updater/Adapter/TufAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
* TUF Update Adapter Class
*
* @since 5.1.0
*
* @internal Currently this class is only used for Joomla! updates and will be extended in the future to support 3rd party updates
* Don't extend this class in your own code, it is subject to change without notice.
*/
class TufAdapter extends UpdateAdapter
{
Expand Down
27 changes: 26 additions & 1 deletion libraries/src/Updater/ConstraintChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Version;
Expand All @@ -21,6 +22,8 @@
* ConstraintChecker Class
*
* @since 5.1.0
*
* @internal Currently this class is only used for Joomla! updates and will be extended in the future to support 3rd party updates
*/
class ConstraintChecker
{
Expand All @@ -34,16 +37,33 @@ class ConstraintChecker
*/
protected \stdClass $failedEnvironmentConstraints;

/**
* The channel to check the contraints against
*
* @var string
*/
protected $channel;

/**
* Constructor, used to populate the failed
*
* @param string|null $channel The channel to be used for updating
*
* @return void
*
* @since 5.1.0
*/
public function __construct()
public function __construct($channel = null)
{
$this->failedEnvironmentConstraints = new \stdClass();

if (!isset($channel)) {
$params = ComponentHelper::getParams('com_joomlaupdate');

$channel = (Version::MAJOR_VERSION + ($params->get('updatesource', 'default') == 'next' ? 1 : 0)) . '.x';
}

$this->channel = $channel;
}

/**
Expand All @@ -68,6 +88,11 @@ public function check(array $candidate, $minimumStability = Updater::STABILITY_S
return false;
}

// Check channel
if (isset($candidate['channel']) && $candidate['channel'] !== $this->channel) {
return false;
}

$result = true;

// Check php_minimum, assume true when not set
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Libraries/Cms/Updater/ConstraintCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Updater\ConstraintChecker;
use Joomla\CMS\Version;
use Joomla\Database\DatabaseDriver;
use Joomla\Tests\Unit\UnitTestCase;

Expand Down Expand Up @@ -40,7 +41,7 @@ class ConstraintCheckerTest extends UnitTestCase
*/
protected function setUp(): void
{
$this->checker = new ConstraintChecker();
$this->checker = new ConstraintChecker(Version::MAJOR_VERSION . '.x');
}

/**
Expand Down