Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1347,15 +1347,36 @@ public function getPhpOptions()
$options[] = $option;
$updateInformation = $this->getUpdateInformation();

// Check if configured database is compatible with the next major version of Joomla
$nextMajorVersion = Version::MAJOR_VERSION + 1;

if (version_compare($updateInformation['latest'], (string) $nextMajorVersion, '>=')) {
// Extra checks when updating to the next major version of Joomla
if (version_compare($updateInformation['latest'], (string) Version::MAJOR_VERSION + 1, '>=')) {
// Check if configured database is compatible with the next major version of Joomla
$option = new \stdClass();
$option->label = Text::sprintf('INSTL_DATABASE_SUPPORTED', $this->getConfiguredDatabaseType());
$option->state = $this->isDatabaseTypeSupported();
$option->notice = null;
$options[] = $option;

// Check if the Joomla 5 backwards compatibility plugin is disabled
$plugin = ExtensionHelper::getExtensionRecord('compat', 'plugin', 0, 'behaviour');

$this->translateExtensionName($plugin);

$option = new \stdClass();
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_TITLE', $plugin->name);
$option->state = !PluginHelper::isEnabled('behaviour', 'compat');
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_NOTICE', $plugin->folder, $plugin->element);
$options[] = $option;

// Check if the Joomla 6 backwards compatibility plugin is enabled
$plugin = ExtensionHelper::getExtensionRecord('compat6', 'plugin', 0, 'behaviour');

$this->translateExtensionName($plugin);

$option = new \stdClass();
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_TITLE', $plugin->name);
$option->state = PluginHelper::isEnabled('behaviour', 'compat6');
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_NOTICE', $plugin->folder, $plugin->element);
$options[] = $option;
}

// Check if database structure is up to date
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_PACKAGE_INFO="You can also download <a href=\"%s\"
COM_JOOMLAUPDATE_VIEW_DEFAULT_PACKAGE_REINSTALL="Reinstall package URL"
COM_JOOMLAUPDATE_VIEW_DEFAULT_PHP_VERSION_NOT_SUPPORTED="Your PHP version is not supported"
COM_JOOMLAUPDATE_VIEW_DEFAULT_PHP_VERSION_NOT_SUPPORTED_DESC="An update to Joomla %1$s was found, but your currently installed PHP version does not match <a href=\"https://downloads.joomla.org/technical-requirements\">the minimum requirements for Joomla %1$s</a>."
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_NOTICE="Go to <a href=\"index.php?option=com_plugins&view=plugins&filter[folder]=%1$s&filter[element]=%2$s\">'System - Manage - Plugins'</a> and disable the plugin."
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_TITLE="The '%s' plugin is disabled"
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_NOTICE="Go to <a href=\"index.php?option=com_plugins&view=plugins&filter[folder]=%1$s&filter[element]=%2$s\">'System - Manage - Plugins'</a> and enable the plugin."
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_TITLE="The '%s' plugin is enabled"
COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN="Potential Upgrade Issue."
COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN_CONFIRM_MESSAGE="Are you sure you want to acknowledge the warnings about potentially incompatible extensions and proceed with the update?"
COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN_DESC="This extension includes a plugin that could cause the update to fail.<br><br>To perform the Joomla update safely you should either update this extension to a version compatible with your target version of Joomla or disable the relevant plugin(s) and check again."
Expand Down
47 changes: 46 additions & 1 deletion libraries/src/Console/UpdateCoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Joomla\CMS\Installer\InstallerHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Version;
use Joomla\Console\Command\AbstractCommand;
use Joomla\Database\DatabaseInterface;
use Joomla\Filesystem\Exception\FilesystemException;
Expand Down Expand Up @@ -192,7 +194,6 @@ public function doExecute(InputInterface $input, OutputInterface $output): int
$this->progressBar->display();
$this->progressBar->advance();


$errors = $this->checkSchema();

if ($errors > 0) {
Expand All @@ -203,6 +204,22 @@ public function doExecute(InputInterface $input, OutputInterface $output): int
return self::ERR_CHECKS_FAILED;
}

// If upgrading to a new major version, check pre-conditions
if (version_compare($this->updateInfo['latest'], (string) Version::MAJOR_VERSION + 1, '>=')) {
$this->progressBar->clear();
$this->ioStyle->writeln('Check pre-conditions for a major upgrade to version ' . $this->updateInfo['latest'] . '...');
$this->progressBar->display();
$this->progressBar->advance();

if (!$this->checkMajorUpgrade()) {
$this->progressBar->finish();

$this->ioStyle->info('The pre-conditions for a major upgrade are not fulfilled.');

return self::ERR_CHECKS_FAILED;
}
}

$this->progressBar->clear();
$this->ioStyle->writeln('Starting Joomla! update ...');
$this->progressBar->display();
Expand Down Expand Up @@ -502,4 +519,32 @@ public function checkSchema(): int

return $changeInformation['errorsCount'];
}

/**
* Check pre-conditions for major version upgrade
*
* @return boolean True if success
*
* @since __DEPLOY_VERSION__
*/
public function checkMajorUpgrade(): bool
{
$return = true;

$language = Factory::getLanguage();
$language->load('plg_behaviour_compat.sys', JPATH_ADMINISTRATOR);
$language->load('plg_behaviour_compat6.sys', JPATH_ADMINISTRATOR);

if (PluginHelper::isEnabled('behaviour', 'compat')) {
$this->ioStyle->error('The \'' . Text::_('PLG_BEHAVIOUR_COMPAT') . '\' plugin is enabled.');
$return = false;
}

if (!PluginHelper::isEnabled('behaviour', 'compat6')) {
$this->ioStyle->error('The \'' . Text::_('PLG_BEHAVIOUR_COMPAT6') . '\' plugin is disabled.');
$return = false;
}

return $return;
}
}