-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Fix MariaDB reserved keywords issue #70
Conversation
To be honest: I don’t really like this approach. Running replacements via regular expressions on database queries is generally not a good idea. A better idea may be to replace the Anyway, I think we should apply this fix only to version 4.4, and remove it again in 4.5. |
what if someone already uses PHP 7.1 and therefore DBAL 2.6? Would'nt the name already be escaped? |
Yes, it would. But the regular expression wouldn’t match then. I will add unit tests for these cases after we agree which way we want to go. |
Not really gonna work, the method is |
I'm still not sure we should fix this issue at all. This issue only happens in the latest MariaDB. So I don't understand why you would want to use the latest MariaDB with an old PHP version? Just update to PHP 7.1 and it will all just work fine? |
Yeah, apart from the fact that some users can't control that, and therefore will run into random errors... |
That's such an edge case, really. Why in the world would any provider update their DB stack but not their php stack. That makes no sense at all. |
I think several people already had this problem as discussed in contao/core-bundle#918. So it’s probably not an edge case... |
They do update php as well. But they leave the option to choose an older php version. ;) Imagine, someone has chosen php 5.6 and the provider updates the system. The php version is still the old one. |
It’s protected, not final: https://github.com/doctrine/dbal/blob/v2.5.13/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L1034 But I’m not sure how easy it is to replace the platform service in the doctrine configuration and if it is a good idea to do so. |
I have a bad gut feeling about that regex escaping to be honest. Feels like this can cause more issues than it solves. I know that this PR aims to fix the schema update but you can still have that problem if any extension queries like |
Some projects might have dependencies, that will prevent composer to update to doctrine/dbal 2.6.x. Or projects might have dependencies, that do not run on PHP 7.1 (yet). Just saying, not that I care that much about it ;). In general I agree with @Toflar |
Again. This PR does not solve the issue at all. It tries to solve it for schema updates which would already be covered if you had php 7.1. Still there might be hundreds of extensions that query on a now reserved word without quoting it and we cannot solve the problem for them. Everyone has to solve it individually. It's not a Contao problem. It does not need to be "fixed" by Contao. |
You're right, I was looking at
Replacing the platform is easy and a supported use-case as far as I know, but it would obviously affect the whole Symfony setup and not just Contao. Not sure if we want to do that (same discussion as with all the other Symfony services). Another option would be replace just the keywords class, but that would require reflections. Not that it would matter, as everything in Doctrine (ORM) uses reflections already 😂
Be aware that the database installer already uses tons of regex to convert the Doctrine Schema to our readable instructions. No real issue for me honestly. |
Contao itself uses column names unquoted in many many places, so it has to be fixed by Contao IMO. Either by not using reserved words as column names, or by escaping column names everywhere. |
Correct. And the only update-safe implementation is escaping. Because either we might need to rename over and over again, or just add a new reserved keyword to an existing escaping method. |
With contao/core-bundle#1262 we now escape the column names in Contao properly. As discussed, we don’t want to hack in support for using MariaDB 10.2.4 with PHP 5, so I’m closing this PR. For the record, the following setups should work from now on:
The only setup that is not supported is:
|
Description ----------- This is the port of contao/core#8813. Also see #1106 and contao/installation-bundle#70 Commits ------- 84c4746 Quote reserved words in database queries 7bf64b1 Use static instead of \Database as self-reference.
See contao/core-bundle#918