Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
upgrade.jpg

The updating or upgrading process for a FusionPBX is really straight forward:

  1. Keep open a PHP session
  2. Replace the PHP files
  3. Run the upgrade script
  4. Update menus

This afternoon, while I was upgrading a customer I notice that the CDR was not recording.

What was Happening?

FusionPBX uses a big and complex array to save all the information, including the database one. This array is declared in many places, one of them is the app_config file. So, here it is the code declaration that was failing:

$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "xml_cdr_uuid";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";

The array declaration has nothing wrong.

While debugging the schema object in the FusionPBX PHP Code (resources/classes/schema.php), I found that the index 'name' could be or not an array. So, the error here is that if the name index is an array, FusionPBX code doesn't do anything. As a consequence, the database field won't be created and the SQL queries involving it will fail.

I found similar fields in the v_destination table.

The Fix

Around line 639 of the resources/classes/schema.php file (FusionPBX 4.4), I added the following code:

else{
    if ($field['exists'] == "false") {
        $sql_update .= "ALTER TABLE ".$table_name." ADD ".$field['name']["text"]." ".$field_type.";\n";
    }
}

Pull requests #4097 and #4100 have been sent. I will update this article when they get an answer. UPDATE: They were accepted!

If you don't feel confident about upgrading your FusionPBX, contact me.

Good luck!

blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.