Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -545,9 +546,24 @@ public function prepareAutoUpdate(string $targetVersion): array

$app = Factory::getApplication();

// 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);
}

return [
'password' => $app->getUserState('com_joomlaupdate.password'),
'filesize' => $app->getUserState('com_joomlaupdate.filesize'),
'password' => $app->getUserState('com_joomlaupdate.password'),
'filesize' => $app->getUserState('com_joomlaupdate.filesize'),
'preparationUrls' => $eventResult->getArgument('preparationUrls')
];
}

Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG="File Checksum Failed"
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_UPDATE_DOWNLOADFAILED="Download of update package failed."
COM_JOOMLAUPDATE_VIEW_UPDATE_ITEMS="items"
COM_JOOMLAUPDATE_VIEW_UPDATE_STOPPED_BY_PLUGIN="Update stopped by plugin."
COM_JOOMLAUPDATE_VIEW_UPDATE_FILESEXTRACTED="Files extracted"
COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_CONFIRM_AND_CONTINUE="Confirm & Continue"
COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD="Joomla Update is finishing and cleaning up"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function prepareUpdate(string $targetVersion): string
$fileinformation['id'] = 'prepareUpdate';

$element = (new Resource((object) $fileinformation, $this->serializer))
->fields(['updates' => ['password', 'filesize']]);
->fields(['updates' => ['password', 'filesize', 'preparationUrls']]);

$this->getDocument()->setData($element);
$this->getDocument()->addLink('self', Uri::current());
Expand Down
67 changes: 67 additions & 0 deletions libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* Joomla! Content Management System
*
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
* @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;
$arguments['preparationUrls'] = [];

parent::__construct($name, $arguments);
}

/**
* Set stop parameter to true
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function setStopUpdate()
{
$this->arguments['stopUpdate'] = true;
$this->stopPropagation();
}

/**
* Appends a preparation url to the url queue
*
* @param string $preparationUrl
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function addPreparationUrl(string $preparationUrl)
{
$this->arguments['preparationUrls'][] = $preparationUrl;
}
}