Skip to content

Commit

Permalink
Merge branch '4.4-dev' into 4.4-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MacJoom committed Dec 20, 2023
2 parents 0333afc + 1b4fea4 commit cda06fc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ class HtmlView extends BaseHtmlView
*/
protected $reasonNoDownload = '';

/**
* Details on failed PHP or DB version requirements to be shown in the emptystate layout when there is no download
*
* @var \stdClass PHP and database requirements from the update manifest
*
* @since __DEPLOY_VERSION__
*/
protected $detailsNoDownload;

/**
* List of non core critical plugins
*
Expand Down Expand Up @@ -199,8 +208,9 @@ public function display($tpl = null)
} else {
// No download available
if ($hasUpdate) {
$this->messagePrefix = '_NODOWNLOAD';
$this->reasonNoDownload = 'COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON';
$this->messagePrefix = '_NODOWNLOAD';
$this->reasonNoDownload = 'COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON';
$this->detailsNoDownload = $this->updateInfo['object']->get('otherUpdateInfo');
}

$this->setLayout('noupdate');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,35 @@
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Session\Session;

$uploadLink = 'index.php?option=com_joomlaupdate&view=upload';
$uploadLink = 'index.php?option=com_joomlaupdate&view=upload';
$reasonNoDownload = '';

if (!empty($this->reasonNoDownload)) {
$reasonNoDownload = Text::_($this->reasonNoDownload);

if (isset($this->detailsNoDownload->php)) {
$reasonNoDownload .= Text::sprintf(
'COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_PHP',
$this->detailsNoDownload->php->used,
$this->detailsNoDownload->php->required
);
}

if (isset($this->detailsNoDownload->db)) {
$reasonNoDownload .= Text::sprintf(
'COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_DATABASE',
Text::_('JLIB_DB_SERVER_TYPE_' . $this->detailsNoDownload->db->type),
$this->detailsNoDownload->db->used,
$this->detailsNoDownload->db->required
);
}

$reasonNoDownload .= Text::_('COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_ACTION');
}

$displayData = [
'textPrefix' => 'COM_JOOMLAUPDATE' . $this->messagePrefix,
'content' => Text::_($this->reasonNoDownload) . Text::sprintf($this->langKey, $this->updateSourceKey),
'content' => $reasonNoDownload . Text::sprintf($this->langKey, $this->updateSourceKey),
'formURL' => 'index.php?option=com_joomlaupdate&view=joomlaupdate',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Updating_from_an_existing_version',
'icon' => 'icon-loop joomlaupdate',
Expand Down
5 changes: 4 additions & 1 deletion administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ COM_JOOMLAUPDATE_MINIMUM_STABILITY_STABLE="Stable"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_APPEND="Upload and Update"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_BUTTON_ADD="Retry check for update"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_CONTENT="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 function."
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON="An update to Joomla %1$s was found but your web server doesn't meet the <a href=\"https://downloads.joomla.org/technical-requirements\" target=\"_blank\" rel=\"noopener noreferrer\">minimum requirements</a>. Please contact your web host to update your server.<br>"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON="An update to Joomla %1$s was found but your web server doesn't meet the <a href=\"https://manual.joomla.org/docs/next/get-started/technical-requirements/\" target=\"_blank\" rel=\"noopener noreferrer\">minimum requirements</a>.<br>"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_ACTION="Please contact your web host to update your server.<br>"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_DATABASE="Your %1$s version \"%2$s\" is lower than \"%3$s\".<br>"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_PHP="Your PHP version \"%1$s\" is lower than \"%2$s\".<br>"
COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_TITLE="This site can't be updated to Joomla %1$s"
COM_JOOMLAUPDATE_OVERVIEW="Joomla Update"
COM_JOOMLAUPDATE_PREUPDATE_CHECK_CAPTION="Server settings to check before update."
Expand Down
32 changes: 31 additions & 1 deletion libraries/src/Updater/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,21 @@ class Update extends CMSObject
protected $currentUpdate;

/**
* Object containing the latest update data
* Object containing the latest update data which meets the PHP and DB version requirements
*
* @var \stdClass
* @since 3.0.0
*/
protected $latest;

/**
* Object containing details if the latest update does not meet the PHP and DB version requirements
*
* @var \stdClass
* @since __DEPLOY_VERSION__
*/
protected $otherUpdateInfo;

/**
* The minimum stability required for updates to be taken into account. The possible values are:
* 0 dev Development snapshots, nightly builds, pre-release versions and so on
Expand Down Expand Up @@ -342,13 +350,23 @@ public function _endElement($parser, $name)
&& $product == $this->currentUpdate->targetplatform->name
&& preg_match('/^' . $this->currentUpdate->targetplatform->version . '/', $this->get('jversion.full', JVERSION))
) {
// Collect information on updates which do not meet PHP and DB version requirements
$otherUpdateInfo = new \stdClass();
$otherUpdateInfo->version = $this->currentUpdate->version->_data;

$phpMatch = false;

// Check if PHP version supported via <php_minimum> tag, assume true if tag isn't present
if (!isset($this->currentUpdate->php_minimum) || version_compare(PHP_VERSION, $this->currentUpdate->php_minimum->_data, '>=')) {
$phpMatch = true;
}

if (!$phpMatch) {
$otherUpdateInfo->php = new \stdClass();
$otherUpdateInfo->php->required = $this->currentUpdate->php_minimum->_data;
$otherUpdateInfo->php->used = PHP_VERSION;
}

$dbMatch = false;

// Check if DB & version is supported via <supported_databases> tag, assume supported if tag isn't present
Expand All @@ -372,6 +390,13 @@ public function _endElement($parser, $name)
if (isset($supportedDbs->$dbType)) {
$minimumVersion = $supportedDbs->$dbType;
$dbMatch = version_compare($dbVersion, $minimumVersion, '>=');

if (!$dbMatch) {
$otherUpdateInfo->db = new \stdClass();
$otherUpdateInfo->db->type = $dbType;
$otherUpdateInfo->db->required = $minimumVersion;
$otherUpdateInfo->db->used = $dbVersion;
}
}
} else {
// Set to true if the <supported_databases> tag is not set
Expand All @@ -396,6 +421,11 @@ public function _endElement($parser, $name)
) {
$this->latest = $this->currentUpdate;
}
} elseif (
!isset($this->otherUpdateInfo)
|| version_compare($otherUpdateInfo->version, $this->otherUpdateInfo->version, '>')
) {
$this->otherUpdateInfo = $otherUpdateInfo;
}
}
break;
Expand Down

0 comments on commit cda06fc

Please sign in to comment.