Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update SentMessage.php #43040

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

Closed
wants to merge 1 commit into from
Closed

Update SentMessage.php #43040

wants to merge 1 commit into from

Conversation

dima-gr
Copy link
Contributor

@dima-gr dima-gr commented Sep 15, 2021

Sometimes the response from the server can be null, because of this, the application is terminated

Q A
Branch? 5.4 for features / 4.4 or 5.3 for bug fixes
Bug fix? yes/no
New feature? yes/no
Deprecations? yes/no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Sometimes the response from the server can be null, because of this, the application is terminated
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@@ -36,7 +36,7 @@ public function getTransport(): string
return $this->transport;
}

public function setMessageId(string $id): void
public function setMessageId(?string $id): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to avoid calls to this method with null if possible.

@OskarStark
Copy link
Contributor

Which transport are you using ?

@dima-gr
Copy link
Contributor Author

dima-gr commented Sep 16, 2021

firebase - Symfony\Component\Notifier\Bridge\Firebase
and when the response comes null, then in the logs appears warning that the unknown index 'message_id', and then a critical error that the parameter cannot be null
$sentMessage->setMessageId($success['results'][0]['message_id']);
you can try to check for the existence of id in the response, if it does not exist, then pass an empty string to setMessageId. Maybe it will be better

@OskarStark
Copy link
Contributor

OskarStark commented Sep 16, 2021

Yes please check and only call setMessageId in the Firebase transport if it's a string

@dima-gr
Copy link
Contributor Author

dima-gr commented Sep 16, 2021

i can modify Symfony\Component\Notifier\Bridge\Firebase\FirebaseTransport.php
and check something like that
$sentMessage->setMessageId(isset($success['results'][0]['message_id']) ? : '');
and then make pull request

@nicolas-grekas
Copy link
Member

I saw that you removed your fork.
Please submit the PR again when you're ready, and please take time to properly fill in the PR template, the commit message, add a test case if possible also.
Thanks.

@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Sep 17, 2021
@fabpot
Copy link
Member

fabpot commented Sep 17, 2021

@dima-gr Your suggestion is indeed the fix that I would like to see.

fabpot added a commit that referenced this pull request Sep 19, 2021
This PR was submitted for the 5.4 branch but it was squashed and merged into the 5.3 branch instead.

Discussion
----------

[Notifier] Update FirebaseTransport.php

prevent setting null value from firebase response, previous pull request - #43040

| Q             | A
| ------------- | ---
| Branch?       | 5.4 for features / 4.4 or 5.3 for bug fixes <!-- see below -->
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 5.x.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->

Commits
-------

b9ab0ad [Notifier] Update FirebaseTransport.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants