diff --git a/administrator/components/com_joomlaupdate/controllers/update.php b/administrator/components/com_joomlaupdate/controllers/update.php index ba9bf5528412e..f29eb71878c11 100644 --- a/administrator/components/com_joomlaupdate/controllers/update.php +++ b/administrator/components/com_joomlaupdate/controllers/update.php @@ -50,6 +50,15 @@ public function download() $message = null; $messageType = null; + // Try to use the fallback file + if ($file === false) + { + $file = $model->download(true); + + $message = JText::_('COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED_FALLBACK'); + $messageType = 'message'; + } + if ($file) { JFactory::getApplication()->setUserState('com_joomlaupdate.file', $file); diff --git a/administrator/components/com_joomlaupdate/models/default.php b/administrator/components/com_joomlaupdate/models/default.php index 106c9804e7aed..87dcdb9b84661 100644 --- a/administrator/components/com_joomlaupdate/models/default.php +++ b/administrator/components/com_joomlaupdate/models/default.php @@ -243,15 +243,28 @@ public function purge() /** * Downloads the update package to the site. * + * @param boolean $fallback Try to use the fallback download path file if available + * * @return bool|string False on failure, basename of the file in any other case. * * @since 2.5.4 */ - public function download() + public function download($fallback = false) { $updateInfo = $this->getUpdateInformation(); $packageURL = $updateInfo['object']->downloadurl->_data; - $headers = get_headers($packageURL, 1); + + // Overwrite the $packageURL incase we are in fallback mode and there is a fallbackdownloadurl + if ($fallback === true && isset($updateInfo['object']->fallbackdownloadurl->_data)) + { + $packageURL = $updateInfo['object']->fallbackdownloadurl->_data; + } + elseif ($fallback === true) + { + return false; + } + + $headers = get_headers($packageURL, 1); // Follow the Location headers until the actual download URL is known while (isset($headers['Location'])) diff --git a/administrator/language/en-GB/en-GB.com_joomlaupdate.ini b/administrator/language/en-GB/en-GB.com_joomlaupdate.ini index b18c99410373d..92864230defbc 100644 --- a/administrator/language/en-GB/en-GB.com_joomlaupdate.ini +++ b/administrator/language/en-GB/en-GB.com_joomlaupdate.ini @@ -68,7 +68,8 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update J COM_JOOMLAUPDATE_VIEW_PROGRESS="Update progress" COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESREAD="Bytes read" -COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED="Download of update package failed." +COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED="For some reason the download of the primary update package failed." +COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED_FALLBACK="For some reason the download of the primary update package failed. But there was a fallback URL defined for that cases that we are going to use now." COM_JOOMLAUPDATE_VIEW_UPDATE_FILESEXTRACTED="Files extracted" COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_CONFIRM_AND_CONTINUE="Confirm & Continue" COM_JOOMLAUPDATE_VIEW_UPDATE_FINALISE_HEAD="Joomla Update is finishing and cleaning up"