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] Composer update joomla/database to 3.3.1 for using custom port numbers with PostgreSQL (PDO) #44781

Conversation

richard67
Copy link
Member

@richard67 richard67 commented Jan 26, 2025

Pull Request for Issue #43902 .

Summary of Changes

This pull request (PR) updates the database framework package from 3.2.1 to 3.3.1.

See https://github.com/joomla-framework/database/releases/tag/3.3.0 and https://github.com/joomla-framework/database/releases/tag/3.3.1 for the changes.

This allows Joomla to use custom port numbers with PostgreSQL (PDO) in the same way as it is already possible with MySQLi and MySQL (PDO).

The database drivers have been changes so the same logic is used for all 3 drivers used by the CMS, so for the MySQL (PDO) driver using custom port numbers works as well as before but does not rely on a more or less undocumented behaviour of the PDO database connector.

As using custom port numbers seems not to be really documented somewhere - at least not as far as I could see - there is no documentation to be updated due to this PR.

Testing Instructions

Will be added soon. Will keep in draft mode as long as not done.

Actual result BEFORE applying this Pull Request

Test MySQLi MySQL (PDO) PosgreSQL (PDO)
IPv4 without port number ✅ Success ✅ Success ✅ Success
IPv4 with non-default port number ✅ Success ✅ Success 🟥 Failure
IPv6 without port number ✅ Success ✅ Success ✅ Success
IPv6 with non-default port number ✅ Success ✅ Success 🟥 Failure
Hostname without port number ✅ Success ✅ Success ✅ Success
Hostname with non-default port number ✅ Success ✅ Success 🟥 Failure
Unix socket ✅ Success ✅ Success ✅ Success

Expected result AFTER applying this Pull Request

Test MySQLi MySQL (PDO) PosgreSQL (PDO)
IPv4 without port number ✅ Success ✅ Success ✅ Success
IPv4 with non-default port number ✅ Success ✅ Success ✅ Success
IPv6 without port number ✅ Success ✅ Success ✅ Success
IPv6 with non-default port number ✅ Success ✅ Success ✅ Success
Hostname without port number ✅ Success ✅ Success ✅ Success
Hostname with non-default port number ✅ Success ✅ Success ✅ Success
Unix socket ✅ Success ✅ Success ✅ Success

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

@richard67 richard67 changed the title [5.3] Composer update joomla/database to 3.3.0 for custom port numbers, Unix sockets or IPv6 addresses with PDO drivers [5.3] Composer update joomla/database to 3.3.1 for custom port numbers, Unix sockets or IPv6 addresses with PDO drivers Jan 26, 2025
@richard67 richard67 marked this pull request as draft January 26, 2025 13:34
@muhme
Copy link
Contributor

muhme commented Jan 27, 2025

Running Joomla installation and one Cypress test with each test case before applying the PR with current 5.3-dev and JBT version 2.1.19 and bash or zsh command line:

  1. Create 5.3-dev branch IPv6 installation with joomla-cypress patches as current joomla-cms 5.3-dev branch is still using joomla-cypress 1.1.1 (Update to 1.3.0 is undergoing with [5.3][cypress] com_contenthistory content administrator test #44675). The patches doesn't harm the production environment as they are only needed for Cypress testing.
scripts/create 53 IPv6 joomla-cypress-33 joomla-cypress-36
  1. Preparing tests with non-default database ports by setting up three port forwardings in the Cypress container:
docker exec jbt-cypress bash -c 'apt-get update && apt-get upgrade -y && apt-get install socat -y'
docker exec -d jbt-cypress socat 'TCP6-LISTEN:4711,fork,reuseaddr' 'TCP6:[fd00::11]:3306'; : MySQL
docker exec -d jbt-cypress socat 'TCP6-LISTEN:4712,fork,reuseaddr' 'TCP6:[fd00::12]:3306'; : MariaDB
docker exec -d jbt-cypress socat 'TCP6-LISTEN:4713,fork,reuseaddr' 'TCP6:[fd00::13]:5432'; : PostgreSQL

Optional check the port forwading:

docker exec jbt-cypress netstat -na

Optional check non-default port number database connections:

docker exec -it jbt-mysql bash -c "mysql -h fd00::7 -P 4711 -u root -proot'
docker exec -it jbt-mysql bash -c "mysql -h fd00::7 -P 4712 -u root -proot'
docker exec -it jbt-pg bash -c "PGPASSWORD=root psql -h fd00::7 -p 4713 -U root -d postgres -c 'SELECT version();'"
  1. Download and create one-line script doit53.sh.txt and adopt the setting of types/hosts/ports for each test case:
mv doit53.sh.txt doit53.sh
chmod 755 doit53.sh
  1. ✅ 5/5 tests IPv4 with unset port number by adapting ./doit53.sh and running it:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("10.0.0.11" "10.0.0.11" "10.0.0.12" "10.0.0.12" "10.0.0.13")
ports=("" "" "" "" "")
  1. ✅ 4/5 tests IPv4 with non-default port number by adapting ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("10.0.0.7" "10.0.0.7" "10.0.0.7" "10.0.0.7" "10.0.0.7")
ports=("4711" "4711" "4712" "4712" "4713")

🟥 1/5 the PostgreSQL test failed with:

Could not connect to the database. Connector returned error
message: Could not connect to PDO: SQLSTATE[08006][7] could
not translate host name *10.0.0.7:4713" to address: Name or
service not known
  1. ✅ 5/5 tests IPv6 with unset port number by adapting ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("fd00::11" "fd00::11" "fd00::12" "fd00::12" "fd00::13")
ports=("" "" "" "" "")
  1. ✅ 4/5 tests IPv6 with non-default port number using ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("fd00::7" "fd00::7" "fd00::7" "fd00::7" "fd00::7")
ports=("4711" "4711" "4712" "4712" "4713")

🟥 1/5 the PostgreSQL test failed with:

Could not connect to the database. Connector returned error
message: Could not connect to PDO: SQLSTATE[08006][7] could
not translate host name *[fd00::7]:4713" to address: Name or
service not known
  1. ✅ 5/5 tests hostname with unset port number by adapting ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("jbt-mysql" "jbt-mysql" "jbt-madb" "jbt-madb" "jbt-pg")
ports=("" "" "" "" "")
  1. ✅ 4/5 tests hostname with non-default port number by adapting ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("jbt-cypress" "jbt-cypress" "jbt-cypress" "jbt-cypress" "jbt-cypress")
ports=("4711" "4711" "4712" "4712" "4713")

🟥 1/5 the PostgreSQL test failed with:

Could not connect to the database. Connector returned error
message: Could not connect to PDO: SQLSTATE[08006][7] could
not translate host name *jbt-cypress:4713" to address: Name or
service not known
  1. ✅ 5/5 tests Unix sockets by adapting ./doit53.sh and running it again:
types=("MySQLi" "MySQL (PDO)" "MySQLi" "MySQL (PDO)" "PostgreSQL (PDO)")
hosts=("unix:/var/run/mysql-socket/mysqld.sock" "unix:/var/run/mysql-socket/mysqld.sock" "unix:/var/run/mariadb-socket/mysqld.sock" "unix:/var/run/mariadb-socket/mysqld.sock" "unix:/var/run/postgresql-socket")
ports=("" "" "" "" "")

Applying this PR:

scripts/patch 53 joomla-cms-44781
docker exec jbt-53 composer install

Repeating test steps 3 ... 9

Using either

  • MySQL with database driver "MySQLi" or "MySQL (PDO)", or using
  • MariaDB with database driver "MySQLi" or "MySQL (PDO)", or using
  • PostgreSQL with "PostgreSQL (PDO)" database driver

the Joomla installation and Cypress tests are working with

  • ✅ (3.) Using an IPv4 address,
  • ✅ (4.) Using an IPv4 address and a non-default port number,
  • ✅ (5.) Using an IPv6 address,
  • ✅ (6.) Using an IPv6 address and a non-default port number
  • ✅ (7.) Using a hostname,
  • ✅ (8.) Using a hostname and non-default port number and
  • ✅ (9.) Using Unix sockets.

@richard67 richard67 changed the title [5.3] Composer update joomla/database to 3.3.1 for custom port numbers, Unix sockets or IPv6 addresses with PDO drivers [5.3] Composer update joomla/database to 3.3.1 for using custom port numbers with PostgreSQL (PDO) Feb 2, 2025
@richard67
Copy link
Member Author

Closing in favour of PR #44814 .

@richard67 richard67 closed this Feb 3, 2025
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.

3 participants