-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
DoctrineTokenProvider issue with postgresql #21467
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
Comments
Status: Works for me PostgreSQL is indeed case-insensitive by default. Are you using a custom UserProvider of sorts? Because there is no |
I tried to use custom user provider, but using in-memory at the moment. And indeed reverted that line back and it still works properly. Maybe something was wrong in custom user provider. I'll give it another try with custom user provider soon. |
Aaaand gotcha!
As I've mentioned earlier I'm still using in-memory provider. That happens with the column in question being all-lower-case. Should it be modified to be exactly "lastUsed" in the database, another error shows up:
Also, now that the column is exactly "lastUsed" it is now broken for prod environment as well. Reverting the column in the database back to all-lower-case fixes it for prod environment, but not for the dev environment, which is still broken with aforementioned "Notice: Undefined index: lastUsed" message. Now another experiment. What is wrong here? |
Looks like |
@PF4Public could you please fork the standard edition and reproduce this issue on a new branch with a minimum amount of code? I'd be happy to look into this, but first need a reproducible scenario. |
@jakzal Please inspect my fork here: https://github.com/PF4Public/symfony-standard
So I still suppose that all sql statements do not adequately quote the "lastUsed" field. Which is partially solved if replacing |
This looks really weird (as you can see in the exception message the statement does not use lastused |
It does not look weird to me. |
@PF4Public Would you be interested in working on a patch for this issue? |
As I've already mentioned, replacing 'lastUsed' with 'lastused' with all-lowercase fields in database makes it work for me. It looks like the key issue here is the difference between how MySQL and PostgreSQL treat unquoted strings in field names in SQL queries. Therefore statements from
As for the 1 point - it is relatively easily done, and I believe will not interfere with any other Symfony code. |
Like I said "PostgreSQL is indeed case-insensitive by default.", when you quote the field/table name it's used as intended (the casing is preserved) otherwise it's lowercase. This is conform the SQL99 standard btw 👍
MySQL can actually work bit a funky here when your on a Case sensitive filesystem and using MyISAM, because the table structure is stored in a single file which equals the table name. So the table does exist despite the casing difference 😅 I think we can safely change lastUsed to lowercase, or otherwise use something like |
…DoctrineTokenProvider (PF4Public) This PR was merged into the 2.8 branch. Discussion ---------- [DoctrineBridge] fix case sensitivity issue in RememberMe\DoctrineTokenProvider | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | ? | Fixed tickets | #21467 | License | MIT | Doc PR | - Commits ------- 0248d4f [DoctrineBridge] fix case sensitivity issue in RememberMe\DoctrineTokenProvider
There is an issue with DoctrineTokenProvider if using postgresql.
The problem is that by default postgresql is not case-sensitive unless you apply quotes to your arguments.
Thus creating
lastUsed
table as suggested might result in creating it all-lowercase. All is fine untill you hit:which will throw exception as there's no such field in table. Looks like changing the field to be exactly
lastUsed
might help, but for me exceptions start happening even earlier, since this time some other queries could not obtain this field properly. I ended up replacing'lastUsed'
to be'lastused'
in that particular line.Therefore I wonder is there any better approach to fix this?
As I'm afraid fixing this way might break this code for mysql or any other database.
The text was updated successfully, but these errors were encountered: