Skip to content

Commit 608988f

Browse files
committed
Merge remote-tracking branch 'upstream/5.4-dev' into upmerges/2025-06-04
2 parents 81fda05 + 7c3fb52 commit 608988f

File tree

124 files changed

+440
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+440
-218
lines changed

administrator/components/com_joomlaupdate/src/Controller/UpdateController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ public function healthstatus()
747747

748748
$result = [
749749
'active' => true,
750-
'healthy' => $result,
750+
'healthy' => $result->value,
751751
];
752752

753753
echo json_encode($result);
@@ -764,7 +764,7 @@ public function healthstatus()
764764
&& $params->get('updatesource', 'default') === 'default'
765765
&& (int) $params->get('minimum_stability', Updater::STABILITY_STABLE) === Updater::STABILITY_STABLE
766766
),
767-
'healthy' => $lastCheck !== false && $lastCheck->diff(new \DateTime())->days < 4,
767+
'healthy' => (int) ($lastCheck !== false && $lastCheck->diff(new \DateTime())->days < 4),
768768
];
769769

770770
echo json_encode($result);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.Administrator
5+
* @subpackage com_joomlaupdate
6+
*
7+
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
8+
* @license GNU General Public License version 2 or later; see LICENSE.txt
9+
*/
10+
11+
namespace Joomla\Component\Joomlaupdate\Administrator\Enum;
12+
13+
// phpcs:disable PSR1.Files.SideEffects
14+
\defined('_JEXEC') or die;
15+
// phpcs:enable PSR1.Files.SideEffects
16+
17+
/**
18+
* Autoupdate State Enum
19+
*/
20+
enum AutoupdateRegisterResultState: int
21+
{
22+
case Failed = -1;
23+
case Unavailable = 0;
24+
case Success = 1;
25+
}

administrator/components/com_joomlaupdate/src/Model/UpdateModel.php

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Joomla\CMS\Uri\Uri;
3434
use Joomla\CMS\User\UserHelper;
3535
use Joomla\CMS\Version;
36+
use Joomla\Component\Joomlaupdate\Administrator\Enum\AutoupdateRegisterResultState;
3637
use Joomla\Component\Joomlaupdate\Administrator\Enum\AutoupdateRegisterState;
3738
use Joomla\Database\ParameterType;
3839
use Joomla\Filesystem\Exception\FilesystemException;
@@ -548,17 +549,18 @@ public function prepareAutoUpdate(string $targetVersion): array
548549
return [
549550
'password' => $app->getUserState('com_joomlaupdate.password'),
550551
'filesize' => $app->getUserState('com_joomlaupdate.filesize'),
552+
'filename' => $app->getUserState('com_joomlaupdate.file'),
551553
];
552554
}
553555

