? ? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
25 Mar 2021

Summary of Changes

This PR is a first pass attempt at resolving some of the long running issues with the storage and passing of the extra_query to update urls.

Namely these issues are addressed in this PR:

  1. Once an update has been discovered, the #__updates table is populated with a copy of the extra_query from the #__update_sites table. If a user then goes and adds a new/updates a extra_query using an extension (this populates the #__update_sites.extra_query table ONLY!) then the already discovered update will fail to work, as the #__updates. extra_query is the one appended to the update URL at update time.

  2. On clicking Rebuild button on the update sites page, any previously entered extra_query that is stored in #__update_sites.extra_query is lost. This PR will preserve the #__update_sites.extra_query value based on the URL of the location of a URL. As long as the URL remains the same, the newly inserted row in #__update_sites after rebuild will still contain the value of the #__update_sites.extra_query from before the rebuild - thus preserving this value.

  3. Updates sites do not display in the admin interface the extra_query value like Joomla 4 does.

  4. Location URLS can contain whitespace at the start and end of a URL if the XML has whitespace for formatting

Background

Well, #__update_sites.extra_query is any string value a developer wants to place in that table column, which, when checking for updates, will be appended to the update Url.

It is commonly used to positively identify a particular user, site, subscription or "license" for commercial (but not exclusively commercial use!)

Testing Instructions

as below

Actual result BEFORE applying this Pull Request

  1. Install an old version of an extension that requires an extra_query to update it later. Go to check for updates in Joomla Update Manager, see that you have discovered the update. Go to your extension and enter your new download id/extra_query provided by your supplier. Go back to the updates page and attempt to apply the cached update. See that the update fails! with some kind of rejection/403 from your supplier.

  2. View your #__update_sites table, enter some values for #__update_sites.extra_query - Click Rebuild on the Update Sites Page - note that #__update_sites.extra_query values are now missing.

  3. Install an old version of an extension that requires an extra_query to update it later. Add the Download ID/Update Id/extra_query provided by the vendor. Go to the Update Sites screen and see no visual indication that there is a extra_query stored for this update site.

Expected result AFTER applying this Pull Request

  1. Install an old version of an extension that requires an extra_query to update it later. Go to check for updates in Joomla Update Manager, see that you have discovered the update. Go to your extension and enter your new download id/extra_query provided by your supplier. Go back to the updates page and attempt to apply the cached update. See that the update succeeds!

  2. View your #__update_sites table, enter some values for #__update_sites.extra_query - Click Rebuild on the Update Sites Page - note that #__update_sites.extra_query values are now preserved.

  3. Install an old version of an extension that requires an extra_query to update it later. Add the Download ID/Update Id/extra_query provided by the vendor. Go to the Update Sites screen and see a new visual indication that there is a extra_query stored for this update site.

  4. All urls imported from XML are trimmed of their surrounding whitespace

Documentation Changes Required

None.

Testing Instructions

Edit lin 420 of administrator/components/com_installer/models/update.php to add echo $url; die; this will echo out the URL that Joomla will attempt to download any updates from, and we can look at that debug output and see if an extra query was used or not in our tests. We are not interested in the actual download of the file or applying the update, as those code areas have not been touched, we are only interested in the URL used.

Install Joomla 3
install https://www.joomlacontenteditor.net/downloads/editor/core?task=release.download&id=223
Go to Extensions -> Manage -> update -> clear cache -> find updates -> You will see JCE 2.9.4 available
Edit your #__update_sites table and set extra_query = ABCDEF where the name = JCE Editor Package (this simulated a Pro version of an extension saving an extra query)
Attempt to apply the update - note that the debug print of the URL DOESNT CONTAIN THE ABCDEF appended.
Rebuild your site then Apply PR and repeat above -> Note that the debug print of the URL DOES CONTAIN THE ABCDEF appended.

Install Joomla 3
install https://www.joomlacontenteditor.net/downloads/editor/core?task=release.download&id=223
Edit your #__update_sites table and set extra_query = ABCDEF where the name = JCE Editor Package (this simulated a Pro version of an extension saving an extra query)
In Joomla Admin -> Extensions-> Manage -> Update Sites -> Click rebuild
Inspect the database - #__update_sites table entry you added for ABCDEF is removed
Rebuild your site then Apply PR and repeat above, this time the ABCDEF is retained after Rebuild button is pressed, and the extra_query is also displayed on the page

Install Joomla 3
install https://www.joomlacontenteditor.net/downloads/editor/core?task=release.download&id=223
Edit your #__update_sites table and set extra_query = ABCDEF where the name = JCE Editor Package (this simulated a Pro version of an extension saving an extra query)
Visit Joomla Admin -> Extensions-> Manage -> Update Sites
Note there is nothing to indicate that there is an extra_query
Apply PR
refresh the page and you can now see the extra_query in a new pre box.

Install Joomla 3
install https://www.joomlacontenteditor.net/downloads/editor/core?task=release.download&id=223
Inspect your #__update_sites table and see additional whitespace before the URL
Rebuild your site then Apply PR and repeat above
Inspect your #__update_sites table and see NO additional whitespace before the URL

Install Joomla 3
install an extension that has trailing or prepended space to the update server url in its XML file.
Inspect your #__update_sites table and see additional whitespace before the URL
Rebuild your site then Apply PR and repeat above
Inspect your #__update_sites table and see NO additional whitespace before the URL

History

This addresses some of #32592 / #32597

avatar PhilETaylor PhilETaylor - open - 25 Mar 2021
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Mar 2021
Category Administration com_installer Libraries Front End Plugins
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 25 Mar 2021
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 25 Mar 2021
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 25 Mar 2021
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
Labels Added: ?
avatar wilsonge wilsonge - change - 25 Mar 2021
The description was changed
avatar wilsonge wilsonge - edited - 25 Mar 2021
avatar PhilETaylor PhilETaylor - change - 25 Mar 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 25 Mar 2021
avatar richard67
richard67 - comment - 25 Mar 2021

@PhilETaylor Not sure if it's an issue, but theoretically, as the update sites table doesn't have any unique index on the location column, it can be that there are several update sites with the same location but different extra queries. Practically I think it's unlikely because that wouldn't make much sense.

avatar PhilETaylor
PhilETaylor - comment - 25 Mar 2021

That would make no sense like you say. There is a comment somewhere about multiple update sites and not allowing it.. let me see if I can find that again...

avatar PhilETaylor
PhilETaylor - comment - 25 Mar 2021

// Look if the location is used already; doesn't matter what type you can't have two types at the same address, doesn't make sense

This code stops the same location being inserted into the db table twice.

avatar richard67
richard67 - comment - 25 Mar 2021

@PhilETaylor Good that we checked.

avatar richard67
richard67 - comment - 25 Mar 2021

Next question is where do I find an extension which needs an update query. Do you have some examples? I don't use such on my private site.

avatar PhilETaylor
PhilETaylor - comment - 25 Mar 2021

They are mainly paid for updates, inc Akeeba and Admin Tools ... email me direct for test copy.

You dont need a valid download id for them, as you can die after echoing the URL that will be used, and that url should confirm that it will use the extra

Die on this blank line with echo $url; die;

avatar richard67
richard67 - comment - 27 Mar 2021

@PhilETaylor Would a hello world component plus an update site which are extended as described here https://joomdonation.com/forum/os-property/24123-extra-query-not-working.html plus some redirect rules in .htaccess for the extra query URLs to make sure the an URL from version x is not used with the next media ID query parameter of version y and vice versa, i.e. return a 404 if it doesn't match, do the job? I could provide the update site with the redirect rules, but with the component I'd need help maybe.

avatar PhilETaylor
PhilETaylor - comment - 27 Mar 2021

That is overkill for the purposes of testing. Nothing has changed with the actual remote checking of an XML stream or the application of an update.

The only things changed are how Joomla internally handles rebuilding the update sites table and how Joomla internally handles the application of an extra_query on an already cached update.

You can use ANY old extension that has an update available, and manually edit the db tables. I'll try to write up some instructions to test that route after lunch.

avatar richard67
richard67 - comment - 27 Mar 2021

I'll try to write up some instructions to test that route after lunch.

Bon appetite!

avatar PhilETaylor PhilETaylor - change - 27 Mar 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 27 Mar 2021
avatar PhilETaylor
PhilETaylor - comment - 27 Mar 2021

Testing instructions have been added to the opening post of this issue

All four bugs fixed have instructions.

Thanks for testing, I know there is a lot of set up and time needed to test, but honestly this fixes a bug that has plagued Joomla for years.

avatar richard67
richard67 - comment - 27 Mar 2021

Will test later today or tomorrow.

avatar joomdonation
joomdonation - comment - 28 Mar 2021

I have spent sometime to review the code and have few questions (hopefully it is not stupid question because I don't understand the code/logic of the whole update process):

avatar joomdonation
joomdonation - comment - 28 Mar 2021

I also made PR PhilETaylor#1 to your branch with suggestion to improve code to save the system from have to run for each loop. Please review to see if it looks OK for you and If yes, merge it.

Also, in the issue #32592, the author suggested this solution:

Proposed solution: clear the query cache when you clear the update cache

Do you know what query cache is he talking about? Would be nice if we can figure out solve all the reported issues with extra_query on this PR.

avatar richard67
richard67 - comment - 28 Mar 2021

Do you know what query cache is he talking about? Good be nice if we can figure out solve all the reported issues with extra_query on this PR.

@joomdonation I'm not sure, but maybe Nicholas means the MySQL query cache, which is something used by MySQL versions lower than 8.0.2 but has been removed with 8.0.2, while MariaDB still has that query cache. See e.g. this PR here: #32028 .

avatar joomdonation
joomdonation - comment - 28 Mar 2021

@richard67 Maybe not because he mentioned about clear Joomla cache in his instructions for his customers.

avatar richard67
richard67 - comment - 28 Mar 2021

@richard67 Maybe not because he mentioned about clear Joomla cache in his instructions for his customers.

That's why I wrote I'm not sure.

avatar richard67
richard67 - comment - 28 Mar 2021

@PhilETaylor I've found a few code standards issues, like not using names quoting in that DB query which has been modified with the last commit to use "TRIM", or with the function parameter $extra_query using underscore instead of camel case. If you want, fix it, or let me know when I should suggest changes or make a PR to your branch to make it easier for you. Personally, I can also live with it if we fix it with a later PR, if you say "don't bother me with that now".

avatar PhilETaylor
PhilETaylor - comment - 28 Mar 2021

Sorry, I just hit the merge button, I have other work overdue for the weekend I need to concentrate on after spending the last 3 days in open source land. the code passed all the automated checks.

I'll be happy to merge any PR's you make against the branch.

avatar richard67
richard67 - comment - 28 Mar 2021

I'll be happy to merge any PR's you make against the branch.

That's ok for me.

avatar PhilETaylor
PhilETaylor - comment - 28 Mar 2021

Merged

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

This one would be a good one to test so that it can make it for Joomla 3.9.26.... if maybe.

avatar richard67
richard67 - comment - 31 Mar 2021

Stay tuned, I will test tomorrow or on Friday or weekend . Same for the other PRs.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Thanks - I dont know when 3.9.26 is being cut... but I was kind hoping it was this week ready for release next week :(

avatar richard67
richard67 - comment - 31 Mar 2021

I don’t know when 3.9.26 will be prepared, but I’m clarifying. I am too tired now to test anything today. As said, I hope I can use our Easter weekend.

avatar joomdonation
joomdonation - comment - 1 Apr 2021

@PhilETaylor I have reviewed the code and I believe that it would address the issue. However, I have few concerns which I mentioned at #32862 (comment) . Do you want to take a look at it?

avatar PhilETaylor
PhilETaylor - comment - 1 Apr 2021

Should we always use extra_query from #__update_sites table instead of extra_query from #__updates table?

Maybe, but the purpose of this PR was to be light touch, and not to change too much, not to introduce any huge issues at the end of the Joomla 3 series with the hope that this would quickly be tested and merged to Joomla 3.9.26 (the second version that was never meant to be released...) as most of these issues are already resolved in Joomla 4, but it would be nice to fix for those staying with Joomla 3 for the next decade.

Do you have a better way to pass extra_query to the plugin? For example, pass the parameter in the plugin trigger

Could do, I have no preference either way, but again was trying not to make any method call changes (but I guess a new array key can't hurt right...)

avatar joomdonation
joomdonation - comment - 1 Apr 2021

@PhilETaylor Leave it as how it is for now. I will test it ASAP

avatar joomdonation
joomdonation - comment - 1 Apr 2021

Received. Thanks !

avatar joomdonation
joomdonation - comment - 2 Apr 2021

After looking more at how update works, I believe we should always use extra_query from #__update_sites table instead using extra_query from #__updates table. That will make it easier for users to perform an update in case they has to update the Download ID (in case he enters a wrong Download ID before)

Currently, if user has to update Download ID, he will have to:

  • Update the Download ID in the extension
  • Go back to update screen:
  • Clear Cache to remove the found updates
  • Click on Find Updates button to find updates again
  • And then perform the update for the extension he wants

If we use extra_query directly from #___update_sites table, users will just have to:

  • Update the Download ID in the extension
  • Go back to update screen, perform updating for the extension they want

That simplify the process and also make more sense. Users won't know that they have to clear cache, then find updates again after updating the Download ID in the extension.

With that said, I made PR PhilETaylor#4 to your branch. Please think about it and if you agree, merge it so that we can move forward.

avatar PhilETaylor
PhilETaylor - comment - 2 Apr 2021

Will test and merge when away - currently 4:46am :-) and I'm asleep

avatar joomdonation
joomdonation - comment - 2 Apr 2021

Will test and merge when away - currently 4:46am :-) and I'm asleep

Why wake up and answer at this time :( ? Go sleep :).

avatar PhilETaylor
PhilETaylor - comment - 2 Apr 2021

Why wake up and answer at this time :( ? Go sleep :).

The joys of running a global business, you never sleep, you always have one eye and ear on incoming emails and alerts ;-)

I have merged your changes - thanks.

avatar joomdonation joomdonation - test_item - 2 Apr 2021 - Tested successfully
avatar joomdonation
joomdonation - comment - 2 Apr 2021

I have tested this item successfully on 4a52cfd

Real test and carefully code review, too.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32862.

avatar richard67 richard67 - test_item - 2 Apr 2021 - Tested successfully
avatar richard67
richard67 - comment - 2 Apr 2021

I have tested this item successfully on 4a52cfd


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32862.

avatar richard67 richard67 - change - 2 Apr 2021
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 2 Apr 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32862.

avatar PhilETaylor
PhilETaylor - comment - 2 Apr 2021

Thanks again to those who took the time to understand this issue and tested the PR, I appreciate it. Thank you.

avatar joomdonation
joomdonation - comment - 2 Apr 2021

Thanks again to those who took the time to understand this issue and tested the PR, I appreciate it. Thank you.

You are not alone :D .

avatar HLeithner HLeithner - change - 6 Apr 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-04-06 13:10:16
Closed_By HLeithner
Labels Added: ?
avatar HLeithner HLeithner - close - 6 Apr 2021
avatar HLeithner HLeithner - merge - 6 Apr 2021
avatar HLeithner
HLeithner - comment - 6 Apr 2021

Thanks

avatar richard67
richard67 - comment - 6 Apr 2021

Also, in the issue #32592, the author suggested this solution:

Proposed solution: clear the query cache when you clear the update cache

Do you know what query cache is he talking about? Would be nice if we can figure out solve all the reported issues with extra_query on this PR.

@joomdonation @PhilETaylor Meanwhile I think he meant the Joomla cache for particular components like system, com_installer and a few others, when update sites have been rebuilt. Possibly we should check that and make a follow up PR.

avatar joomdonation
joomdonation - comment - 6 Apr 2021

@richard67 Actually, he is talking about caching the updates found (Joomla! has that set to 6 hours by default). By using extra_query directly from #__update_sites instead of #__updates table as we are doing now, I think the issue with extra_query should be fully sorted by now. See the attached screenshot to see the caching I am talking about here
update_sites_caching

avatar PhilETaylor
PhilETaylor - comment - 6 Apr 2021

s/__DEPLOY_VERSION/__DEPLOY_VERSION__ #33038

avatar PhilETaylor
PhilETaylor - comment - 6 Apr 2021

@joomdonation @PhilETaylor Meanwhile I think he meant the Joomla cache for particular components like system, com_installer and a few others, when update sites have been rebuilt. Possibly we should check that and make a follow up PR.

" regarding the query cache, Joomla needs to delete the _system cache which caches Models' queries to the database. Otherwise changing the extra_query in the #__update_sites has no effect. The next time Joomla tries to fetch updates it will call the same model, use the same _system cache and end up using the old extra_query"

avatar PhilETaylor
PhilETaylor - comment - 6 Apr 2021

Add a Comment

Login with GitHub to post a comment