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]: StringMap not found #18

Open
1 task done
daveHT opened this issue May 31, 2023 · 4 comments
Open
1 task done

[Bug]: StringMap not found #18

daveHT opened this issue May 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@daveHT
Copy link

daveHT commented May 31, 2023

What happened?

When I try to follow the tutorial for the basic set up I'm getting an internal error

include(StringMap.php): Failed to open stream: No such file or directory

Note that the code from the tutorial works totally fine (I am able to create the StringMap and dispatch the notification) as per the snippet below

function createNotification($enContent): Notification {
$content = new StringMap();
$content->setEn($enContent);
$notification = new Notification();
$notification->setAppId(APP_ID);
$notification->setContents($content);
$notification->setIncludedSegments(['Subscribed Users']);
return $notification;
}

The error is happening deep inside the OneSignal SDK code inside ObjectSerializer.php.
vendor/onesignal/onesignal-php-api/lib/ObjectSerializer.php(93): is_callable()

The call to is_callable() is failing (can't find StringMap).

Interestingly I have no problems including and creating my own StringMaps (along with other OneSignal types) so it's not a dependency issue that I can see. (I'm not ruling out an issue with my composer setup but all else seems to be working).

In ObjectSerializer.php there one line before the offending line there is long list of allowable types that it checks that skip the call to is_callable(). I added StringMap to that list, and everything works perfectly after that. Obviously this solution is a bit of a hack, but it's interesting that everything works after I do that small change (I can get notifications to show up on devices and there are no errors).

if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void', 'StringMap'], true)) {
$callable = [$openAPIType, 'getAllowableEnumValues'];
if (is_callable($callable)) {
......

I talked to support and they advised that they are forwarding to the dev team but also said that I should post here to understand what is happening and see whether this is a bug or issue with my setup.

Thanks!

Steps to reproduce?

1. follow tutorial for basic setup. 2 app crashes with error above

What did you expect to happen?

I expected there to be no error that it couldn't find StringMap.php

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@daveHT daveHT added the bug Something isn't working label May 31, 2023
@emawby
Copy link
Contributor

emawby commented Jun 12, 2023

@daveHT Interesting issue thank you for reaching out. We will investigate!

@daveHT
Copy link
Author

daveHT commented Aug 29, 2023

Any resolution on this? Every time I do a composer update my simple fix above gets overwritten so it would be nice to get this in (or addressed some other way)

@tinora
Copy link

tinora commented Mar 13, 2024

@daveHT do you still experience this issue? For me it seems to work without your "hack". Regards Tino

@LowKey1998
Copy link

@tinora @emawby where can i find the user key token and app key token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants