joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[6.0] Updater: Remove Adapter classes from inheritance

Open Hackwar opened this issue 1 year ago • 22 comments

Summary of Changes

This is an effort to remove deprecated code from the system. The Updater class depends on the Adapter class, which in turn has been deprecated for a long time already. This PR removes the code of the Adapter class from the Updater class and replaces it with some sane methods to add adapters when required.

This PR does some cleanup and it adds the following methods:

  • loadAdapters(): This iterates over the set folder and adds all files it finds as available updater adapters. To keep it light, the array only contains the name as key and either the class name as value or an object. The object is instantiated just in time when needed.
  • getAdapters(): This method keeps the behavior of the $custom parameter, but otherwise still just returns the list of available adapters
  • getAdapter(): This new method replaces loadAdapter() and either returns an object which was previously made or instantiates it from the class stored in the $adapters array.
  • setAdapter(): This new method allows to hand in a name for the adapter and either a class name or an instantiated object for the respective adapter type. This would allow you to add custom adapter types and also to overwrite existing adapter types.

I reused some method names from the Adapter class. This PR is a b/c break and thus targeted towards 6.0. This is the corresponding PR to #43792 for the Updater classes.

Testing Instructions

Test that updating Joomla still works.

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org:

  • [X] No documentation changes for docs.joomla.org needed

  • [X] Pull Request link for manual.joomla.org: https://github.com/joomla/Manual/pull/301

  • [ ] No documentation changes for manual.joomla.org needed

Hackwar avatar Jul 14 '24 22:07 Hackwar

@hackwar, sorry Hannes more conflicts need fixing. If we can sort this and #43792, we can merge #43794.

Bodge-IT avatar Feb 12 '25 08:02 Bodge-IT

@hackwar Is this still relevant?

Bodge-IT avatar Feb 19 '25 08:02 Bodge-IT

Yes, this is still a necessary PR.

Hackwar avatar Feb 19 '25 09:02 Hackwar

...Awaiting capability to run updater

Bodge-IT avatar Jun 06 '25 17:06 Bodge-IT

@muhme @Bodge-IT the PR is ready. Could you two test this? Since you already tested the other PR...

Hackwar avatar Jun 10 '25 12:06 Hackwar

I have tested this item :white_check_mark: successfully on 0fbb612eaacefff27a3f4c8ecc9e84c3c69258d2

Tested before PR with JBT, current 6.0-dev branch, PHP 8.4.7, enabled 'Log Almost Everything' and 'Log Deprecated API'

  • Installed module zitat-service.de version 2.0.1 from URL https://github.com/muhme/quote_joomla/releases/download/2.0.1/mod_zitat_service_de_2.0.1.zip, configured and checked it is working
  • Update 2.0.3 is shown as available (this needs targetplatform version 6 for the module), updated, checked version is updated in administrator backend and file system XML and checked is still working
  • Uninstalled the module and installed again 2.0.1 with file upload, configured and checked is working
  • Installed over by 'Upload Package File' with 2.0.3 ZIP, checked version is updated in administrator backend and file system XML and checked is still working

Installed 60 joomla-cms-43793, PHP 8.4.7, enabled 'Log Almost Everything' and 'Log Deprecated API'

  • Installed module zitat-service.de version 2.0.1 from URL https://github.com/muhme/quote_joomla/releases, configured and checked it is working
  • ✅ Update 2.0.3 is shown as available, updated, checked version is updated in administrator backend and file system XML and checked is still working
  • Uninstalled the module and installed again 2.0.1 with file upload, configured and checked is working
  • ✅ Installed over by 'Upload Package File' with 2.0.3 ZIP, checked version is updated in administrator backend and file system XML and checked is still working
  • Uninstalled the module and installed again 2.0.1, configured and checked is working
  • ✅ Installed over by 'Install from URL' with https://github.com/muhme/quote_joomla/releases/download/2.0.3/mod_zitat_service_de_2.0.3.zip, checked version is updated in administrator backend and file system XML and checked is still working
  • Uninstalled the module and installed again 2.0.1, configured and checked is working
  • ✅ Installed over by 'Install from Folder', checked version is updated in administrator backend and file system XML and checked is still working
  • Uninstalled the module and installed 2.0.1 with CLI, configured and checked is working
docker exec jbt-60 php cli/joomla.php extension:install --path /var/www/html/tmp/mod_zitat_service_de_2.0.1.zip
  • Installed over with CLI, checked version is updated in administrator backend and file system XML and checked is still working
docker exec jbt-60 php cli/joomla.php extension:install --path /var/www/html/tmp/mod_zitat_service_de_2.0.3.zip
  • ✅ no errors in administrator/logs/everything.php
  • the ~170'000 messages in administrator/logs/deprectaed.php search case independent for updat results in following, please check by your own:
