Skip to content

[5.4] Refactor CMS Table classes #45243

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

Merged
merged 7 commits into from
May 16, 2025

Conversation

joomdonation
Copy link
Contributor

@joomdonation joomdonation commented Mar 28, 2025

Pull Request for Issue # .

Summary of Changes

Similar to #45242, this is follow PR for #45165. It makes the following changes to CMS Table classes defined in libraries/src/Table folder:

  • Replace DatabaseDriver by DatabaseInterface for $db param in class constructor
  • Use $this->getDatabase() method to get db object instead of using deprecated $this->_db property
  • Replace $this->getDbo() calls by $this->getDatabase()
  • Introduce local $db variable to replace multiple $db->getDatabase() call if needed

I do not know if it is useful or not but I want to mention that the task #2 and #3 above can be done automatically using two useful two rector rules below:

Testing Instructions

It is not needed to test any change, we can expect that when it works for some that it works for all. Please test if you can create an Article, Category, Menu Item, User, Viewlevel. Just pick 2 of the list.

Actual result BEFORE applying this Pull Request

Works

Expected result AFTER applying this Pull Request

Works, without using deprecated code

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:

  • No documentation changes for manual.joomla.org needed

@brianteeman
Copy link
Contributor

is there a list being maintained somewhere of all the rector rules that have been used

@joomdonation
Copy link
Contributor Author

is there a list being maintained somewhere of all the rector rules that have been used

Currently, we don't. For every PR I made which use rector rules, I clearly mentioned the rules I use and link to documentation of the rule so that if someone wants to use it for his extensions, he can follow. Ideally, we should have rector rules to help automatically refactoring code from old Joomla version to compatible with newer Joomla version like other projects do, for example craftcms/rector, but right now, we do not have anyone can handle that work yet.

@HLeithner
Copy link
Member

@joomdonation code review is not enough, cloud you please write test instruction, in this case test all touched table classes?

@joomdonation
Copy link
Contributor Author

@HLeithner If we could not do code review and want to have testing instructions for human test, I think we would have to split this PR into multiple small PRs, each PR for one table class. If this is the case, I will close the PR and open separate small PRs

@HLeithner
Copy link
Member

I think own prs are not needed, just a list of components touched and the test instruction to open and close and save something should be enough.

@joomdonation
Copy link
Contributor Author

Aren't all these basic operations are covered by our tests already?

@HLeithner
Copy link
Member

at this time I think that doesn't matter because we require 2 real user tests (can be discussed in maintainers), this pr came up in the maintainer meeting yesterday.

@joomdonation
Copy link
Contributor Author

For this kind of PR, I don't think real user tests are enough because the testing instructions for changes in multiple places like that might not cover all the cases. Careful code review + tests pass should be better, I think.

@HLeithner
Copy link
Member

code review is done by the person that merges anyway. As said discuss this in maintainers chat/meeting please.

@joomdonation
Copy link
Contributor Author

I'm closing this PR because it touch multiple table classes and it is not easy for real user tests. I will open multiple small PRs instead to make it is easier for human testing

@joomdonation joomdonation reopened this May 9, 2025
@richard67
Copy link
Member

PR has been reopened and testing instructions have been updated.

Let's hope we find testers now.

@richard67
Copy link
Member

I have tested this item ✅ successfully on 3621c2e

I've successfully tested Blog Sample Data installation, creation and modification of users and user groups, categories, articles and installing and using a 3rd party extension which uses categories and assets with MySQL 8 and some of that also with PostgreSQL, both on PHP 8.4.

In addition, I've made a detailed code review of the changes.

Finally I've triggered a branch update for this PR to make sure system tests are passing with the recently upmerged change that the system tests check for errors in server logs (PR #45409 ).


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

@richard67
Copy link
Member

richard67 commented May 11, 2025

Hints for other testers:

  • Make sure to have PHP error reporting set to maximum in global configuration so you would see any PHP notices or warnings or errors, if there were some.
  • As this PR does not make any changes where the type of the database is relevant, it is sufficient to test with one kind of database (MySQL, MariaDB or PostgreSQL).
  • The PR should be tested on a current 5.4-dev or latest 5.4 nightly build. If you don't have that, you can find here patched installation and update packages which are the latest 5.4-dev plus the changes from this PR: https://artifacts.joomla.org/drone/joomla/joomla-cms/5.4-dev/45243/downloads/84629/

@joomdonation
Copy link
Contributor Author

Thanks Richard for helping with CS and testing.

@dautrich
Copy link

I have tested this item ✅ successfully on 3621c2e


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 12, 2025
@dautrich
Copy link

I tested on a Nightly Build 5.4-dev, PHP 8.3.6, MySQL 8.0.30 locally under Laragon.

@richard67 richard67 added this to the Joomla! 5.4.0 milestone May 12, 2025
@muhme
Copy link
Contributor

muhme commented May 15, 2025

Tested successfully together with 45242

  • Environment Apple arm64 M3, JBT (Docker-based), pgsql socket, PHP 8.4.7 (with Display Errors: On and error_reporting: maximum), 5.4-dev + 45242 + 45243, Joomla Log Almost Everything and Log Deprectaed API
  • ✅ Joomla System Tests
    • Individual tests fail, but pass when repeated as a single test (as is often the case)
  • ✅ Manually tested
    • Created a user
    • Created an article and featured on home
    • Installed module zitat-service.de from JED, published and placed on all pages

@muhme muhme merged commit f2b1243 into joomla:5.4-dev May 16, 2025
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 16, 2025
@muhme
Copy link
Contributor

muhme commented May 16, 2025

thanks to all

@joomdonation
Copy link
Contributor Author

Thanks all for your help !

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.

8 participants