aghstrategies / com.aghstrategies.airmail

Unified CiviCRM bounce event handler for SMTP services
Other
8 stars 13 forks source link

Non-static method CRM_Airmail_EventAction::open() cannot be called statically in CRM_Airmail_Backend_Sendgrid->processMessages() #33

Closed bugfolder closed 1 year ago

bugfolder commented 1 year ago

This error started showing up in the dblog on our Backdrop installation after our first use of the Airmail extension to send a CiviMail using Sendgrid:

Error: Non-static method CRM_Airmail_EventAction::open() cannot be called statically in CRM_Airmail_Backend_Sendgrid->processMessages() (line 57 of /mysite/civi-extensions/com.aghstrategies.airmail/CRM/Airmail/Backend/Sendgrid.php).

The offendling line 57 is this:

          CRM_Airmail_EventAction::open($params);

That function is declared in EventAction.php like this:

  /**
   * Record an opened email.
   *
   * @param array $params
   *   Must include a key `event_queue_id` with the queue of the email
   */
  public function open($params) {
    CRM_Mailing_Event_BAO_Opened::open($params['event_queue_id']);
  }

Since CRM_Mailing_Event_BAO_Opened::open() is a static function, it should be OK to declare CRM_Airmail_EventAction::open() as static, too. And indeed, changing that declaration eliminates the dblog error and results in the correct recording of open events. So I think that fix is simple. Change the declaration to

  public static function open($params) {
    CRM_Mailing_Event_BAO_Opened::open($params['event_queue_id']);
  }

I haven't looked into it closely, but it would appear that the subsequent function, CRM_Airmail_EventAction::click() might also need to be declared static.

elisseck commented 1 year ago

@bugfolder thanks for reporting! Glad you were able to get it working anyways.

This has actually been fixed in exactly the manner you describe in version 2.2. It looks like the downloads page on civicrm.org did not respond to our tagged release (https://civicrm.org/extensions/airmail) so I am going to look into why that didn't connect.

bugfolder commented 1 year ago

@elisseck, the CiviCRM Extensions download page https://civicrm.org/extensions/airmail still shows version 2.1 as being the current release (despite there being a 2.2 version on GitHub). Is that fixable?

bugfolder commented 1 year ago

@elisseck, I see that 2.2.1 is now listed on the extensions page https://civicrm.org/extensions/airmail (thanks!), but the "Notes" link for the download leads to https://github.com/aghstrategies/com.aghstrategies.airmail/releases/tag/2.2.1, which 404s.

elisseck commented 1 year ago

@bugfolder yes thank you for the reminder to fix this release. It just fell off the radar.

The download link works at least... I am not sure why civicrm.org is not using the actual tag name but it appears it does not support the "v" in tags (an old convention I followed without thinking about it). That would be a question for them but the notes link should be https://github.com/aghstrategies/com.aghstrategies.airmail/releases/tag/v2.2.1