From f0c47a0391acc0dfa94d25958b348eb444fc4a1b Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 11:41:21 +0200 Subject: [PATCH 01/11] Implement plugin event --- .../src/Model/UpdateModel.php | 17 +++++- .../language/en-GB/com_joomlaupdate.ini | 2 + .../Extension/BeforeJoomlaAutoupdateEvent.php | 52 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index f12bc440062a5..ff84c9b2cd5f1 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -13,6 +13,7 @@ use Joomla\CMS\Authentication\Authentication; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Event\Extension\AfterJoomlaUpdateEvent; +use Joomla\CMS\Event\Extension\BeforeJoomlaAutoupdateEvent; use Joomla\CMS\Event\Extension\BeforeJoomlaUpdateEvent; use Joomla\CMS\Extension\ExtensionHelper; use Joomla\CMS\Factory; @@ -541,7 +542,21 @@ public function prepareAutoUpdate(string $targetVersion): array } if (!$this->createUpdateFile($fileInformation['basename'])) { - throw new \Exception('Could not write update file', 410); + throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE'), 410); + } + + // Run preparation plugin trigger + PluginHelper::importPlugin('installer'); + + $eventResult = $app->getDispatcher()->dispatch( + 'onBeforeJoomlaAutoupdate', + new BeforeJoomlaAutoupdateEvent( + 'onBeforeJoomlaAutoupdate' + ) + ); + + if ($eventResult->getArgument('stopUpdate')) { + throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } $app = Factory::getApplication(); diff --git a/administrator/language/en-GB/com_joomlaupdate.ini b/administrator/language/en-GB/com_joomlaupdate.ini index cc0d4cf9012e6..9654765743a13 100644 --- a/administrator/language/en-GB/com_joomlaupdate.ini +++ b/administrator/language/en-GB/com_joomlaupdate.ini @@ -209,6 +209,7 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update J COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESREAD="Bytes read" COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG="File Checksum Failed" +COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE="Could not write update file" COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED="Download of update package failed." COM_JOOMLAUPDATE_VIEW_UPDATE_FILESEXTRACTED="Files extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_CONFIRM_AND_CONTINUE="Confirm & Continue" @@ -216,6 +217,7 @@ COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD="Joomla Update is finishing and clean COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD_DESC="To complete the update Process please confirm your identity by re-entering the login information for your site "%s" below." COM_JOOMLAUPDATE_VIEW_UPDATE_ITEMS="items" COM_JOOMLAUPDATE_VIEW_UPDATE_PERCENT="Percent complete" +COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN="Update stopped by plugin" COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG="The version of the update package and the requested version do not match, try to refresh the update information." COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_BODY="Make sure that the update file you have uploaded comes from the official Joomla download page. Afterwards, please confirm that you want to install it by re-entering the login information for your site "%s" below." COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_HEAD="Are you sure you want to install the file you uploaded?" diff --git a/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php b/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php new file mode 100644 index 0000000000000..10fbbab13ab21 --- /dev/null +++ b/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php @@ -0,0 +1,52 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Event\Extension; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + +/** + * Class for Joomla Auto Update events + * + * @since __DEPLOY_VERSION__ + */ +class BeforeJoomlaAutoupdateEvent extends AbstractJoomlaUpdateEvent +{ + /** + * Constructor. + * + * @param string $name The event name. + * @param array $arguments The event arguments. + * + * @throws \BadMethodCallException + * + * @since __DEPLOY_VERSION__ + */ + public function __construct($name, array $arguments = []) + { + $arguments['stopUpdate'] = false; + + parent::__construct($name, $arguments); + } + + /** + * Set stop parameter to true + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function setStopUpdate() + { + $this->arguments['stopUpdate'] = true; + $this->stopPropagation(); + } +} From 7e2d0bd06b9ce46d1f80a8c010b1672f53decc26 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 11:48:11 +0200 Subject: [PATCH 02/11] move app call --- .../components/com_joomlaupdate/src/Model/UpdateModel.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index ff84c9b2cd5f1..695d0320cffe5 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -545,6 +545,8 @@ public function prepareAutoUpdate(string $targetVersion): array throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE'), 410); } + $app = Factory::getApplication(); + // Run preparation plugin trigger PluginHelper::importPlugin('installer'); @@ -558,9 +560,6 @@ public function prepareAutoUpdate(string $targetVersion): array if ($eventResult->getArgument('stopUpdate')) { throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } - - $app = Factory::getApplication(); - return [ 'password' => $app->getUserState('com_joomlaupdate.password'), 'filesize' => $app->getUserState('com_joomlaupdate.filesize'), From 65ba63c750885fd4dfe71a5d535cdff330a48743 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 11:56:12 +0200 Subject: [PATCH 03/11] add line break --- .../components/com_joomlaupdate/src/Model/UpdateModel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 695d0320cffe5..49cf106984a87 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -560,6 +560,7 @@ public function prepareAutoUpdate(string $targetVersion): array if ($eventResult->getArgument('stopUpdate')) { throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } + return [ 'password' => $app->getUserState('com_joomlaupdate.password'), 'filesize' => $app->getUserState('com_joomlaupdate.filesize'), From 78f8637f48c8cfa41c3a0fd842580b2cfb0046bb Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 12:25:00 +0200 Subject: [PATCH 04/11] update argument and method name --- .../components/com_joomlaupdate/src/Model/UpdateModel.php | 2 +- libraries/src/Event/CoreEventAware.php | 1 + .../src/Event/Extension/BeforeJoomlaAutoupdateEvent.php | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 49cf106984a87..411a08634e0d3 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -557,7 +557,7 @@ public function prepareAutoUpdate(string $targetVersion): array ) ); - if ($eventResult->getArgument('stopUpdate')) { + if ($eventResult->getArgument('stoppedUpdate')) { throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } diff --git a/libraries/src/Event/CoreEventAware.php b/libraries/src/Event/CoreEventAware.php index ce55048350968..d2af70f6e63d2 100644 --- a/libraries/src/Event/CoreEventAware.php +++ b/libraries/src/Event/CoreEventAware.php @@ -155,6 +155,7 @@ trait CoreEventAware 'onExtensionAfterSave' => Model\AfterSaveEvent::class, 'onExtensionAfterDelete' => Model\AfterDeleteEvent::class, 'onExtensionChangeState' => Model\BeforeChangeStateEvent::class, + 'onJoomlaBeforeAutoupdate' => Extension\BeforeJoomlaAutoupdateEvent::class, 'onJoomlaBeforeUpdate' => Extension\BeforeJoomlaUpdateEvent::class, 'onJoomlaAfterUpdate' => Extension\AfterJoomlaUpdateEvent::class, // Installer diff --git a/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php b/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php index 10fbbab13ab21..78e09724aa664 100644 --- a/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php +++ b/libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php @@ -32,7 +32,7 @@ class BeforeJoomlaAutoupdateEvent extends AbstractJoomlaUpdateEvent */ public function __construct($name, array $arguments = []) { - $arguments['stopUpdate'] = false; + $arguments['stoppedUpdate'] = false; parent::__construct($name, $arguments); } @@ -44,9 +44,9 @@ public function __construct($name, array $arguments = []) * * @since __DEPLOY_VERSION__ */ - public function setStopUpdate() + public function stopUpdate() { - $this->arguments['stopUpdate'] = true; + $this->arguments['stoppedUpdate'] = true; $this->stopPropagation(); } } From 880d001892b0f9e5be14e8aedf4cdad8103f4514 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 12:31:09 +0200 Subject: [PATCH 05/11] Update administrator/language/en-GB/com_joomlaupdate.ini Co-authored-by: Brian Teeman --- administrator/language/en-GB/com_joomlaupdate.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/com_joomlaupdate.ini b/administrator/language/en-GB/com_joomlaupdate.ini index 9654765743a13..b183994797bcc 100644 --- a/administrator/language/en-GB/com_joomlaupdate.ini +++ b/administrator/language/en-GB/com_joomlaupdate.ini @@ -217,7 +217,7 @@ COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD="Joomla Update is finishing and clean COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD_DESC="To complete the update Process please confirm your identity by re-entering the login information for your site "%s" below." COM_JOOMLAUPDATE_VIEW_UPDATE_ITEMS="items" COM_JOOMLAUPDATE_VIEW_UPDATE_PERCENT="Percent complete" -COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN="Update stopped by plugin" +COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN="Update stopped by plugin." COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG="The version of the update package and the requested version do not match, try to refresh the update information." COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_BODY="Make sure that the update file you have uploaded comes from the official Joomla download page. Afterwards, please confirm that you want to install it by re-entering the login information for your site "%s" below." COM_JOOMLAUPDATE_VIEW_UPLOAD_CAPTIVE_INTRO_HEAD="Are you sure you want to install the file you uploaded?" From b4db17bb6125f9157b68a976659ad8a00dbc8968 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 7 Jul 2025 12:31:15 +0200 Subject: [PATCH 06/11] Update administrator/language/en-GB/com_joomlaupdate.ini Co-authored-by: Brian Teeman --- administrator/language/en-GB/com_joomlaupdate.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/com_joomlaupdate.ini b/administrator/language/en-GB/com_joomlaupdate.ini index b183994797bcc..91a7ecdbdaa7d 100644 --- a/administrator/language/en-GB/com_joomlaupdate.ini +++ b/administrator/language/en-GB/com_joomlaupdate.ini @@ -209,7 +209,7 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update J COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESREAD="Bytes read" COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG="File Checksum Failed" -COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE="Could not write update file" +COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE="Could not write update file." COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED="Download of update package failed." COM_JOOMLAUPDATE_VIEW_UPDATE_FILESEXTRACTED="Files extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_CONFIRM_AND_CONTINUE="Confirm & Continue" From 11f86f81d1dc596b5be02e9b3117b1c98b66d841 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Thu, 17 Jul 2025 13:58:27 +0200 Subject: [PATCH 07/11] adjust exception type --- .../com_joomlaupdate/src/Model/UpdateModel.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 411a08634e0d3..0a8cb79f4a9c1 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -23,6 +23,7 @@ use Joomla\CMS\Installer\Installer; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; +use Joomla\CMS\MVC\Controller\Exception\CheckinCheckout; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Plugin\PluginHelper; @@ -41,6 +42,7 @@ use Joomla\Filesystem\File; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; +use Tobscure\JsonApi\Exception\InvalidParameterException; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -534,15 +536,15 @@ public function prepareAutoUpdate(string $targetVersion): array $fileInformation = $this->download(); if ($fileInformation['version'] !== $targetVersion) { - throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG'), 410); + throw new InvalidParameterException(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG'), 410); } if ($fileInformation['check'] === false) { - throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG'), 410); + throw new InvalidParameterException(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG'), 410); } if (!$this->createUpdateFile($fileInformation['basename'])) { - throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE'), 410); + throw new InvalidParameterException(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_COULD_NOT_WRITE_UPDATE_FILE'), 410); } $app = Factory::getApplication(); @@ -558,7 +560,7 @@ public function prepareAutoUpdate(string $targetVersion): array ); if ($eventResult->getArgument('stoppedUpdate')) { - throw new \Exception(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); + throw new CheckinCheckout(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } return [ From 233164feb69e1fa7dca122957eac62eb88b16925 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Fri, 8 Aug 2025 11:51:55 +0200 Subject: [PATCH 08/11] fix stan issue --- .../components/com_joomlaupdate/src/Model/UpdateModel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 0815ffe340b9d..0e2fb000408f8 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -552,7 +552,7 @@ public function prepareAutoUpdate(string $targetVersion): array // Run preparation plugin trigger PluginHelper::importPlugin('installer'); - $eventResult = $app->getDispatcher()->dispatch( + $eventResult = $this->getDispatcher()->dispatch( 'onBeforeJoomlaAutoupdate', new BeforeJoomlaAutoupdateEvent( 'onBeforeJoomlaAutoupdate' @@ -840,7 +840,7 @@ public function createUpdateFile($basename = null): bool $app = Factory::getApplication(); // Trigger event before joomla update. - $app->getDispatcher()->dispatch('onJoomlaBeforeUpdate', new BeforeJoomlaUpdateEvent('onJoomlaBeforeUpdate')); + $this->getDispatcher()->dispatch('onJoomlaBeforeUpdate', new BeforeJoomlaUpdateEvent('onJoomlaBeforeUpdate')); // Get the absolute path to site's root. $siteroot = JPATH_SITE; @@ -1177,7 +1177,7 @@ public function cleanUp() $oldVersion = $app->getUserState('com_joomlaupdate.oldversion'); // Trigger event after joomla update. - $app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate', [ + $this->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate', [ 'oldVersion' => $oldVersion ?: '', ])); $app->setUserState('com_joomlaupdate.oldversion', null); From be5d2c955498d3a4b872af6a9f472529f9592e30 Mon Sep 17 00:00:00 2001 From: David Jardin Date: Mon, 11 Aug 2025 16:57:42 +0200 Subject: [PATCH 09/11] Write reason to log file --- .../components/com_joomlaupdate/src/Model/UpdateModel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 0e2fb000408f8..f268b1b64275f 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -560,6 +560,8 @@ public function prepareAutoUpdate(string $targetVersion): array ); if ($eventResult->getArgument('stoppedUpdate')) { + Log::add(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), Log::ERROR, 'Update'); + throw new CheckinCheckout(Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN'), 503); } From 847886173905e9847bbdea46a040806e188fa7de Mon Sep 17 00:00:00 2001 From: David Jardin Date: Tue, 12 Aug 2025 15:30:02 +0200 Subject: [PATCH 10/11] fix version number in error notitications --- .../com_joomlaupdate/src/Model/NotificationModel.php | 4 ++-- .../src/Controller/NotificationController.php | 9 ++++++--- .../src/View/Notification/JsonapiView.php | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/administrator/components/com_joomlaupdate/src/Model/NotificationModel.php b/administrator/components/com_joomlaupdate/src/Model/NotificationModel.php index 08409055c75e9..f794cee9a2ea9 100644 --- a/administrator/components/com_joomlaupdate/src/Model/NotificationModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/NotificationModel.php @@ -39,12 +39,13 @@ final class NotificationModel extends BaseDatabaseModel * * @param string $type The type of notification to send. This is the last key for the mail template * @param string $oldVersion The old version from before the update + * @param string $newVersion The new version from after the update * * @return void * * @since 5.4.0 */ - public function sendNotification($type, $oldVersion): void + public function sendNotification($type, $oldVersion, $newVersion): void { $params = ComponentHelper::getParams('com_joomlaupdate'); @@ -58,7 +59,6 @@ public function sendNotification($type, $oldVersion): void $app = Factory::getApplication(); $jLanguage = $app->getLanguage(); $sitename = $app->get('sitename'); - $newVersion = (new Version())->getShortVersion(); $substitutions = [ 'oldversion' => $oldVersion, diff --git a/api/components/com_joomlaupdate/src/Controller/NotificationController.php b/api/components/com_joomlaupdate/src/Controller/NotificationController.php index e54086e232203..6f60e02edf376 100644 --- a/api/components/com_joomlaupdate/src/Controller/NotificationController.php +++ b/api/components/com_joomlaupdate/src/Controller/NotificationController.php @@ -11,6 +11,7 @@ namespace Joomla\Component\Joomlaupdate\Api\Controller; use Joomla\CMS\Language\Text; +use Joomla\Component\Joomlaupdate\Administrator\Model\NotificationModel; use Joomla\Component\Joomlaupdate\Api\View\Updates\JsonapiView; // phpcs:disable PSR1.Files.SideEffects @@ -50,10 +51,11 @@ public function failed() $this->validateUpdateToken(); $fromVersion = $this->input->json->getString('fromVersion', null); + $toVersion = $this->input->json->getString('toVersion', null); $view = $this->prepareView(); - $view->notification('failed', $fromVersion); + $view->notification('failed', $fromVersion, $toVersion); return $this; } @@ -70,10 +72,11 @@ public function success() $this->validateUpdateToken(); $fromVersion = $this->input->json->getString('fromVersion', null); + $toVersion = $this->input->json->getString('toVersion', null); $view = $this->prepareView(); - $view->notification('success', $fromVersion); + $view->notification('success', $fromVersion, $toVersion); return $this; } @@ -101,7 +104,7 @@ protected function prepareView() throw new \RuntimeException($e->getMessage()); } - /** @var UpdateModel $model */ + /** @var NotificationModel $model */ $model = $this->getModel('Notification', 'Administrator', ['ignore_request' => true, 'state' => $this->modelState]); if (!$model) { diff --git a/api/components/com_joomlaupdate/src/View/Notification/JsonapiView.php b/api/components/com_joomlaupdate/src/View/Notification/JsonapiView.php index 9097e67756e18..0343f485c3a2b 100644 --- a/api/components/com_joomlaupdate/src/View/Notification/JsonapiView.php +++ b/api/components/com_joomlaupdate/src/View/Notification/JsonapiView.php @@ -33,7 +33,7 @@ class JsonapiView extends BaseApiView * * @since 5.4.0 */ - public function notification($type, $oldVersion) + public function notification($type, $oldVersion, $newVersion) { /** * @var UpdateModel $model @@ -43,7 +43,7 @@ public function notification($type, $oldVersion) try { // Perform the finalization action - $model->sendNotification($type, $oldVersion); + $model->sendNotification($type, $oldVersion, $newVersion); } catch (\Throwable $e) { $success = false; } From 5a6662fade2627a42132847b174c37bb44bee60e Mon Sep 17 00:00:00 2001 From: David Jardin Date: Wed, 13 Aug 2025 08:32:02 +0200 Subject: [PATCH 11/11] cs fix --- .../src/Controller/NotificationController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/components/com_joomlaupdate/src/Controller/NotificationController.php b/api/components/com_joomlaupdate/src/Controller/NotificationController.php index 6f60e02edf376..da52aa37fc63b 100644 --- a/api/components/com_joomlaupdate/src/Controller/NotificationController.php +++ b/api/components/com_joomlaupdate/src/Controller/NotificationController.php @@ -51,7 +51,7 @@ public function failed() $this->validateUpdateToken(); $fromVersion = $this->input->json->getString('fromVersion', null); - $toVersion = $this->input->json->getString('toVersion', null); + $toVersion = $this->input->json->getString('toVersion', null); $view = $this->prepareView(); @@ -72,7 +72,7 @@ public function success() $this->validateUpdateToken(); $fromVersion = $this->input->json->getString('fromVersion', null); - $toVersion = $this->input->json->getString('toVersion', null); + $toVersion = $this->input->json->getString('toVersion', null); $view = $this->prepareView();