Separate from #2833969: Document that there is no support for Twilio 5 PHP library:

The module currently doesn't support Twilio's 5.x version of their php sdk and only works with the 4.x version.

Since 4.x is deprecated and we don't know why (security? using legacy api features that will get dropped?) it would be good to upgrade the tfa_basic code to work with the 5.x version of Twilio's code.

This will require the minimum php version to be 5.5, which seems fine for anyone interested in security is likely already on that or newer anyway.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles created an issue. See original summary.

esolitos’s picture

I might be able to step in to help as I'll need to use a PIN authentication for a project soon.

I'll be in touch with a patch hopefully soon.

greggles’s picture

Good to hear, esolitos! Would be great to get this support working well with a modern version of the Twilio library.

jpsalter’s picture

This patch supports the latest version of the Twilio PHP library (5.26.0).
You can install the library via composer or direct download and it should work correctly.

greggles’s picture

Status: Active » Needs review

Thanks so much for your work!

I noticed a few nitpick things:

+        // the number you'd like to send the message to

Comments should start with an upper case and be a sentence that ends with punctuation.

+    'version callback' => array('\Twilio\VersionInfo', "string"), // Calls Twilio version function via PHP array syntax

Same punctuation missing here and comments should be on a line on their own (no trailing comments).

These are very small issues so I'll leave it at needs review, but would be good to fix prior to commit.

greggles’s picture

whoops and need to fix up my credit.

jpsalter’s picture

I've added punctuation to the comments. Thanks for the feedback.

greggles’s picture

Thanks, jpsalter. I just noticed a few more things:

+  // Necessary to get the version information

Missing punctuation on that one.

+    'version callback' => array('\Twilio\VersionInfo', "string"), // Calls Twilio version function via PHP array syntax.

This comment should be moved to it's own line like below.

+    // Calls Twilio version function via PHP array syntax.
+    'version callback' => array('\Twilio\VersionInfo', "string"),

Or the comment could be removed.

I'm unlikely to be able to test this functionality - would be great if other folks could.

jpsalter’s picture

klausi’s picture

there is still an old "@return Services_Twilio|FALSE" doc comment.

Please make sure to update all references to Services_Twilio.

jpsalter’s picture

Updated the comments. Changed the catching of an exception too.

jpsalter’s picture

Fixing logic for library load.

jpsalter’s picture

Sorry - wrong diff before. This fixes the logic.

hoegrammer’s picture

Hi, the patch in #13 nearly worked for me but I had to make a further change:

In tfa_basic.module I replaced
if (module_exists('libraries') && $library = libraries_load('twilio') && !empty($library['loaded'])) {
    $twilio_available = TRUE;
}

with

if (module_exists('libraries') && $library = libraries_load('twilio')) {
  if (!empty($library['loaded'])) {
    $twilio_available = TRUE;
  }
}

I'm puzzled as to why this made any difference, but without it I found that the Twilio fields (SID, etc) were missing from the setup form.

It's odd, because I don't see why that change should make any difference! (If anyone can shed light on this I'd be grateful). Thanks!

klausi’s picture

Updated patch which has a couple more safe guards to not throw fatal errors when the library is not available.

@hoegrammer: I think the problem was that there was an assignment in the if(), which is never a good idea. Also changed that in the patch.

The most annoying thing about this upgrade is that the Twilio library version 5 is now 190k lines of code!! This is huge and I don't want to add all the irrelevant Twilio class files to my composer classmap. I decided to use it with the libraries API instead.

klausi’s picture

Forgot to update info file where the library is also referenced.

Graber’s picture

Priority: Normal » Major

Bumping priority as this is a serious issue, the module doesn't even document which version of the library is supported (currently none probably).