FuelSDK-PHP icon indicating copy to clipboard operation
FuelSDK-PHP copied to clipboard

[undefined array index in ET_Client.php in function getAuthTokenExpiration if $tenantKey and $this->tenantTokens are null]

Open rizhk opened this issue 3 years ago • 8 comments

Describe the bug undefined array index in ET_Client.php in function getAuthTokenExpiration if $tenantKey and $this->tenantTokens

To Reproduce use php 7.4 and try to send email

Expected behavior It is doing nothing, because undefined array index in php 7.4

Screenshots If applicable, add screenshots to help explain your problem.

Code snippet function getAuthTokenExpiration($tenantKey) { $tenantKey = $tenantKey == null ? $this->tenantKey : $tenantKey;

              /* please check $tenantKey is already null*/
              /*if ($tenantKey  && $this->tenantTokens[$tenantKey] == null)  */

	if ($this->tenantTokens[$tenantKey] == null) {
		$this->tenantTokens[$tenantKey] = array();
	}
	return isset($this->tenantTokens[$tenantKey]['authTokenExpiration'])
		? $this->tenantTokens[$tenantKey]['authTokenExpiration']
		: null;
}

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (e.g. gif) is not sufficient.

Environment

  • SDK Version 1.3.0
  • PHP version: 7.4

The bug has the severity

  • [ ] Critical: The defect affects critical functionality or critical data. It does not have a workaround.

rizhk avatar Jun 07 '22 04:06 rizhk

Any fix for this? For me, this isn't shutting me down entirely, as I can still make other calls, but it is causing difficulties when integrating with Symfony.

garek007 avatar Dec 29 '22 17:12 garek007

Looks like this may fix it for me, but not sure if doing it this way will have other downstream impacts.

if (!isset($this->tenantTokens[$tenantKey])) {

garek007 avatar Dec 29 '22 17:12 garek007

Great Garek, i will add it to the code. Thank you

rizhk avatar Dec 30 '22 02:12 rizhk

Sorry I mean that I edited my own. I just noticed that you submitted a fix and wanted it merged. I'm unable to merge in this repo.

garek007 avatar Dec 30 '22 02:12 garek007

Ok i will merge it, thank you

rizhk avatar Dec 30 '22 02:12 rizhk

What is the status of this? This makes the code unusable. Is there a workaround? This is quite an old request, so I'm a bit surprised this hasn't been fixed. How do I set the tenant key? The tenantTokens property is never initialized as an array, yet it is assumed to be an array. Even if tenantTokens is initialized as an array, if tenantKey is null, it cannot be used as an array key. This is a pretty glaring problem and should be corrected ASAP.

jusmark123 avatar Apr 15 '23 20:04 jusmark123

hey @jusmark123 could you please use this https://github.com/rizhk/FuelSDK-PHP/commits/v1.7.0 ? let me know if that works for you :)

rizhk avatar Apr 17 '23 22:04 rizhk

Will try thanks

jusmark123 avatar Apr 17 '23 23:04 jusmark123