Skip to content

Commit

Permalink
Merge branch '3.10-dev' into 4.0-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Sep 11, 2021
2 parents b1a3f7b + f2581cc commit 6615552
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,32 +487,57 @@ public function fetchExtensionCompatibility()
$model = $this->getModel('Update');
$upgradeCompatibilityStatus = $model->fetchCompatibility($extensionID, $joomlaTargetVersion);
$currentCompatibilityStatus = $model->fetchCompatibility($extensionID, $joomlaCurrentVersion);
$upgradeUpdateVersion = false;
$currentUpdateVersion = false;

$upgradeWarning = 0;

if ($upgradeCompatibilityStatus->state == 1 && $upgradeCompatibilityStatus->compatibleVersion !== false)
if ($upgradeCompatibilityStatus->state == 1 && !empty($upgradeCompatibilityStatus->compatibleVersions))
{
if (version_compare($upgradeCompatibilityStatus->compatibleVersion, $extensionVersion, 'gt'))
$upgradeUpdateVersion = end($upgradeCompatibilityStatus->compatibleVersions);
}

if ($currentCompatibilityStatus->state == 1 && !empty($currentCompatibilityStatus->compatibleVersions))
{
$currentUpdateVersion = end($currentCompatibilityStatus->compatibleVersions);
}

if ($upgradeUpdateVersion !== false)
{
$upgradeOldestVersion = $upgradeCompatibilityStatus->compatibleVersions[0];

if ($currentUpdateVersion !== false)
{
// Extension needs upgrade before upgrading Joomla
// If there are updates compatible with both CMS versions use these
$bothCompatibleVersions = array_values(
array_intersect($upgradeCompatibilityStatus->compatibleVersions, $currentCompatibilityStatus->compatibleVersions)
);

if (!empty($bothCompatibleVersions))
{
$upgradeOldestVersion = $bothCompatibleVersions[0];
$upgradeUpdateVersion = end($bothCompatibleVersions);
}
}

if (version_compare($upgradeOldestVersion, $extensionVersion, '>'))
{
// Installed version is empty or older than the oldest compatible update: Update required
$resultGroup = 2;
}
else
{
// Current version is up to date and compatible
// Current version is compatible
$resultGroup = 3;
}

if ($currentCompatibilityStatus->state == 1)
if ($currentUpdateVersion !== false && version_compare($upgradeUpdateVersion, $currentUpdateVersion, '<'))
{
if (version_compare($upgradeCompatibilityStatus->compatibleVersion, $currentCompatibilityStatus->compatibleVersion, 'lt'))
{
// Special case warning when version compatible with target is lower than current
$upgradeWarning = 2;
}
// Special case warning when version compatible with target is lower than current
$upgradeWarning = 2;
}
}
elseif ($currentCompatibilityStatus->state == 1)
elseif ($currentUpdateVersion !== false)
{
// No compatible version for target version but there is a compatible version for current version
$resultGroup = 1;
Expand All @@ -525,8 +550,14 @@ public function fetchExtensionCompatibility()

// Do we need to capture
$combinedCompatibilityStatus = array(
'upgradeCompatibilityStatus' => $upgradeCompatibilityStatus,
'currentCompatibilityStatus' => $currentCompatibilityStatus,
'upgradeCompatibilityStatus' => (object) array(
'state' => $upgradeCompatibilityStatus->state,
'compatibleVersion' => $upgradeUpdateVersion
),
'currentCompatibilityStatus' => (object) array(
'state' => $currentCompatibilityStatus->state,
'compatibleVersion' => $currentUpdateVersion
),
'resultGroup' => $resultGroup,
'upgradeWarning' => $upgradeWarning,
);
Expand Down
47 changes: 21 additions & 26 deletions administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function applyUpdateSite()
* The commented "case" below are for documenting where 'default' and legacy options falls
* case 'default':
* case 'lts':
* case 'sts': (Its shown as "Default" cause that option does not exist any more)
* case 'sts': (It's shown as "Default" because that option does not exist any more)
* case 'nochange':
*/
default:
Expand Down Expand Up @@ -1490,34 +1490,18 @@ public function fetchCompatibility($extensionID, $joomlaTargetVersion)

foreach ($updateFileUrls as $updateFileUrl)
{
$compatibleVersion = $this->checkCompatibility($updateFileUrl, $joomlaTargetVersion);
$compatibleVersions = $this->checkCompatibility($updateFileUrl, $joomlaTargetVersion);

if ($compatibleVersion)
{
// Return the compatible version
return (object) array('state' => 1, 'compatibleVersion' => $compatibleVersion->_data);
}
else
{
// Return the compatible version as false so we can say update server is supported but no compatible version found
return (object) array('state' => 1, 'compatibleVersion' => false);
}
// Return the compatible versions
return (object) array('state' => 1, 'compatibleVersions' => $compatibleVersions);
}
}
else
{
$compatibleVersion = $this->checkCompatibility($updateSite['location'], $joomlaTargetVersion);
$compatibleVersions = $this->checkCompatibility($updateSite['location'], $joomlaTargetVersion);

if ($compatibleVersion)
{
// Return the compatible version
return (object) array('state' => 1, 'compatibleVersion' => $compatibleVersion->_data);
}
else
{
// Return the compatible version as false so we can say update server is supported but no compatible version found
return (object) array('state' => 1, 'compatibleVersion' => false);
}
// Return the compatible versions
return (object) array('state' => 1, 'compatibleVersions' => $compatibleVersions);
}
}

