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

Pass a custom variable to flush() #358

Open
fx1234 opened this issue Oct 13, 2022 · 5 comments
Open

Pass a custom variable to flush() #358

fx1234 opened this issue Oct 13, 2022 · 5 comments

Comments

@fx1234
Copy link

fx1234 commented Oct 13, 2022

We are using the following simple code to flush the Queue:

foreach( $webPush->flush() as $report ){ .... }

The problem is, we need our own variables (the UserID) inside the loop. Is there a way to pass custom variables into the loop? Maybe so that it is available in $report

@tgves
Copy link

tgves commented Jan 31, 2024

any ideas?

@Gugu7264
Copy link
Contributor

I'm unsure I understand the underlying problem here. If you are able to access your own variables when calling flush, why can't you use them inside the for loop?

I know this is old, but the issue is not closed so apparently still an issue

@fx1234
Copy link
Author

fx1234 commented Jun 18, 2024

I think it was about connecting our internal user IDs directly with the push notifications without having to get this information from the database within the loop for each notification.

With a large number of outgoing notifications, this would mean a lot of extra database queries inside the loop

I don't have direct access to the code right now and because it was a while ago, I'm not 100% sure whether the problem was more extensive. But basically it was about making our own information available for each notification inside the loop

@Gugu7264
Copy link
Contributor

Okay, I think I get what you mean because I'm encountering the same issue. I end up using the endpoint to find the user 😁

@fx1234
Copy link
Author

fx1234 commented Jun 18, 2024

If you send a large number (thousands) of notifications at the same time, it is a big overhead if you have to get the data from the database for each user. It would therefore be better if you had a way to have the required data available directly in $report

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

3 participants