Click to expand the diff!
```diff
diff --git a/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php b/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php
index b03b7d6dc31eb..dba5f257ae347 100644
--- a/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php
+++ b/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php
@@ -71,6 +71,7 @@ public function display($cachable = false, $urlparams = false)
$state = $model->getState();
$state->set('update_finished_with_error', $this->app->getUserState('com_joomlaupdate.update_finished_with_error'));
$state->set('update_errors', (array) $this->app->getUserState('com_joomlaupdate.update_errors', []));
+ $state->set('update_channel_reset', $this->app->getUserState('com_joomlaupdate.update_channel_reset'));
$state->set('installer_message', $this->app->getUserState('com_joomlaupdate.installer_message'));
$state->set('log_file', $this->app->get('log_path') . '/joomla_update.php');
}
diff --git a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
index 727f4edd9e9c3..f63a4dd7de605 100644
--- a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
+++ b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php
@@ -156,6 +156,9 @@ public function finalise()
$model->collectError('finaliseUpgrade', $e);
}
+ // Reset update source from "Joomla Next" to "Default"
+ $this->app->setUserState('com_joomlaupdate.update_channel_reset', $model->resetUpdateSource());
+
// Check for update errors
if ($model->getErrors()) {
// The errors already should be logged at this point
diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
index b28ed81f2c716..802c6effdcafe 100644
--- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
+++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
@@ -2027,4 +2027,73 @@ private function checkManifestXML(string $manifest, $packageName)
throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE', $packageName, $versionPackage, $currentVersion), 500);
}
}
+
+ /**
+ * Reset update source from "next" to "default"
+ *
+ * @return boolean True if update source is reset, false if reset failed with error,
+ * null if no reset was necessary.
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function resetUpdateSource()
+ {
+ // Get current update source
+ $params = ComponentHelper::getParams('com_joomlaupdate');
+
+ // Do nothing if not "next"
+ if ($params->get('updatesource', 'default') !== 'next') {
+ return null;
+ }
+
+ $params->set('updatesource', 'default');
+
+ $params = $params->toString();
+ $db = $this->getDatabase();
+ $query = $db->getQuery(true)
+ ->update($db->quoteName('#__extensions'))
+ ->set($db->quoteName('params') . ' = :params')
+ ->where($db->quoteName('type') . ' = ' . $db->quote('component'))
+ ->where($db->quoteName('element') . ' = ' . $db->quote('com_joomlaupdate'))
+ ->bind(':params', $params);
+
+ try {
+ $db->setQuery($query);
+ $db->execute();
+ } catch (\Exception $e) {
+ Log::add(
+ sprintf(
+ 'An error has occurred while running "resetUpdateSource". Code: %s. Message: %s.',
+ $e->getCode(),
+ $e->getMessage()
+ ),
+ Log::WARNING,
+ 'Update'
+ );
+
+ Log::add(
+ Text::sprintf(
+ 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED',
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'),
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT')
+ ),
+ Log::WARNING,
+ 'Update'
+ );
+
+ return false;
+ }
+
+ Log::add(
+ Text::sprintf(
+ 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_OK',
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'),
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT')
+ ),
+ Log::INFO,
+ 'Update'
+ );
+
+ return true;
+ }
}
diff --git a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php
index 53b17ccf0fc6c..2920c2a26b060 100644
--- a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php
+++ b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php
@@ -19,6 +19,7 @@
$hadErrors = $this->state->get('update_finished_with_error');
$errors = $this->state->get('update_errors');
+$channelReset = $this->state->get('update_channel_reset');
$logFile = $this->state->get('log_file');
$installerMsg = $this->state->get('installer_message');
$forumLink = 'https://forum.joomla.org/';
@@ -27,6 +28,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/administrator/language/en-GB/com_joomlaupdate.ini b/administrator/language/en-GB/com_joomlaupdate.ini
index 5902c52891851..66daf5ab8fdb9 100644
--- a/administrator/language/en-GB/com_joomlaupdate.ini
+++ b/administrator/language/en-GB/com_joomlaupdate.ini
@@ -69,6 +69,8 @@ COM_JOOMLAUPDATE_SELF_EMPTYSTATE_CONTENT="You must update this component first b
COM_JOOMLAUPDATE_SELF_EMPTYSTATE_TITLE="A new version of the Joomla Update Component is available"
COM_JOOMLAUPDATE_SYSTEM_CHECK="System Check"
COM_JOOMLAUPDATE_TOOLBAR_CHECK="Check for Updates"
+COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED="Failed to reset the update channel from \"%1$s\" to \"%2$s\". Please change it in the Joomla Update Component's options so you don't miss future updates."
+COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_OK="The update channel has been reset from \"%1$s\" to \"%2$s\"."
COM_JOOMLAUPDATE_UPDATE_CHECK="Update Check"
COM_JOOMLAUPDATE_UPDATE_CONFIRM_BACKUP="I'm aware that a backup before any update is highly recommended."
COM_JOOMLAUPDATE_UPDATE_EMPTYSTATE_TITLE="Update your site to \"Joomla! %s\""
@@ -169,7 +171,7 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATE_NOTICE="Before you update Joomla, ensure th
COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATEFOUND="A Joomla update was found."
COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATES_INFO_CUSTOM="You are on the "%s" update channel. This is not an official Joomla update channel."
COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATES_INFO_DEFAULT="You are on the "%s" update channel. Through this channel you'll receive notifications for all updates of the current Joomla release (5.x)"
-COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATES_INFO_NEXT="You are on the "%s" update channel. Through this channel you'll receive notifications for all updates of the current Joomla release (5.x) and you will also be notified when the future major release (6.x) will be available. Before upgrading to 6.x you'll need to assess its compatibility with your environment."
+COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATES_INFO_NEXT="You are on the "%s" update channel. Through this channel you will be notified when the future major release (6.x) will be available. Before upgrading to 6.x you'll need to assess its compatibility with your environment. You will not be notified about updates of the current Joomla release (5.x)."
COM_JOOMLAUPDATE_VIEW_DEFAULT_UPDATES_INFO_TESTING="You are on the "%s" update channel. This channel is designed for testing new releases and fixes in Joomla. It is only intended for JBS (Joomla Bug Squad™) members and others within the Joomla community who are testing. Do not use this setting on a production site."
COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update Joomla if your server is behind a firewall or otherwise unable to contact the update servers. First download the Joomla Update Package in ZIP format from the official Joomla download page. Then use the fields below to upload and install it."
COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted"
diff --git a/libraries/src/Console/UpdateCoreCommand.php b/libraries/src/Console/UpdateCoreCommand.php
index 8a28fe15aab31..bef4f091c4722 100644
--- a/libraries/src/Console/UpdateCoreCommand.php
+++ b/libraries/src/Console/UpdateCoreCommand.php
@@ -272,6 +272,24 @@ private function updateJoomlaCore($updatemodel): bool
$result = $updatemodel->finaliseUpgrade();
if ($result) {
+ $updateSourceChanged = $updatemodel->resetUpdateSource();
+
+ if ($updateSourceChanged) {
+ $message = Text::sprintf(
+ 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_OK',
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'),
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT')
+ );
+ $this->ioStyle->info($message);
+ } elseif ($updateSourceChanged !== null) {
+ $message = Text::sprintf(
+ 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED',
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'),
+ Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT')
+ );
+ $this->ioStyle->warning($message);
+ }
+
$this->progressBar->clear();
$this->ioStyle->writeln("Cleaning up ...");
$this->progressBar->display();
```
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/43717 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php b/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php index b03b7d6dc31eb..dba5f257ae347 100644 --- a/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php +++ b/administrator/components/com_joomlaupdate/src/Controller/DisplayController.php @@ -71,6 +71,7 @@ public function display($cachable = false, $urlparams = false) $state = $model->getState(); $state->set('update_finished_with_error', $this->app->getUserState('com_joomlaupdate.update_finished_with_error')); $state->set('update_errors', (array) $this->app->getUserState('com_joomlaupdate.update_errors', [])); + $state->set('update_channel_reset', $this->app->getUserState('com_joomlaupdate.update_channel_reset')); $state->set('installer_message', $this->app->getUserState('com_joomlaupdate.installer_message')); $state->set('log_file', $this->app->get('log_path') . '/joomla_update.php'); } diff --git a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php index 727f4edd9e9c3..f63a4dd7de605 100644 --- a/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php +++ b/administrator/components/com_joomlaupdate/src/Controller/UpdateController.php @@ -156,6 +156,9 @@ public function finalise() $model->collectError('finaliseUpgrade', $e); } + // Reset update source from "Joomla Next" to "Default" + $this->app->setUserState('com_joomlaupdate.update_channel_reset', $model->resetUpdateSource()); + // Check for update errors if ($model->getErrors()) { // The errors already should be logged at this point diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index b28ed81f2c716..802c6effdcafe 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -2027,4 +2027,73 @@ private function checkManifestXML(string $manifest, $packageName) throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_DOWNGRADE', $packageName, $versionPackage, $currentVersion), 500); } } + + /** + * Reset update source from "next" to "default" + * + * @return boolean True if update source is reset, false if reset failed with error, + * null if no reset was necessary. + * + * @since __DEPLOY_VERSION__ + */ + public function resetUpdateSource() + { + // Get current update source + $params = ComponentHelper::getParams('com_joomlaupdate'); + + // Do nothing if not "next" + if ($params->get('updatesource', 'default') !== 'next') { + return null; + } + + $params->set('updatesource', 'default'); + + $params = $params->toString(); + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->update($db->quoteName('#__extensions')) + ->set($db->quoteName('params') . ' = :params') + ->where($db->quoteName('type') . ' = ' . $db->quote('component')) + ->where($db->quoteName('element') . ' = ' . $db->quote('com_joomlaupdate')) + ->bind(':params', $params); + + try { + $db->setQuery($query); + $db->execute(); + } catch (\Exception $e) { + Log::add( + sprintf( + 'An error has occurred while running "resetUpdateSource". Code: %s. Message: %s.', + $e->getCode(), + $e->getMessage() + ), + Log::WARNING, + 'Update' + ); + + Log::add( + Text::sprintf( + 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED', + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'), + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT') + ), + Log::WARNING, + 'Update' + ); + + return false; + } + + Log::add( + Text::sprintf( + 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_OK', + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'), + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT') + ), + Log::INFO, + 'Update' + ); + + return true; + } } diff --git a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php index 53b17ccf0fc6c..2920c2a26b060 100644 --- a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php +++ b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/complete.php @@ -19,6 +19,7 @@ $hadErrors = $this->state->get('update_finished_with_error'); $errors = $this->state->get('update_errors'); +$channelReset = $this->state->get('update_channel_reset'); $logFile = $this->state->get('log_file'); $installerMsg = $this->state->get('installer_message'); $forumLink = 'https://forum.joomla.org/'; @@ -27,6 +28,17 @@It is only intended for JBS (Joomla Bug Squad™) members and others within the Joomla community who are testing. Do not use this setting on a production site." COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update Joomla if your server is behind a firewall or otherwise unable to contact the update servers. First download the Joomla Update Package in ZIP format from the official Joomla download page. Then use the fields below to upload and install it." COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted" diff --git a/libraries/src/Console/UpdateCoreCommand.php b/libraries/src/Console/UpdateCoreCommand.php index 8a28fe15aab31..bef4f091c4722 100644 --- a/libraries/src/Console/UpdateCoreCommand.php +++ b/libraries/src/Console/UpdateCoreCommand.php @@ -272,6 +272,24 @@ private function updateJoomlaCore($updatemodel): bool $result = $updatemodel->finaliseUpgrade(); if ($result) { + $updateSourceChanged = $updatemodel->resetUpdateSource(); + + if ($updateSourceChanged) { + $message = Text::sprintf( + 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_OK', + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'), + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT') + ); + $this->ioStyle->info($message); + } elseif ($updateSourceChanged !== null) { + $message = Text::sprintf( + 'COM_JOOMLAUPDATE_UPDATE_CHANGE_UPDATE_SOURCE_FAILED', + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT'), + Text::_('COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT') + ); + $this->ioStyle->warning($message); + } + $this->progressBar->clear(); $this->ioStyle->writeln("Cleaning up ..."); $this->progressBar->display(); ```