Expand Down Expand Up @@ -1637,7 +1621,7 @@ private function getCollectionDetailsUrls($updateSiteInfo, $joomlaTargetVersion)
* @param string $updateFileUrl The items update XML url.
* @param string $joomlaTargetVersion The Joomla! version to test against
*
* @return mixed An array of data items or false.
* @return array An array of strings with compatible version numbers
*
* @since 3.10.0
*/
Expand All @@ -1649,9 +1633,20 @@ private function checkCompatibility($updateFileUrl, $joomlaTargetVersion)
$update->set('jversion.full', $joomlaTargetVersion);
$update->loadFromXml($updateFileUrl, $minimumStability);

$downloadUrl = $update->get('downloadurl');
$compatibleVersions = $update->get('compatibleVersions');

// Check if old version of the updater library
if (!isset($compatibleVersions))
{
$downloadUrl = $update->get('downloadurl');
$updateVersion = $update->get('version');

return empty($downloadUrl) || empty($downloadUrl->_data) || empty($updateVersion) ? array() : array($updateVersion->_data);
}

usort($compatibleVersions, 'version_compare');

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
->useScript('bootstrap.tab');

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

Text::script('COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN_CONFIRM_MESSAGE');
Text::script('COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSION_NO_COMPATIBILITY_INFORMATION');
Expand Down
4 changes: 2 additions & 2 deletions administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_INSTALLUPDATE="Update"
COM_JOOMLAUPDATE_VIEW_DEFAULT_LATEST="Latest Joomla version"
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_DOWNLOAD_URL="We can't find a download URL"
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."
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE="Live Update is not available"
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>."
COM_JOOMLAUPDATE_VIEW_DEFAULT_NO_LIVE_UPDATE="A new version of the Joomla Update Component is available."
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>."
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."
COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_PLUGIN_CONFIRMATION="I accept the warnings about potentially incompatible extensions and wish to proceed with the update."
COM_JOOMLAUPDATE_VIEW_DEFAULT_NOUPDATES="No updates available"
Expand Down
19 changes: 13 additions & 6 deletions libraries/src/Updater/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ class Update extends CMSObject
*/
protected $minimum_stability = Updater::STABILITY_STABLE;

/**
* Array with compatible versions used by the pre-update check
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $compatibleVersions = array();

/**
* Gets the reference to the current direct parent
*
Expand Down Expand Up @@ -389,14 +397,13 @@ public function _endElement($parser, $name)

if ($phpMatch && $stabilityMatch && $dbMatch)
{
if (isset($this->latest))
if (!empty($this->currentUpdate->downloadurl) && !empty($this->currentUpdate->downloadurl->_data))
{
if (version_compare($this->currentUpdate->version->_data, $this->latest->version->_data, '>') == 1)
{
$this->latest = $this->currentUpdate;
}
$this->compatibleVersions[] = $this->currentUpdate->version->_data;
}
else

if (!isset($this->latest)
|| version_compare($this->currentUpdate->version->_data, $this->latest->version->_data, '>'))
{
$this->latest = $this->currentUpdate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function updatecachetime_postinstall_condition()
}

/**
* Sets the cachtimeout back to the default (6 hours)
* Sets the cachetimeout back to the default (6 hours)
*
* @return void
*
Expand All @@ -43,7 +43,7 @@ function updatecachetime_postinstall_action()
{
$installer = ComponentHelper::getComponent('com_installer');

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

// Save the new parameters back to com_installer
Expand Down

0 comments on commit 6615552

Please sign in to comment.