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

Bug: Config value returned as a string instead of an int #151

Open
JesseMaxwell opened this issue Nov 13, 2023 · 1 comment
Open

Bug: Config value returned as a string instead of an int #151

JesseMaxwell opened this issue Nov 13, 2023 · 1 comment

Comments

@JesseMaxwell
Copy link

Steps to replicate:

  1. Install gigya/magento2-im version 6.1.1
  2. Add product to cart
  3. Go to checkout
  4. Expected: no Gigya-related console errors
  5. Actual: Uncaught SyntaxError: Unexpected token ',': sessionExpiration: ,

Background

The problem is apparent when we go to: \Gigya\GigyaIM\Model\Config::getSessionMode. The docblock indicates that the return type is int. However, there is no type-coercion in place so the docblock is misleading. The \Magento\Framework\App\Config\ScopeConfigInterface::getValue that it directly returns affirms that the return type is actually mixed.

Then, if we go to \Gigya\GigyaIM\Block\GigyaScript::getUserSessionLifetime, we notice that the match statement is based only in integers.

The fix is simple: add (int) to the return of \Gigya\GigyaIM\Model\Config::getSessionMode. OR: add (int) the $mode declaration in \Gigya\GigyaIM\Block\GigyaScript::getUserSessionLifetime.

@cristian-vatca-osf
Copy link
Collaborator

The next version has this type casting for every \Gigya\GigyaIM\Model\Config method and function return type declaration

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