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

Incrementing token results in SQL error #3969

Closed
AugustMiller opened this issue Mar 8, 2019 · 1 comment
Closed

Incrementing token results in SQL error #3969

AugustMiller opened this issue Mar 8, 2019 · 1 comment

Comments

@AugustMiller
Copy link
Contributor

AugustMiller commented Mar 8, 2019

Description

When setting a usageLimit on a new Token and subsequently accessing/consuming the token, I'm getting an error about an unknown column:

Error Info: Array
(
    [0] => 42703
    [1] => 7
    [2] => ERROR:  column "usagecount" does not exist
LINE 1: UPDATE "tokens" SET "usageCount"=usageCount + 1, "dateUpdate...
                                         ^
HINT:  Perhaps you meant to reference the column "tokens.usageCount".
)

It sounds like something's wrong with new Expression('usageCount + 1'), but I'm useless when it comes to SQL expressions! 😢

Steps to reproduce

  1. Create a Token with a usageLimit: $tokens->createToken(['controller/action', ['param' => 'val']], 100);;
  2. Trigger the token by making a request: https://mydomain.com/path?token=EQhn5d29k1kT-1yjldVbi8gFRZf0v2h6;
  3. Maybe observe error?

Additional info

  • Craft version: Craft Pro 3.1.15
  • PHP version: 7.2.14
  • Database driver & version: PostgreSQL 10.6
  • Plugins & versions: Commerce, and a couple of business-logic plugins (one of which generates this token)
@brandonkelly
Copy link
Member

Thanks, that’s fixed for the next release.

To get the fix early. change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#8a4f94fd46ff187c0a293c24713f58960d9f4ef2 as 3.1.17.1",
  "...": "..."
}

Then run composer update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants