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

Document the serverVersion option in a forward-compatible manner #5971

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

derrabus
Copy link
Member

Q A
Type documentation
Fixed issues N/A

Summary

The examples that we give for the serverVersion option are all invalid as per #5779, which means they will not work in DBAL 4. This PR changes the affected section of the documentation.

@derrabus derrabus added this to the 3.6.2 milestone Mar 20, 2023
@derrabus derrabus requested a review from morozov March 20, 2023 13:58
@derrabus derrabus requested a review from greg0ire March 20, 2023 14:01
alexander-schranz added a commit to alexander-schranz/recipes that referenced this pull request Mar 20, 2023
Comment on lines 345 to 347
e.g. ``8.0.32`` instead of just ``8`` if your server is a MySQL 8.0.32. This
means that if you are running a MariaDB database, you should suffix the
``serverVersion`` with ``-MariaDB`` (ex: ``10.11.2-MariaDB``).
Copy link
Member

@morozov morozov Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the "you should suffix" part as it's controversial. The user should specify the server version verbatim, without adding or removing anything. The documentation could suggest running the following code snippet and using its output as the value of serverVersion:

echo $connection->getServerVersion(), PHP_EOL;

Specific versions of MariaDB could be used as an example. In my case, it produces:

10.11.2-MariaDB-1:10.11.2+maria~ubu2204

Note that this method is private in DBAL 3, so the snippet needs to be adapted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're talking about MySQL/MariaDB specifically, we could refer to whatever this query returns:

SELECT VERSION();

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're talking about MySQL/MariaDB specifically [...]

Are we? This documentation applies to all platforms for which the DBAL has different implementations for different versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we? This documentation applies to all platforms for which the DBAL has different implementations for different versions.

True, but the fact that we're parsing the suffix of a version string is very much specific to MariaDB.

Copy link
Member

@morozov morozov Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is an implementation detail of our version detection logic. Why should users be aware of that?

The whole extent of this feature is providing the server version in the configuration in order to prevent the application from connecting to the database during the calls to Connection::getServerVersion(). The more implementation details we expose via the documentation, the more chances are that the documentation will become obsolete at some point or will have to be continuously changed alongside the changes in supported platforms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A private getServerVersion() is also an implementation details in form of a choice to outsource some logic into a private method. Private methods can be removed and shouldn't appear in the docs. Maybe it should be added to the branch for version 4 though.

I'm not sure if we currently have a generic way to get the server version string for the config,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point. It is private because it's only used for platform detection and is not supposed to be used outside of DBAL. But the thing is that we want to call it in order to use by the DBAL internally.

Anyways, I think this issue doesn't deserve that much discussion. I'm fine with whatever you all decide.

@derrabus
Copy link
Member Author

derrabus commented Mar 27, 2023

We need to tell people to use a verbatim version string, but all DBAL APIs that would deliver that string are internal.

I've updated my PR with detailed instructions for MySQL, MariaDB and Postgres on how to get the version string without DBAL. For other platforms, the version string is currently irrelevant, but I've documented the use of the internal APIs for that matter, although I'm not very comfortable with such APIs appearing in the documentation.

btw, I've tried to reply in the thread, but GitHub threw HTTP 500 responses at me when I tried to do so. 😓

@derrabus
Copy link
Member Author

All right, pushing to my branch doesn't work either at the moment. I guess, we need to wait until GitHub got rid of its little hiccup. 😑

docs/en/reference/configuration.rst Outdated Show resolved Hide resolved
docs/en/reference/configuration.rst Outdated Show resolved Hide resolved
greg0ire
greg0ire previously approved these changes Apr 2, 2023
@derrabus derrabus merged commit 377036a into doctrine:3.6.x Apr 2, 2023
@derrabus derrabus deleted the docs/server-version branch April 2, 2023 14:05
symfony-recipes-bot pushed a commit to symfony/recipes that referenced this pull request Apr 28, 2023
* Add mariadb example to DATABASE_URL

* Apply change requests

* Use same casing as in the doctrine/dbal mariadb docs

See doctrine/dbal#5971

* Update doctrine/doctrine-bundle/2.8/manifest.json

Co-authored-by: Alexander M. Turek <me@derrabus.de>

* Use only major version for postgresql serverVersion

---------

Co-authored-by: Alexander M. Turek <me@derrabus.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants