Skip to content

Commit 6615552

Browse files
committed
Merge branch '3.10-dev' into 4.0-dev
2 parents b1a3f7b + f2581cc commit 6615552

File tree

6 files changed

+83
-50
lines changed

6 files changed

+83
-50
lines changed

administrator/components/com_joomlaupdate/src/Controller/UpdateController.php

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -487,32 +487,57 @@ public function fetchExtensionCompatibility()
487487
$model = $this->getModel('Update');
488488
$upgradeCompatibilityStatus = $model->fetchCompatibility($extensionID, $joomlaTargetVersion);
489489
$currentCompatibilityStatus = $model->fetchCompatibility($extensionID, $joomlaCurrentVersion);
490+
$upgradeUpdateVersion = false;
491+
$currentUpdateVersion = false;
490492

491493
$upgradeWarning = 0;
492494

493-
if ($upgradeCompatibilityStatus->state == 1 && $upgradeCompatibilityStatus->compatibleVersion !== false)
495+
if ($upgradeCompatibilityStatus->state == 1 && !empty($upgradeCompatibilityStatus->compatibleVersions))
494496
{
495-
if (version_compare($upgradeCompatibilityStatus->compatibleVersion, $extensionVersion, 'gt'))
497+
$upgradeUpdateVersion = end($upgradeCompatibilityStatus->compatibleVersions);
498+
}
499+
500+
if ($currentCompatibilityStatus->state == 1 && !empty($currentCompatibilityStatus->compatibleVersions))
501+
{
502+
$currentUpdateVersion = end($currentCompatibilityStatus->compatibleVersions);
503+
}
504+
505+
if ($upgradeUpdateVersion !== false)
506+
{
507+
$upgradeOldestVersion = $upgradeCompatibilityStatus->compatibleVersions[0];
508+
509+
if ($currentUpdateVersion !== false)
496510
{
497-
// Extension needs upgrade before upgrading Joomla
511+
// If there are updates compatible with both CMS versions use these
512+
$bothCompatibleVersions = array_values(
513+
array_intersect($upgradeCompatibilityStatus->compatibleVersions, $currentCompatibilityStatus->compatibleVersions)
514+
);
515+
516+
if (!empty($bothCompatibleVersions))
517+
{
518+
$upgradeOldestVersion = $bothCompatibleVersions[0];
519+
$upgradeUpdateVersion = end($bothCompatibleVersions);
520+
}
521+
}
522+
523+
if (version_compare($upgradeOldestVersion, $extensionVersion, '>'))
524+
{
525+
// Installed version is empty or older than the oldest compatible update: Update required
498526
$resultGroup = 2;
499527
}
500528
else
501529
{
502-
// Current version is up to date and compatible
530+
// Current version is compatible
503531
$resultGroup = 3;
504532
}
505533

506-
if ($currentCompatibilityStatus->state == 1)
534+
if ($currentUpdateVersion !== false && version_compare($upgradeUpdateVersion, $currentUpdateVersion, '<'))
507535
{
508-
if (version_compare($upgradeCompatibilityStatus->compatibleVersion, $currentCompatibilityStatus->compatibleVersion, 'lt'))
509-
{
510-
// Special case warning when version compatible with target is lower than current
511-
$upgradeWarning = 2;
512-
}
536+
// Special case warning when version compatible with target is lower than current
537+
$upgradeWarning = 2;
513538
}
514539
}
515-
elseif ($currentCompatibilityStatus->state == 1)
540+
elseif ($currentUpdateVersion !== false)
516541
{
517542
// No compatible version for target version but there is a compatible version for current version
518543
$resultGroup = 1;
@@ -525,8 +550,14 @@ public function fetchExtensionCompatibility()
525550

526551
// Do we need to capture
527552
$combinedCompatibilityStatus = array(
528-
'upgradeCompatibilityStatus' => $upgradeCompatibilityStatus,
529-
'currentCompatibilityStatus' => $currentCompatibilityStatus,
553+
'upgradeCompatibilityStatus' => (object) array(
554+
'state' => $upgradeCompatibilityStatus->state,
555+
'compatibleVersion' => $upgradeUpdateVersion
556+
),
557+
'currentCompatibilityStatus' => (object) array(
558+
'state' => $currentCompatibilityStatus->state,
559+
'compatibleVersion' => $currentUpdateVersion
560+
),
530561
'resultGroup' => $resultGroup,
531562
'upgradeWarning' => $upgradeWarning,
532563
);

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

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function applyUpdateSite()
8888
* The commented "case" below are for documenting where 'default' and legacy options falls
8989
* case 'default':
9090
* case 'lts':
91-
* case 'sts': (Its shown as "Default" cause that option does not exist any more)
91+
* case 'sts': (It's shown as "Default" because that option does not exist any more)
9292
* case 'nochange':
9393
*/
9494
default:
@@ -1490,34 +1490,18 @@ public function fetchCompatibility($extensionID, $joomlaTargetVersion)
14901490

14911491
foreach ($updateFileUrls as $updateFileUrl)
14921492
{
1493-
$compatibleVersion = $this->checkCompatibility($updateFileUrl, $joomlaTargetVersion);
1493+
$compatibleVersions = $this->checkCompatibility($updateFileUrl, $joomlaTargetVersion);
14941494

1495-
if ($compatibleVersion)
1496-
{
1497-
// Return the compatible version
1498-
return (object) array('state' => 1, 'compatibleVersion' => $compatibleVersion->_data);
1499-
}
1500-
else
1501-
{
1502-
// Return the compatible version as false so we can say update server is supported but no compatible version found
1503-
return (object) array('state' => 1, 'compatibleVersion' => false);
1504-
}
1495+
// Return the compatible versions
1496+
return (object) array('state' => 1, 'compatibleVersions' => $compatibleVersions);
15051497
}
15061498
}
15071499
else
15081500
{
1509-
$compatibleVersion = $this->checkCompatibility($updateSite['location'], $joomlaTargetVersion);
1501+
$compatibleVersions = $this->checkCompatibility($updateSite['location'], $joomlaTargetVersion);
15101502

1511-
if ($compatibleVersion)
1512-
{
1513-
// Return the compatible version
1514-
return (object) array('state' => 1, 'compatibleVersion' => $compatibleVersion->_data);
1515-
}
1516-
else
1517-
{
1518-
// Return the compatible version as false so we can say update server is supported but no compatible version found
1519-
return (object) array('state' => 1, 'compatibleVersion' => false);
1520-
}
1503+
// Return the compatible versions
1504+
return (object) array('state' => 1, 'compatibleVersions' => $compatibleVersions);
15211505
}
15221506
}
15231507

@@ -1637,7 +1621,7 @@ private function getCollectionDetailsUrls($updateSiteInfo, $joomlaTargetVersion)
16371621
* @param string $updateFileUrl The items update XML url.
16381622
* @param string $joomlaTargetVersion The Joomla! version to test against
16391623
*
1640-
* @return mixed An array of data items or false.
1624+
* @return array An array of strings with compatible version numbers
16411625
*
16421626
* @since 3.10.0
16431627
*/
@@ -1649,9 +1633,20 @@ private function checkCompatibility($updateFileUrl, $joomlaTargetVersion)
16491633
$update->set('jversion.full', $joomlaTargetVersion);
16501634
$update->loadFromXml($updateFileUrl, $minimumStability);
16511635

1652-
$downloadUrl = $update->get('downloadurl');
1636+
$compatibleVersions = $update->get('compatibleVersions');
1637+
1638+
// Check if old version of the updater library
1639+
if (!isset($compatibleVersions))
1640+
{
1641+
$downloadUrl = $update->get('downloadurl');
1642+
$updateVersion = $update->get('version');
1643+
1644+
return empty($downloadUrl) || empty($downloadUrl->_data) || empty($updateVersion) ? array() : array($updateVersion->_data);
1645+
}
1646+
1647+
usort($compatibleVersions, 'version_compare');
16531648

1654-
return !empty($downloadUrl) && !empty($downloadUrl->_data) ? $update->get('version') : false;
1649+
return $compatibleVersions;
16551650
}
16561651

