JoomlaPolska / jezyk-J4

Język polski dla Joomla 4
GNU General Public License v2.0
3 stars 5 forks source link

[4.4] Add information about reasons to Joomla Update when an update was found which doesn't fulfil PHP or DB requirements #441

Closed joomlapl-bot closed 6 months ago

joomlapl-bot commented 9 months ago

PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/42489 Poniżej zmiany w oryginale:

Click to expand the diff! ```diff diff --git a/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php b/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php index 1d42a5b3e83dc..3a20f99fd14c1 100644 --- a/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php +++ b/administrator/components/com_joomlaupdate/src/View/Joomlaupdate/HtmlView.php @@ -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 * @@ -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'); diff --git a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php index 3ebdca365b6f7..9f0a86509932e 100644 --- a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php +++ b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php @@ -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', diff --git a/administrator/language/en-GB/com_joomlaupdate.ini b/administrator/language/en-GB/com_joomlaupdate.ini index 5d2d00e53543d..2966ca2980183 100644 --- a/administrator/language/en-GB/com_joomlaupdate.ini +++ b/administrator/language/en-GB/com_joomlaupdate.ini @@ -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.
Please try to download the update package from the official Joomla download page 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 minimum requirements. Please contact your web host to update your server.
" +COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON="An update to Joomla %1$s was found but your web server doesn't meet the minimum requirements.
" +COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_ACTION="Please contact your web host to update your server.
" +COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_DATABASE="Your %1$s version \"%2$s\" is lower than \"%3$s\".
" +COM_JOOMLAUPDATE_NODOWNLOAD_EMPTYSTATE_REASON_PHP="Your PHP version \"%1$s\" is lower than \"%2$s\".
" 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." diff --git a/libraries/src/Updater/Update.php b/libraries/src/Updater/Update.php index 8ad6f92f9c600..d2e02e89904a2 100644 --- a/libraries/src/Updater/Update.php +++ b/libraries/src/Updater/Update.php @@ -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 @@ -342,6 +350,10 @@ 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 tag, assume true if tag isn't present @@ -349,6 +361,12 @@ public function _endElement($parser, $name) $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 tag, assume supported if tag isn't present @@ -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 tag is not set @@ -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; ```