$ grep -i updat joomla-60/administrator/logs/deprecated.php 
2025-06-12T09:08:46+00:00	WARNING 10.0.0.1	deprecated	Use method "getUrl" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetUrl" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:08:46+00:00	WARNING 10.0.0.1	deprecated	Use method "getHeaders" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetHeaders" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getUrl" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetUrl" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getHeaders" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetHeaders" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getUrl" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetUrl" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getHeaders" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetHeaders" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getUrl" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetUrl" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:09:28+00:00	WARNING 10.0.0.1	deprecated	Use method "getHeaders" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetHeaders" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:19:15+00:00	WARNING 10.0.0.1	deprecated	Use method "getUrl" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetUrl" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168
2025-06-12T09:19:15+00:00	WARNING 10.0.0.1	deprecated	Use method "getHeaders" for value pre-processing is deprecated, and will not work in Joomla 6. Use "onGetHeaders" instead. Event Joomla\CMS\Event\Installer\BeforeUpdateSiteDownloadEvent - [ROOT]/libraries/src/Event/AbstractEvent.php - Line 168

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

muhme avatar Jun 12 '25 09:06 muhme

Thank you for testing. As far as I can see, none of the warnings you got are related to this PR, right?

Hackwar avatar Jun 12 '25 15:06 Hackwar

Thank you for testing. As far as I can see, none of the warnings you got are related to this PR, right?

It seems so, as the deprecations are from different files, as touched with this PR. I was uncertain how to check. I checked now again with the three file names they are touched by the PR and result is zero ✅ 👍 :smile:

muhme avatar Jun 12 '25 15:06 muhme

Unfortunately I had to do one more cleanup by removing a duplicate call to getAdapter().

Hackwar avatar Jun 13 '25 05:06 Hackwar

Unfortunately I had to do one more cleanup by removing a duplicate call to getAdapter().

Null problemo, let me know when you're done, then I'll test again – my module is now Joomla 6 ready, this was my main effort; maybe put it on DRAFT by then?

muhme avatar Jun 13 '25 06:06 muhme

It is ready. You can test this now.

Hackwar avatar Jun 13 '25 06:06 Hackwar

I have tested this item :white_check_mark: successfully on b0685d4c5d0b0c4bf905c2d164084e310536f150

Retestet with JBT and grafted 6.0.0-alpha2-dev+pr.43793 from current prebuild packages

  • Enabled 'Log Almost Everything' and 'Log Deprecated API'
  • Followed the same procedure as in the first test with install/configure/checks/install over/checks/uninstall:
    • ✅ Update 2.0.3 is shown as available, updated
    • ✅ Installed over by 'Upload Package File' with 2.0.3 ZIP
    • ✅ Installed over by 'Install from URL'
    • ✅ Installed over by 'Install from Folder'
    • ✅ Installed over with CLI, using file package
    • ✅ Installed over with CLI, using URL
    • ✅ no errors in administrator/logs/everything.php
    • ✅ no deprecation entries for the ExtensionAdapter.php, Updater.php and UpdateAdapter.php in the ~136.000 lines
      This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43793.

muhme avatar Jun 13 '25 13:06 muhme

I have tested this item :white_check_mark: successfully on b0685d4c5d0b0c4bf905c2d164084e310536f150

I have successfully tested this.

Used JoomDonation v5.10.9 to update to JoomDonation v5.11.0, also upgraded 2 different Language Packs to latest version. (I also tried installing a few J6 compatible apps as a test, like Regular Labs Cache Cleaner 9.60 and others)

(the Joomla Updater did NOT find the updated version of JoomDonation online, but I was able to install v5.11 on top of v5.10.9 via uploading the file)

I did NOT test over CLI or locally. I only tested via online my hosting testing environments.


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

exlemor avatar Jun 16 '25 21:06 exlemor

@ exlemor Thank you for testing :+1:

the Joomla Updater did NOT find the updated version of JoomDonation online

If you check the update XML https://joomdonation.com/updates/jdonation.xml, there is no 6.0 target platform, so no update is offered correctly.

muhme avatar Jun 17 '25 04:06 muhme

Thanks for testing, RTC


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

rdeutz avatar Jun 17 '25 06:06 rdeutz

Thanks everyone, @Hackwar, @muhme & @exlemor . Great work.

Bodge-IT avatar Jun 17 '25 07:06 Bodge-IT

I can't begin to express how happy I am that this is finally done. Thank you to all who tested, reviewed and now merged. I've been trying to fix the adapter classes during the development of 1.6 and tried again in 2.5 and 3.5. For 4.0 unfortunately I didn't get around to fixing this, but now for 6.0 we can finally get rid of this.

Hackwar avatar Jun 17 '25 07:06 Hackwar