User tests: Successful: Unsuccessful:
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:
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.
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.
Updates sites do not display in the admin interface the extra_query
value like Joomla 4 does.
Location URLS can contain whitespace at the start and end of a URL if the XML has whitespace for formatting
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!)
as below
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.
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.
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.
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!
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.
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.
All urls imported from XML are trimmed of their surrounding whitespace
None.
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
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_installer Libraries Front End Plugins |
Labels |
Added:
?
|
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...
This code stops the same location being inserted into the db table twice.
@PhilETaylor Good that we checked.
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.
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;
@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.
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.
I'll try to write up some instructions to test that route after lunch.
Bon appetite!
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.
Will test later today or tomorrow.
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):
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.
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 .
@richard67 Maybe not because he mentioned about clear Joomla cache in his instructions for his customers.
@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.
@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".
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.
I'll be happy to merge any PR's you make against the branch.
That's ok for me.
Merged
This one would be a good one to test so that it can make it for Joomla 3.9.26.... if maybe.
Stay tuned, I will test tomorrow or on Friday or weekend . Same for the other PRs.
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 :(
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.
@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?
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...)
@PhilETaylor Leave it as how it is for now. I will test it ASAP
Received. Thanks !
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:
If we use extra_query directly from #___update_sites table, users will just have to:
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.
Will test and merge when away - currently 4:46am :-) and I'm asleep
Will test and merge when away - currently 4:46am :-) and I'm asleep
Why wake up and answer at this time :( ? Go sleep :).
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.
I have tested this item
Real test and carefully code review, too.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Thanks again to those who took the time to understand this issue and tested the PR, I appreciate it. Thank you.
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 .
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:
?
|
Thanks
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.
@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
@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"
@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.