Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -541,11 +542,25 @@ 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);
}

$app = Factory::getApplication();

// Run preparation plugin trigger
PluginHelper::importPlugin('installer');

$eventResult = $app->getDispatcher()->dispatch(
'onBeforeJoomlaAutoupdate',
new BeforeJoomlaAutoupdateEvent(
'onBeforeJoomlaAutoupdate'
)
);

if ($eventResult->getArgument('stoppedUpdate')) {
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'),
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ 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"
Comment thread
SniperSister marked this conversation as resolved.
Outdated
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"
COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD="Joomla Update is finishing and cleaning up"
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"
Comment thread
SniperSister marked this conversation as resolved.
Outdated
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?"
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Event/CoreEventAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions libraries/src/Event/Extension/BeforeJoomlaAutoupdateEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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['stoppedUpdate'] = false;

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

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