554556
/**
555557
* Change the registration state of a site in the update service
556558
*
557-
* @return bool
559+
* @return AutoupdateRegisterResultState
558560
*
559561
* @since 5.4.0
560562
*/
561-
public function changeAutoUpdateRegistration(AutoupdateRegisterState $targetState)
563+
public function changeAutoUpdateRegistration(AutoupdateRegisterState $targetState): AutoupdateRegisterResultState
562564
{
563565
// Purge cache - this makes sure that the changed status will already be available if the health check is performed
564566
$this->cleanCache('_system');
@@ -583,47 +585,82 @@ public function changeAutoUpdateRegistration(AutoupdateRegisterState $targetStat
583585
} catch (\RuntimeException $e) {
584586
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
585587

586-
return false;
588+
return AutoupdateRegisterResultState::Failed;
587589
}
588590

589591
// Decode response
590592
$result = json_decode((string)$response->getBody(), true);
591593

592-
// Handle non-success response
594+
// Handle validation issue
595+
if ($response->getStatusCode() === 422) {
596+
// Append message
597+
Factory::getApplication()->enqueueMessage(
598+
Text::sprintf(
599+
'COM_JOOMLAUPDATE_AUTOUPDATE_REGISTER_UNAVAILABLE',
600+
),
601+
'warning'
602+
);
603+
604+
$this->updateAutoUpdateParams(
605+
AutoupdateRegisterState::Unsubscribed,
606+
false
607+
);
608+
609+
return AutoupdateRegisterResultState::Unavailable;
610+
}
611+
612+
// Handle other non-success response
593613
if ($response->getStatusCode() !== 200) {
594614
Factory::getApplication()->enqueueMessage(
595615
Text::sprintf(
596616
'COM_JOOMLAUPDATE_AUTOUPDATE_REGISTER_ERROR',
597-
$result['message'],
598-
$result['status']
617+
$result['message'] ?: '',
618+
$result['status'] ?: ''
599619
),
600620
'error'
601621
);
602622

603-
return false;
623+
$this->updateAutoUpdateParams(
624+
AutoupdateRegisterState::Unsubscribed,
625+
false
626+
);
627+
628+
return AutoupdateRegisterResultState::Failed;
604629
}
605630

631+
$this->updateAutoUpdateParams(
632+
($targetState === AutoupdateRegisterState::Subscribe)
633+
? AutoupdateRegisterState::Subscribed
634+
: AutoupdateRegisterState::Unsubscribed,
635+
($targetState === AutoupdateRegisterState::Unsubscribed)
636+
);
637+
638+
return AutoupdateRegisterResultState::Success;
639+
}
640+
641+
/**
642+
* Update the autoupdate activation and registration states
643+
*
644+
* @since __DEPLOY_VERSION__
645+
*/
646+
protected function updateAutoUpdateParams(AutoupdateRegisterState $registrationState, bool $enableUpdate): void
647+
{
606648
// Get extension row
607649
$extension = new Extension($this->getDatabase());
608650
$extensionId = $extension->find(['element' => 'com_joomlaupdate']);
609651
$extension->load($extensionId);
610652

611653
// Set new update registration state
612654
$params = new Registry($extension->params);
613-
$params->set(
614-
'autoupdate_status',
615-
($targetState === AutoupdateRegisterState::Subscribe)
616-
? AutoupdateRegisterState::Subscribed->value
617-
: AutoupdateRegisterState::Unsubscribed->value
618-
);
655+
656+
$params->set('autoupdate_status', $registrationState->value);
657+
$params->set('autoupdate', (int) $enableUpdate);
619658

620659
$extension->params = $params->toString();
621660

622661
if (!$extension->store()) {
623662
throw new \RuntimeException($extension->getError());
624663
}
625-
626-
return true;
627664
}
628665

629666
/**
@@ -1347,15 +1384,36 @@ public function getPhpOptions()
13471384
$options[] = $option;
13481385
$updateInformation = $this->getUpdateInformation();
13491386

1350-
// Check if configured database is compatible with the next major version of Joomla
1351-
$nextMajorVersion = Version::MAJOR_VERSION + 1;
1352-
1353-
if (version_compare($updateInformation['latest'], (string) $nextMajorVersion, '>=')) {
1387+
// Extra checks when updating to the next major version of Joomla
1388+
if (version_compare($updateInformation['latest'], (string) Version::MAJOR_VERSION + 1, '>=')) {
1389+
// Check if configured database is compatible with the next major version of Joomla
13541390
$option = new \stdClass();
13551391
$option->label = Text::sprintf('INSTL_DATABASE_SUPPORTED', $this->getConfiguredDatabaseType());
13561392
$option->state = $this->isDatabaseTypeSupported();
13571393
$option->notice = null;
13581394
$options[] = $option;
1395+
1396+
// Check if the Joomla 5 backwards compatibility plugin is disabled
1397+
$plugin = ExtensionHelper::getExtensionRecord('compat', 'plugin', 0, 'behaviour');
1398+
1399+
$this->translateExtensionName($plugin);
1400+
1401+
$option = new \stdClass();
1402+
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_TITLE', $plugin->name);
1403+
$option->state = !PluginHelper::isEnabled('behaviour', 'compat');
1404+
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_NOTICE', $plugin->folder, $plugin->element);
1405+
$options[] = $option;
1406+
1407+
// Check if the Joomla 6 backwards compatibility plugin is enabled
1408+
$plugin = ExtensionHelper::getExtensionRecord('compat6', 'plugin', 0, 'behaviour');
1409+
1410+
$this->translateExtensionName($plugin);
1411+
1412+
$option = new \stdClass();
1413+
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_TITLE', $plugin->name);
1414+
$option->state = PluginHelper::isEnabled('behaviour', 'compat6');
1415+
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_NOTICE', $plugin->folder, $plugin->element);
1416+
$options[] = $option;
13591417
}
13601418

13611419
// Check if database structure is up to date

0 commit comments

Comments
 (0)