bryglen / yii2-sendgrid

sendgrid wrapper for yii 2
MIT License
13 stars 25 forks source link

Error to update to PHP 7.2 #17

Open Macbenach opened 6 years ago

Macbenach commented 6 years ago

When send email apperace this error after update my server to PHP 7.2

message: count(): Parameter must be an array or an object that implements Countable"

file: "/var/www/html/tfd_rh_api/vendor/sendgrid/sendgrid/lib/SendGrid/Email.php"

References:

https://github.com/yiisoft/yii/issues/4167 https://github.com/Automattic/jetpack/issues/8420 https://github.com/invoiceninja/invoiceninja/issues/1767

neverabe commented 6 years ago

@bryglen, there is a way to solve this, did you prefer @Macbenach and me make a PR?

bryglen commented 6 years ago

this is a known issue on 7.2, as of now no support for 7.2

neverabe commented 6 years ago

@bryglen dude, plz upgrade your composer.json at least 6.++, see reference https://github.com/sendgrid/sendgrid-php/releases, you library are to old, plz make the update.

neverabe commented 6 years ago

Hello @bryglen what you think about this snippet

  public function getHeadersJson() {
    if ($this->getHeaders() == NULL) {
     return "{}";
    }

    if (count($this->getHeaders()) <= 0) {
     return "{}";
    }
    return json_encode($this->getHeaders(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
  }

Maybe exist some better code but it seems to solve the problem in php 7.2, i test it in PHP 7.2 and 7.0

neverabe commented 6 years ago

@bryglen, help us

bryglen commented 6 years ago

please create PR

jyotiprava commented 3 years ago

Hello guys, Can use this package https://github.com/ramprasadm1986/yii2-sendgrid