16571652
/**

administrator/components/com_joomlaupdate/tmpl/joomlaupdate/preupdatecheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
->useScript('bootstrap.tab');
2727

2828
// Text::script doesn't have a sprintf equivalent so work around this
29-
Factory::getDocument()->addScriptOptions('nonCoreCriticalPlugins', $this->nonCoreCriticalPlugins);
29+
$this->document->addScriptOptions('nonCoreCriticalPlugins', $this->nonCoreCriticalPlugins);
3030

3131
Text::script('COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN_CONFIRM_MESSAGE');
3232
Text::script('COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSION_NO_COMPATIBILITY_INFORMATION');

administrator/language/en-GB/com_joomlaupdate.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_INSTALLUPDATE="Update"
111111
COM_JOOMLAUPDATE_VIEW_DEFAULT_LATEST="Latest Joomla version"
112112
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_DOWNLOAD_URL="We can't find a download URL"
113113
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_DOWNLOAD_URL_DESC="An update to Joomla %1$s was found, but it wasn't possible to fetch the download URL for that update. Either the update to Joomla %1$s is not available for your stability level or there is a problem with the Joomla Update Server.<br>Please try to download the update package from <a href=\"https://downloads.joomla.org/latest\">the official Joomla download page</a> and use the Upload and Update tab."
114-
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE="Live Update is not available"
115-
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE_DESC="There is a new version of the Joomla Update Component that needs to be installed first. <a class=\"alert-link\" href=\"index.php?option=com_installer&view=update\">Click here to update the component</a>."
114+
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE="A new version of the Joomla Update Component is available."
115+
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE_DESC="You must update this component first before you can update Joomla! <a class=\"alert-link\" href=\"index.php?option=com_installer&view=update\">Click here to update the component</a>."
116116
COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_PLUGIN_BEING_CHECKED="The system is currently checking these plugins to see if they could cause problems during the update.<br><br>Please be patient while the checks are completed."
117117
COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_PLUGIN_CONFIRMATION="I accept the warnings about potentially incompatible extensions and wish to proceed with the update."
118118
COM_JOOMLAUPDATE_VIEW_DEFAULT_NOUPDATES="No updates available"

libraries/src/Updater/Update.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ class Update extends CMSObject
218218
*/
219219
protected $minimum_stability = Updater::STABILITY_STABLE;
220220

221+
/**
222+
* Array with compatible versions used by the pre-update check
223+
*
224+
* @var array
225+
* @since __DEPLOY_VERSION__
226+
*/
227+
protected $compatibleVersions = array();
228+
221229
/**
222230
* Gets the reference to the current direct parent
223231
*
@@ -389,14 +397,13 @@ public function _endElement($parser, $name)
389397

390398
if ($phpMatch && $stabilityMatch && $dbMatch)
391399
{
392-
if (isset($this->latest))
400+
if (!empty($this->currentUpdate->downloadurl) && !empty($this->currentUpdate->downloadurl->_data))
393401
{
394-
if (version_compare($this->currentUpdate->version->_data, $this->latest->version->_data, '>') == 1)
395-
{
396-
$this->latest = $this->currentUpdate;
397-
}
402+
$this->compatibleVersions[] = $this->currentUpdate->version->_data;
398403
}
399-
else
404+
405+
if (!isset($this->latest)
406+
|| version_compare($this->currentUpdate->version->_data, $this->latest->version->_data, '>'))
400407
{
401408
$this->latest = $this->currentUpdate;
402409
}

plugins/system/updatenotification/postinstall/updatecachetime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function updatecachetime_postinstall_condition()
3333
}
3434

3535
/**
36-
* Sets the cachtimeout back to the default (6 hours)
36+
* Sets the cachetimeout back to the default (6 hours)
3737
*
3838
* @return void
3939
*
@@ -43,7 +43,7 @@ function updatecachetime_postinstall_action()
4343
{
4444
$installer = ComponentHelper::getComponent('com_installer');
4545

46-
// Sets the cachtimeout back to the default (6 hours)
46+
// Sets the cachetimeout back to the default (6 hours)
4747
$installer->params->set('cachetimeout', 6);
4848

4949
// Save the new parameters back to com_installer

0 commit comments

Comments
 (0)