You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During Auth Begin, a session is created without any scope / accessToken etc.. set. So these fields are null. In this state if $session->isValid() is called, it results in a TypeError.
Because isValid calls Context::$SCOPES->equals($this->scope).
Here $this->scope is null. SCOPES->equals calls $scopes = new self($scopes);.
is_string returns false for null type, but this code assumes that is not string, then must be array and continues. Resulting in array_map call throwing a TypeError because it expects array, but null given.
Expected behavior
What do you think should happen?
No PHP TypeError should happen.
Actual behavior
What actually happens?
TypeError
php > require_once'vendor/autoload_runtime.php';
php > $s = new \Shopify\Auth\Scopes(null);
PHPWarning: UncaughtTypeError: array_map(): Argument#2 ($array) must be of type array, null given in /home/******************************/vendor/shopify/shopify-api/src/Auth/Scopes.php:27Stack trace:
#0 /home/******************************/vendor/shopify/shopify-api/src/Auth/Scopes.php(27): array_map()#1 php shell code(1): Shopify\Auth\Scopes->__construct()#2 {main}
thrown in /home/******************************/vendor/shopify/shopify-api/src/Auth/Scopes.php on line 27
Steps to reproduce the problem
php -a
require_once'vendor/autoload_runtime.php';
$s = new \Shopify\Auth\Scopes(null);
Reduced test case
The best way to get your bug fixed is to provide a reduced test case.
Checklist
I have described this issue in a way that is actionable (if possible)
We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Issue summary
During Auth Begin, a session is created without any scope / accessToken etc.. set. So these fields are null. In this state if $session->isValid() is called, it results in a TypeError.
Because isValid calls
Context::$SCOPES->equals($this->scope)
.Here
$this->scope
is null.SCOPES->equals
calls$scopes = new self($scopes);
.And in the constructor of
Scopes
shopify-api-php/src/Auth/Scopes.php
Lines 19 to 27 in d368eef
is_string
returns false for null type, but this code assumes that is not string, then must be array and continues. Resulting inarray_map
call throwing a TypeError because it expects array, but null given.Expected behavior
What do you think should happen?
No PHP TypeError should happen.
Actual behavior
What actually happens?
TypeError
Steps to reproduce the problem
php -a
Reduced test case
The best way to get your bug fixed is to provide a reduced test case.
Checklist
Possible Solution
Adding
?? []
should fix it.Or
Session->isValid
shouldn't callContext::$SCOPES->equals
if$this->scope
is null.The text was updated successfully, but these errors were encountered: