Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Send an event before an update site is downloaded #44516

Merged
merged 4 commits into from
Dec 15, 2024

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Nov 24, 2024

Summary of Changes

This pr adds the same logic for installer plugins to be able to modify the update site url and headers as when the extension is downloaded. A use case for this pr is to add some authentication before fetching the update site url like a bearer token, the download id or similar. For extension developers it has an additional benefit to install a plugin and modify update sites for specific clients without the extra step and a modification of the update site url in the database.

Testing Instructions

  • Install an older version of an extension or DPCalendar Free when you don't have one
  • Or you can add the following code to the file /plugins/installer/packageinstaller/src/Extension/PackageInstaller.php
public function onInstallerBeforeUpdateSiteDownload(\Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent $event): void
{
        $event->updateUrl($event->getUrl().'demo=1');
}

and replace the line 47 with:

return ['onInstallerAddInstallationTab' => 'onInstallerAddInstallationTab', 'onInstallerBeforeUpdateSiteDownload' => 'onInstallerBeforeUpdateSiteDownload'];
  • Go to /administrator/index.php?option=com_installer&view=update
  • Click on "Check for updates"

Actual result BEFORE applying this Pull Request

  • DPCalendar update can be found.
  • No warning about an invalid url.

Expected result AFTER applying this Pull Request

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org: Add docu for new update event Manual#340

  • No documentation changes for manual.joomla.org needed

@fgsw
Copy link

fgsw commented Nov 25, 2024

I have tested this item ✅ successfully on 3bd616f

With Pull Request and without it an Update of 'DPCalendar Free' is found.


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

@laoneo
Copy link
Member Author

laoneo commented Nov 25, 2024

I'v updated the testing instructions, to actually see if the event also works.

@HLeithner
Copy link
Member

The event needs validation, if you set a url this should be validated, at least if it is a string hand has a proper schema set. Similar to the headers argument, needs to be an array of strings (with key?).

@laoneo
Copy link
Member Author

laoneo commented Nov 25, 2024

All of this should be done done in the parent class and is not in the scope of this pr.

@fgsw
Copy link

fgsw commented Nov 27, 2024

I have not tested this item.


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

@exlemor
Copy link

exlemor commented Dec 4, 2024

I have tested this item ✅ successfully on aa23300

I have tested this successfully. Please see note below.

To be more precise in case this is important:

BEFORE the PATCH, there was a whole long list of error lines:

For the extension DPCalendar Free version 7.0.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 7.0.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 7.0.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.3.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.2.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.2.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.1.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.11 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.10 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.9 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.8 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 6.0.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.6.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.5.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.5.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.4.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.4.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.4.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.4.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.4.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.8 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.3.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.2.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.2.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.2.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.2.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.2.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.1.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.1.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.1.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 5.0.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.9 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.8 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.2.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.1.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.1.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.1.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.1.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.1.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.12 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.11 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.10 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.9 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.8 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.7 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.6 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.5 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.4 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.3 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.2 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.1 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
For the extension DPCalendar Free version 4.0.0 is available, but it requires at least PHP version 8.3 while your system only has 8.2.26
Before updating ensure that the update is compatible with your Joomla! installation.
You are strongly advised to make a backup of your site's files and database before you start updating.

what is odd is the version I installed was 9.2.1 but the messages stop at 7.0.2

AFTER the PATCH, the messages start with:

Update: Could not open update site #2 "Accredited Joomla! Translations", URL: https://update.joomla.org/language/translationlist_5.xmldemo=1
Update: Could not open update site #3 "Joomla! Update Component", URL: https://update.joomla.org/core/extensions/com_joomlaupdate.xmldemo=1
Update: Could not open update site #4 "Akeeba Backup Core for Joomla!", URL: https://cdn.akeeba.com/updates/pkgakeebabackupcore.xmldemo=1
Update: Could not open update site #5 "Patch Tester Component", URL: https://raw.githubusercontent.com/joomla-extensions/patchtester/master/manifest.xmldemo=1
plus the long list above...


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

@laoneo
Copy link
Member Author

laoneo commented Dec 4, 2024

The DPCalendar warnings are not related to this pr. So we are RTC.


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Dec 4, 2024
@laoneo laoneo changed the title Send an event before an update site is downloaded [5.3] Send an event before an update site is downloaded Dec 7, 2024
@bembelimen bembelimen merged commit f257ff6 into joomla:5.3-dev Dec 15, 2024
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Dec 15, 2024
@bembelimen
Copy link
Contributor

Thx

@bembelimen bembelimen added this to the Joomla! 5.3.0 milestone Dec 15, 2024
@laoneo laoneo deleted the updatesite/event branch December 15, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants