Closed joomlapl-bot closed 7 months ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/42556 Poniżej zmiany w oryginale:
rozwiązane w 5.0.3
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/42556 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 2fec11100701b..29d3ac7614940 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 6336b732f970c..5a4c9bc3d552a 100644 --- a/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php +++ b/administrator/components/com_joomlaupdate/tmpl/joomlaupdate/noupdate.php @@ -15,11 +15,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 cd9e5d3e37332..17fca2758a9b6 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/Installer/Adapter/FileAdapter.php b/libraries/src/Installer/Adapter/FileAdapter.php index 499b702814760..3f122feedc493 100644 --- a/libraries/src/Installer/Adapter/FileAdapter.php +++ b/libraries/src/Installer/Adapter/FileAdapter.php @@ -172,7 +172,11 @@ protected function finaliseInstall() */ protected function finaliseUninstall(): bool { - File::delete(JPATH_MANIFESTS . '/files/' . $this->extension->element . '.xml'); + $manifest = JPATH_MANIFESTS . '/files/' . $this->extension->element . '.xml'; + + if (is_file($manifest)) { + File::delete($manifest); + } $extensionId = $this->extension->extension_id; @@ -283,7 +287,10 @@ protected function removeExtensionFiles() $folderList[] = $targetFolder . '/' . $eFileName; } else { $fileName = $targetFolder . '/' . $eFileName; - File::delete($fileName); + + if (is_file($fileName)) { + File::delete($fileName); + } } } } diff --git a/libraries/src/Installer/Adapter/LibraryAdapter.php b/libraries/src/Installer/Adapter/LibraryAdapter.php index 1d9f0e6f8b441..f3eeacb7518d6 100644 --- a/libraries/src/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/Installer/Adapter/LibraryAdapter.php @@ -274,7 +274,11 @@ public function prepareDiscoverInstall() protected function removeExtensionFiles() { $this->parent->removeFiles($this->getManifest()->files, -1); - File::delete(JPATH_MANIFESTS . '/libraries/' . $this->extension->element . '.xml'); + $manifest = JPATH_MANIFESTS . '/libraries/' . $this->extension->element . '.xml'; + + if (is_file($manifest)) { + File::delete($manifest); + } // @todo: Change this so it walked up the path backwards so we clobber multiple empties // If the folder is empty, let's delete it diff --git a/libraries/src/Installer/Adapter/PackageAdapter.php b/libraries/src/Installer/Adapter/PackageAdapter.php index 022802d6f181c..eb7875212dd89 100644 --- a/libraries/src/Installer/Adapter/PackageAdapter.php +++ b/libraries/src/Installer/Adapter/PackageAdapter.php @@ -328,7 +328,11 @@ protected function finaliseUninstall(): bool $update->delete($uid); } - File::delete(JPATH_MANIFESTS . '/packages/' . $this->extension->element . '.xml'); + $file = JPATH_MANIFESTS . '/packages/' . $this->extension->element . '.xml'; + + if (is_file($file)) { + File::delete($file); + } $folder = $this->parent->getPath('extension_root'); diff --git a/libraries/src/Installer/Installer.php b/libraries/src/Installer/Installer.php index 02a4868fe3ddc..fdc98c9f102a2 100644 --- a/libraries/src/Installer/Installer.php +++ b/libraries/src/Installer/Installer.php @@ -531,12 +531,16 @@ public function abort($msg = null, $type = null) switch ($step['type']) { case 'file': // Remove the file - $stepval = File::delete($step['path']); + if (is_file($step['path']) && !($stepval = File::delete($step['path']))) { + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $step['path']), Log::WARNING, 'jerror'); + } break; case 'folder': // Remove the folder - $stepval = Folder::delete($step['path']); + if (Folder::exists($step['path']) && !($stepval = Folder::delete($step['path']))) { + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $step['path']), Log::WARNING, 'jerror'); + } break; case 'query': @@ -1437,11 +1441,19 @@ public function parseFiles(\SimpleXMLElement $element, $cid = 0, $oldFiles = nul $deletions = $this->findDeletedFiles($oldEntries, $element->children()); foreach ($deletions['folders'] as $deleted_folder) { - Folder::delete($destination . '/' . $deleted_folder); + $folder = $destination . '/' . $deleted_folder; + + if (Folder::exists($folder) && !Folder::delete($folder)) { + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder), Log::WARNING, 'jerror'); + } } foreach ($deletions['files'] as $deleted_file) { - File::delete($destination . '/' . $deleted_file); + $file = $destination . '/' . $deleted_file; + + if (is_file($file) && !File::delete($file)) { + Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file), Log::WARNING, 'jerror'); + } } } } diff --git a/libraries/src/Installer/InstallerScript.php b/libraries/src/Installer/InstallerScript.php index 23bb71499f6c7..28da7035a4f52 100644 --- a/libraries/src/Installer/InstallerScript.php +++ b/libraries/src/Installer/InstallerScript.php @@ -317,7 +317,7 @@ public function removeFiles() { if (!empty($this->deleteFiles)) { foreach ($this->deleteFiles as $file) { - if (file_exists(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) { + if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) { echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '
'; } } diff --git a/libraries/src/Updater/Update.php b/libraries/src/Updater/Update.php index 8b277e78046ac..8c1d275393cad 100644 --- a/libraries/src/Updater/Update.php +++ b/libraries/src/Updater/Update.php @@ -203,13 +203,21 @@ class Update 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 @@ -355,6 +363,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