joomla / install-from-web-server

Repository holding the component powering the Install from Web server.
9 stars 31 forks source link

Server returns J3 extension versions for requests from J4 #64

Closed Bakual closed 2 years ago

Bakual commented 3 years ago

While trying out the Weblinks and also my own extension (SermonSpeaker) it noticed that the Webinstaller offers the J3 version of the packages instead of the J4 ones. Once installed, you get an update to the J4 version in the extension updater.

I think the server is missing code to properly take care of Joola 4.0 requests.

Llewellynvdm commented 3 years ago

This is the one place the version set is managed:

https://github.com/joomla/install-from-web-server/blob/master/components/com_apps/models/base.php#L308

To see the JSON that the scrapper works with try this:

view-source:https://extensions.joomla.org/index.php?option=com_jed&view=extension&controller=filter&filter[approved]=1&filter[published]=1&filter[core_catid]=129&format=json

Here is the return set

http://jsoneditoronline.org/#left=cloud.de35690427884e9ea011d178cc9e43ab

The call is made here per category:

https://github.com/joomla/install-from-web-server/blob/master/components/com_apps/models/category.php#L151

The call per extension:

https://github.com/joomla/install-from-web-server/blob/master/components/com_apps/models/extension.php#L69

Still not sure where to issues is, but at a quick glance this is what I found....

Llewellynvdm commented 3 years ago

Download link if its is the XML update server, gets given to the CMS install extension... so me thinking out loud would think the issue is there.

So just to confirm you are using an XML update server as your direct link on the JED, right?

Bakual commented 3 years ago

I honestly don't know what Weblinks is using, but for SermonSpeaker I use the XML (https://raw.githubusercontent.com/Bakual/SermonSpeaker/main/updates.xml), yes. image

Llewellynvdm commented 3 years ago

Okay so once you select the extension in the webinstall, it pass that XML to the install extension.... can you check this?

Bakual commented 3 years ago

No, it doesn't pass the XML, it gets the URL to the ZIP and passes that one. The XML is not returned to the plugin. image

Llewellynvdm commented 3 years ago

Can you check this with weblinks?

Llewellynvdm commented 3 years ago

Hmmm I see it does the same... so it could be the client... still looking.

Llewellynvdm commented 3 years ago

Could be right here... https://github.com/joomla/install-from-web-server/blob/master/components/com_apps/models/extension.php#L175

Not sure but that does look like the moment the download url is build.... wonder if the cache API makes differentiation between Joomla 3 and 4?

Llewellynvdm commented 3 years ago

And since this website APP is running on a Joomla 3 website the Update class only gets what will install on it.

Llewellynvdm commented 3 years ago

Yes I see the filter.dev_level... wonder if it is being passed correctly...

Llewellynvdm commented 3 years ago

image

Llewellynvdm commented 3 years ago

SO nope there is the issue: image

Mw== is 3

So I conclude at this point that this is a client issue.

Llewellynvdm commented 3 years ago

This is where the next search on the client side has started: https://github.com/joomla-extensions/install-from-web-client/blob/master/plugins/installer/webinstaller/webinstaller.php#L134

Llewellynvdm commented 3 years ago

Okay so we could run a test on the server side, by changing these few lines:


if (preg_match('/\.xml\s*$/', $item->downloadurl))
{
    $release = $this->getState('filter.release');

    $update = new Update;
    $update->set('jversion.release', $release);
    $update->loadFromXML($item->downloadurl);
    $packageUrlNode = $update->get('downloadurl', false);

    if (isset($packageUrlNode->_data))
    {
        $item->downloadurl = $packageUrlNode->_data;
    }
}

I am not sure if that will work, but @richard67 thinks the release property contains the version not the dev level, and I would agree with him.

Bakual commented 3 years ago

I wonder why we not just pass the download URL from JED to the client. Why does the server even has to find out itself which version to offer? The CMS is capable of doing that itself and better.

Llewellynvdm commented 3 years ago

Well it could be because the end-user may not know that the XML link will work...

But okay, lets look at that as the solution as I can see the wisdom in that. We don't touch the URL in the app, we pass the xml instead. I will try to test that later today.

Llewellynvdm commented 2 years ago

Okay so now I have tested this and the removal of these lines works well in both Joomla 4 and 3.10

I am just wondering at which point (version) did we add the option for Joomla to install from the update server xml?

Bakual commented 2 years ago

Looks like this commit: https://github.com/joomla/joomla-cms/commit/ef7061b4b4590c38a93399cd81bec4a560405f33 Which would mean since Joomla 3.2.0 (8 years ago) 😄

Llewellynvdm commented 2 years ago

@Bakual I manually made the change to the live system, so you should be able to see how it works now on all websites. Please just confirm in the PR that all works as expected, so I can merge, and conclude this issue resolved/fixed.

Bakual commented 2 years ago

Tested it with Weblinks in a J3 and a J4 site and it worked fine. For my SermonSpeaker it also installed the right version.