Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

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

Open
1 task
rizhk opened this issue Jun 7, 2022 · 8 comments
Labels

Comments

@rizhk
Copy link

rizhk commented Jun 7, 2022

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.
@garek007
Copy link

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
Copy link

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])) {

@rizhk
Copy link
Author

rizhk commented Dec 30, 2022

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

@garek007
Copy link

garek007 commented Dec 30, 2022

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.

@rizhk
Copy link
Author

rizhk commented Dec 30, 2022

Ok i will merge it, thank you

@jusmark123
Copy link

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.

@rizhk
Copy link
Author

rizhk commented Apr 17, 2023

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 :)

@jusmark123
Copy link

Will try thanks

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

No branches or pull requests

3 participants