Are you new? Read the FAQ and catch up on!
18k views

Janrain's PHP OpenID library fixed for PHP 5.3 (and how I did it)

First things first. Here you can download my version of Janrain's PHP OpenId library, fixed for PHP 5.3.

Now, I will explain what I did to make it work.

I found the first hints to solve the problem in this ticket at the library's trac. More precisely, the second comment in which someone suggested to fix one of the first errors by modifying the Auth_OpenID_detectMathLibrary (File: Auth/BigMath.php Line: 365). The new function looks like this:

PHP
  1. function Auth_OpenID_detectMathLibrary($exts)
  2. {
  3.     $loaded = false;
  4.  
  5.    // > This if is the only modification to the function <
  6.    if ( ! function_exists( 'dl' ) )
  7.     {
  8.         return false;
  9.     }
  10.  
  11.     foreach ($exts as $extension)
  12.     {
  13.     // See if the extension specified is already loaded.
  14.         if ($extension['extension'] &&
  15.             extension_loaded($extension['extension']))
  16.         {
  17.             $loaded = true;
  18.         }
  19.  
  20.         // Try to load dynamic modules.
  21.         if (!$loaded)
  22.         {
  23.             foreach ($extension['modules'] as $module)
  24.             {
  25.                 if (@dl($module . "." . PHP_SHLIB_SUFFIX))
  26.                 {
  27.                     $loaded = true;
  28.                     break;
  29.                 }
  30.             }
  31.         }
  32.  
  33.         // If the load succeeded, supply an instance of
  34.         // Auth_OpenID_MathWrapper which wraps the specified
  35.         // module's functionality.
  36.         if ($loaded)
  37.         {
  38.             return $extension;
  39.         }
  40.     }
  41.  
  42.     return false;
  43. }
  44.  

­

After modifying that function the library seemed to work better, but I kept getting a lot of warnings and errors. To fix them I removed all the pass-by-reference elements (as suggested here) and added the static keyword to all the static functions. After doing this with a lot of patience, I finally got it working even using Google as vendor.

You can do this yourself, but you will probably prefer just to download my code and keep it if it works for you.

Tags: PHP Janrain OpenID PHP 5.3

Embed: