Skip to content

Commit e84a232

Browse files
authored
[5.4] Add pre-update checks for backward compatibility plugins for update to Joomla 6 (joomla#45493)
Adds 2 new checks to the "Required Settings" checks of the pre-update checker ---------
1 parent f061770 commit e84a232

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

administrator/components/com_joomlaupdate/src/Model/UpdateModel.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,15 +1347,36 @@ public function getPhpOptions()
13471347
$options[] = $option;
13481348
$updateInformation = $this->getUpdateInformation();
13491349

1350-
// Check if configured database is compatible with the next major version of Joomla
1351-
$nextMajorVersion = Version::MAJOR_VERSION + 1;
1352-
1353-
if (version_compare($updateInformation['latest'], (string) $nextMajorVersion, '>=')) {
1350+
// Extra checks when updating to the next major version of Joomla
1351+
if (version_compare($updateInformation['latest'], (string) Version::MAJOR_VERSION + 1, '>=')) {
1352+
// Check if configured database is compatible with the next major version of Joomla
13541353
$option = new \stdClass();
13551354
$option->label = Text::sprintf('INSTL_DATABASE_SUPPORTED', $this->getConfiguredDatabaseType());
13561355
$option->state = $this->isDatabaseTypeSupported();
13571356
$option->notice = null;
13581357
$options[] = $option;
1358+
1359+
// Check if the Joomla 5 backwards compatibility plugin is disabled
1360+
$plugin = ExtensionHelper::getExtensionRecord('compat', 'plugin', 0, 'behaviour');
1361+
1362+
$this->translateExtensionName($plugin);
1363+
1364+
$option = new \stdClass();
1365+
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_TITLE', $plugin->name);
1366+
$option->state = !PluginHelper::isEnabled('behaviour', 'compat');
1367+
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_NOTICE', $plugin->folder, $plugin->element);
1368+
$options[] = $option;
1369+
1370+
// Check if the Joomla 6 backwards compatibility plugin is enabled
1371+
$plugin = ExtensionHelper::getExtensionRecord('compat6', 'plugin', 0, 'behaviour');
1372+
1373+
$this->translateExtensionName($plugin);
1374+
1375+
$option = new \stdClass();
1376+
$option->label = Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_TITLE', $plugin->name);
1377+
$option->state = PluginHelper::isEnabled('behaviour', 'compat6');
1378+
$option->notice = $option->state ? null : Text::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_NOTICE', $plugin->folder, $plugin->element);
1379+
$options[] = $option;
13591380
}
13601381

13611382
// Check if database structure is up to date

administrator/language/en-GB/com_joomlaupdate.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_PACKAGE_INFO="You can also download <a href=\"%s\"
180180
COM_JOOMLAUPDATE_VIEW_DEFAULT_PACKAGE_REINSTALL="Reinstall package URL"
181181
COM_JOOMLAUPDATE_VIEW_DEFAULT_PHP_VERSION_NOT_SUPPORTED="Your PHP version is not supported"
182182
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>."
183+
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."
184+
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_DISABLED_TITLE="The '%s' plugin is disabled"
185+
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."
186+
COM_JOOMLAUPDATE_VIEW_DEFAULT_PLUGIN_ENABLED_TITLE="The '%s' plugin is enabled"
183187
COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN="Potential Upgrade Issue."
184188
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?"
185189
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."

libraries/src/Console/UpdateCoreCommand.php

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Joomla\CMS\Installer\InstallerHelper;
1616
use Joomla\CMS\Language\Text;
1717
use Joomla\CMS\Log\Log;
18+
use Joomla\CMS\Plugin\PluginHelper;
19+
use Joomla\CMS\Version;
1820
use Joomla\Console\Command\AbstractCommand;
1921
use Joomla\Database\DatabaseInterface;
2022
use Joomla\Filesystem\Exception\FilesystemException;
@@ -192,7 +194,6 @@ public function doExecute(InputInterface $input, OutputInterface $output): int
192194
$this->progressBar->display();
193195
$this->progressBar->advance();
194196

195-
196197
$errors = $this->checkSchema();
197198

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

207+
// If upgrading to a new major version, check pre-conditions
208+
if (version_compare($this->updateInfo['latest'], (string) Version::MAJOR_VERSION + 1, '>=')) {
209+
$this->progressBar->clear();
210+
$this->ioStyle->writeln('Check pre-conditions for a major upgrade to version ' . $this->updateInfo['latest'] . '...');
211+
$this->progressBar->display();
212+
$this->progressBar->advance();
213+
214+
if (!$this->checkMajorUpgrade()) {
215+
$this->progressBar->finish();
216+
217+
$this->ioStyle->info('The pre-conditions for a major upgrade are not fulfilled.');
218+
219+
return self::ERR_CHECKS_FAILED;
220+
}
221+
}
222+
206223
$this->progressBar->clear();
207224
$this->ioStyle->writeln('Starting Joomla! update ...');
208225
$this->progressBar->display();
@@ -502,4 +519,32 @@ public function checkSchema(): int
502519

503520
return $changeInformation['errorsCount'];
504521
}
522+
523+
/**
524+
* Check pre-conditions for major version upgrade
525+
*
526+
* @return boolean True if success
527+
*
528+
* @since __DEPLOY_VERSION__
529+
*/
530+
public function checkMajorUpgrade(): bool
531+
{
532+
$return = true;
533+
534+
$language = Factory::getLanguage();
535+
$language->load('plg_behaviour_compat.sys', JPATH_ADMINISTRATOR);
536+
$language->load('plg_behaviour_compat6.sys', JPATH_ADMINISTRATOR);
537+
538+
if (PluginHelper::isEnabled('behaviour', 'compat')) {
539+
$this->ioStyle->error('The \'' . Text::_('PLG_BEHAVIOUR_COMPAT') . '\' plugin is enabled.');
540+
$return = false;
541+
}
542+
543+
if (!PluginHelper::isEnabled('behaviour', 'compat6')) {
544+
$this->ioStyle->error('The \'' . Text::_('PLG_BEHAVIOUR_COMPAT6') . '\' plugin is disabled.');
545+
$return = false;
546+
}
547+
548+
return $return;
549+
}
505550
}

0 commit comments

Comments
 (0)