In 2017, Joomla added support for download mirrors. The reason for this addition was the inability to update Joomla in some countries due to Amazon's blockade. #18543
Since then, mirrors have been added to the Joomla update server manifest, including on GitHub.
Unfortunately, this feature has not been working for a long time. Probably there was no urgent need to fix it.
Today, I had time to figure this out. At first, I thought the problem was just that when this feature was made, we forgot to write a timeout into it. But on closer inspection, I noticed that the mirrors don't even get into the update object, meaning part of the code is simply not used.
To start fixing this function, which has long needed fixing, I need to find out when and for what reason this line was added:
https://github.com/joomla/joomla-cms/blob/5.0-dev/libraries/src/Updater/Update.php#L415
Labels |
Added:
No Code Attached Yet
|
Unfortunately, this feature has not been working for a long time. Probably there was no urgent need to fix it.
was this reported anywhere?
was this reported anywhere?
Most likely, this remained in the chats and forums of the Russian-speaking community. No one wrote about it on GitHub.
hard to fix something if no one knows it is broken :)
hmm this is the method that takes care of the additional download sources:
Can you please send us the update server XML you are using?
What error messages do you got?
And what is the status of the primary update URL?
hard to fix something if no one knows it is broken :)
Most likely, this remained in the chats and forums of the Russian-speaking community. No one wrote about it on GitHub.
Can you please send us the update server XML you are using?
Joomla Standard update server
And newer used if this line go to timeout
And what is the status of the primary update URL?
Timeout
Initially, I thought it would be enough to simply add a timeout here.
I already have a solution to the problem, but I need to find out why the mirrors were removed.
And also rewrite the download method.
Hot fix lock like this.
P.S. Please don't judge this code too harshly, I wrote it over breakfast.
public function download()
{
$updateInfo = $this->getUpdateInformation();
$sources = $updateInfo['object']->get('downloadSources', []);
$packageURLs = [
trim($updateInfo['object']->downloadurl->_data),
];
if (count($sources) > 0)
{
foreach ($sources as $source)
{
$url = trim($source->url);
if (!empty($url))
{
$packageURLs[] = $url;
}
}
}
$packageURLs = array_unique($packageURLs);
// We have to manually follow the redirects here so we set the option to false.
$httpOptions = new Registry();
$httpOptions->set('follow_location', false);
// Follow the Location headers until the actual download URL is known
$packageURL = null;
foreach ($packageURLs as $mirrorUrl)
{
try
{
$head = HttpFactory::getHttp($httpOptions)->head($mirrorUrl, [], 10);
}
catch (\RuntimeException $e)
{
continue;
}
while (isset($head->headers['location']))
{
$packageURL = (string) $head->headers['location'][0];
try
{
$head = HttpFactory::getHttp($httpOptions)->head($packageURL, [], 10);
}
catch (\RuntimeException $e)
{
$packageURL = null;
break;
}
}
if ($packageURL)
{
break;
}
}
if ($packageURL === null)
{
// Passing false here -> download failed message
$response['basename'] = false;
return $response;
}
``
Looks good on a quick look from here. Needs to be tested now ofc.
Looks good on a quick look from here. Needs to be tested now ofc.
And optimize.
There you also need to remove the while for the download cycle from mirrors, it is rudimentary with this approach.
Plus we need to decide what to do with the case described in #39446 mb check 404 response?
And my question is, if I make a PR for Joomla 4, will it be accepted?
Feel free to do the PR with test instructions. Everyone is allowed to create PRs ;-)
Feel free to do the PR with test instructions. Everyone is allowed to create PRs ;-)
The question is whether Fix will accept j4 and j5 into the branch or make it only for j5
Well i personally would classify this as a bug fix and therefore send the PR against 4.4 after that the change should be merged up to 5 too.
Ok I'll do PR one of these days
Labels |
Added:
bug
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-11-30 17:40:42 |
Closed_By | ⇒ | alikon |
#39446