Error upgrading from FreePBX 12 to 13

Hi,

I am trying to upgrade from FreePBX 12 (latest versions of all modules) to FreePBX 13 on an Asterisk 11 PBX in a Flash build. The upgrade passes all the checked, but when it starts I get and error (no detail and suggests running from the command line). When I run from the command line I get:


amportal && fwconsole ma upgradeall

Please wait…

/var/lib/asterisk/bin/freepbx_engine: line 119: Whoops\Exception\ErrorException:: command not found
new amportal script detected, copying it to /usr/local/sbin and attempting to backup up old
Creating symlink for fwconsole
Removing broken fwconsole link
!!!amportal is depreciated. Please use fwconsole!!!
forwarding all commands to 'fwconsole’
Whoops\Exception\ErrorException: Undefined index: PHP_CONSOLE in file /var/www/html/admin/bootstrap.php on line 181
Stack trace:

  1. Whoops\Exception\ErrorException->() /var/www/html/admin/bootstrap.php:181
  2. Whoops\Run->handleError() /var/www/html/admin/bootstrap.php:181
  3. require_once() /etc/freepbx.conf:9
  4. include_once() /var/lib/asterisk/bin/fwconsole:12

I have two Asterisk 11/FreePBX 12 PBXes and they get the identical error, so I don’t think it is corruption of a single server.

Any ideas? I am hoping to get the existing 32bit CentOS 6.5 boxes up to FreePBX 13 so I can then do a backup of the configuration and import it onto a new 64bit CentOS 7 server.

Thanks

Graham

The Distro based on Centos 7 only runs FreePBX 14, so you can’t restore from a 13 backup anyway. If it’s not too late, you are probably better off using the migration script:
https://wiki.freepbx.org/display/PPS/Elastix+and+PBXinaFlash+to+FreePBX+Distro+Conversion+Tool

Thanks for your comment.

I wouldn’t be using the Distro, it will be a clean CentOS 7 64bit server with Asterisk 13 and FreePBX 13 installed.

Thanks

Graham

Okay, well good luck with that. I hope it works out better than your current installs which fail to upgrade.

That is possibly the worst post I have ever seen. Just because I am not in a position to use the sangoma distro suddenly no help and a very sarcastic comment.

What happened to the ‘community’ aspect of this? If it is ‘your way or the highway’ and no community support if your distribution isn’t used, why even provide instructions on how to install FreePBX?

Using a distro is what I did previously (PBX in a Flash) and I now have an error when trying to upgrade (2.11 to 12 worked fine). The existing installs are years old and been upgraded in place multiple times. The FreePBX distro didn’t even exist when we built these boxes.

Or is selling commercial modules the only thing that matters now?

Anyone else able to help?

Graham

I would help if I could. You have dismissed a viable path forward that I can see. No sarcasm was intended (tho I concede my wording could have been better), I was genuinely sincere with my wish that things work out for you.

Thanks for your reply.

So as the maintainers of the code, nobody in Sangoma can give any feedback on why I would be getting the error:

Whoops\Exception\ErrorException: Undefined index: PHP_CONSOLE in file /var/www/html/admin/bootstrap.php on line 181

Yes, I have ‘dismissed’ one possible path forwards, but I am sure their are plenty of others such as:

  • Someone who is familiar with the code provides some information on what it is looking for at that point so I could fix the issue
  • Someone who has seen the same or similar problem could provide their solution to the problem

Just because I can’t use the Sangoma distribution, it doesn’t mean other possibilities aren’t open.

Graham

A quick look at the code suggests it is looking for a parameter called PHP_CONSOLE in /etc/amportal.conf. Is this something that should be present on FreePBX 12 or should it have been added by the FreePBX 13 upgrade process?

Looking on my new box, it is present in /etc/amportal.conf and set to FALSE. Is it safe to just add it or is it being missing a symptom of something more fundamental?

Thanks

Graham

Hi,

I am sure that when they have time and an idea of what is wrong they will reply.

They are under no obligation to do that though and there are things that come before that like working on FreePBX, most of which is not commercial…

From searching other threads it looks like something didn’t get installed properly and the best course of action might be to reinstall them manually…

On a few applications we have at work I am now the only maintainer left and sometimes, when we get such weird error messages and we can see that something somehow corrupted the install, the only thing I can suggest is to reinstall…

For your specific problem one of the reasons might be lack of disk space. Is it that important to find which files could not get copied instead of manually installing what could not?

(after taking care of the disk space problem that is…)

Let me dig up the thread that resemble your problem in some way…

Good luck and have a nice day,

Nick

Thanks for the reply Nick.

Plenty of space on the server, but a good thing to check!

I have wound the boxes back to before the FreePBX 13 upgrade attempt. It is an identical error on both servers so I don’t think it is as simple as something not installing properly, I think it may be either something missing in amportal.conf (see my other post) or something that is supposed to update amportal.conf not running.

These boxes have been through multiple upgrade cycles from very early builds of Asterisk 11 (yes, that long!)

Thanks

Graham

Hi Graham,

You might want to check if one of the things that were suggested in this thread helps you:

I am not a PHP programmer (I am a programmer though) but this sounds to me this sounds like bootstrap.php can’t find the file (or finds an previous version of the file) which is supposed to define PHP_CONSOLE…

Is it because the file was not installed or doesn’t have the right permissions (you did try a fwconsole chown hopefully), it is difficult to say hence why trying to reinstall over what was “installed” might work…

Your problem is probably related to that… Something the module/script was unable to deal is probably preventing it to complete successfully like it did for other people…

Good luck and have a nice day!

Nick

I had this same problem, and was not able to find a “clean” resolution elsewhere. Let me tell you what worked for me:

Start by editing the bootstrap.php file, and comment out (leading //) the 6-7 lines referencing the PHP_CONSOLE index. I wish I had taken a screenshot before proceeding, these lines are from after I completed the upgrade, so they may not be an exact match but should be fairly close:

if($amp_conf[‘PHP_CONSOLE’]) {
$connector = PhpConsole\Connector::getInstance();
if(!empty($amp_conf[‘PHP_CONSOLE_PASSWORD’])) {
$connector->setPassword($amp_conf[‘PHP_CONSOLE_PASSWORD’]);
}
$handler = PhpConsole\Handler::getInstance();
$handler->start();
}

So with the comments it ended up looking like this:

//if($amp_conf[‘PHP_CONSOLE’]) {
// $connector = PhpConsole\Connector::getInstance();
// if(!empty($amp_conf[‘PHP_CONSOLE_PASSWORD’])) {
// $connector->setPassword($amp_conf[‘PHP_CONSOLE_PASSWORD’]);
// }
// $handler = PhpConsole\Handler::getInstance();
// $handler->start();
//}

After I saved the file, I was able to get back into FreePBX. It had all kinds of errors and warnings relating to module versions. From here I proceeded with the “manual” process that I had used to upgrade from FreePBX 11 to 12, which is doing the online check & upgrade process for all modules. You’ll have to do it several times to work through all of the dependencies, etc.

Right off the bat, though, the System Admin module wouldn’t update because the Core module was the wrong version. I couldn’t get to the Core update through the UI, so back to the CLI to run this command:

amportal a ma update core

After that completed, I was able to update System Admin through the UI, and after that it let me update all of the other modules to 13 (also through UI).

I did have to install userman (User Manager) and cel (Call Event Logging) before it would let me update some of the other modules, FYI. This may be unique to my system, though, so only install the dependencies you need.

Apply Config once everything is up to date. Everything seems to be functioning correctly, and I rebooted the server just to make sure changes/stability would persist.

I went back to bootstrap.php to un-comment those lines, but the upgrade process apparently fixed that for me.

Hope this helps!

1 Like

That’s fantastic, thank you.

I will give this a try at my next maintenance window.

My thought was to add the missing entries from amportal.conf but this looks to be a simpler option.

Thanks again

Graham

amportal.conf isn’t used. Hasn’t been since 2.9. So adding anything there wouldn’t do it. You can comment those lines out or you could also open a bug report if you really wanted someone to look at it.

“amportal.conf isn’t used” - the section of code with the error in bootstrap.php is definitely opening amportal.conf to try and find those settings, which are missing.

If this isn’t used then commenting out the code would appear to be the best option.

Graham

amp_conf, which you referenced, is populated from the database not from amportal.conf.

Undefined index is happening because the value doesn’t exist in the database yet. This is because bootstrap is loaded before the script that installs these settings. Commenting it out makes it so it doesn’t look for it. An easier way to fix this is to just wrap the initial if in an !empty()

Perhaps you could show me where in bootstrap it’s opening amportal.conf

Opening a bug report would be your best bet to get it fixed so we can remember we have to do this.

Another weekend, another attempt at upgrading from FreePBX 12 to 13. The error shown at the top of this thread appears to be a secondary error once the first one I have now isolated has happened. I tried to do the upgrade from the CLI rather than the GUI so I would get more information, and got this:

installing files to /var/www/html..done
installing files to /var/lib/asterisk/bin..done
installing files to /var/lib/asterisk/agi-bin..done
Checking for upgrades..
7 found
Upgrading to 13.0.1alpha1..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.1alpha1/upgrade.php
Upgrading to 13.0.1alpha1..OK
Upgrading to 13.0.50..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.50/upgrade.php
Upgrading to 13.0.50..OK
Upgrading to 13.0.143..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.143/upgrade.php
Upgrading to 13.0.143..OK
Upgrading to 13.0.190.2..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.190.2/upgrade.php
Upgrading to 13.0.190.2..OK
Upgrading to 13.0.190.10..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.190.10/upgrades.php
Upgrading to 13.0.190.10..OK
Upgrading to 13.0.192.15..
-> Running PHP script /var/www/html/admin/modules/framework/upgrades//13.0.192.15/upgrade.php
PHP Fatal error:  Uncaught exception 'Exception' with message 'Attempted to load /var/www/html/admin/libraries/BMO/ModulesConf.class.php but it didn't define the class ModulesConf' in /var/www/html/admin/libraries/BMO/Self_Helper.class.php:210
Stack trace:
#0 /var/www/html/admin/libraries/BMO/Self_Helper.class.php(100): Self_Helper->loadObject('ModulesConf')
#1 /var/www/html/admin/libraries/BMO/Self_Helper.class.php(36): Self_Helper->autoLoad('ModulesConf')
#2 /var/www/html/admin/libraries/BMO/FreePBX.class.php(84): Self_Helper->__get('ModulesConf')
#3 /var/www/html/admin/modules/framework/upgrades/13.0.192.15/upgrade.php(2): FreePBX::__callStatic('ModulesConf', Array)
#4 /var/www/html/admin/modules/framework/upgrades/13.0.192.15/upgrade.php(2): FreePBX::ModulesConf()
#5 /var/www/html/admin/modules/framework/installlib/installer.class.php(148): include_once('/var/www/html/a...')
#6 /var/www/html/admin/modules/framework/installlib/installer.class.php(109): FreePBX\Install\Installer->install_upgrade('13.0.192.15')
#7 /var/www/ht in /var/www/html/admin/libraries/BMO/Self_Helper.class.php on line 210

Once this has happened, if you try the upgrade again without rolling back the server you get the bootstrap.php error.

Doing some Googling I can see a few people have seen the error, but I can’t find any solutions.

Any help would be gratefully received.

Thanks

Graham

Additional update. I thought maybe some PHP component was missing so I ran the dependencies command for FreePBX 13 on Centos 6 from https://wiki.freepbx.org/display/FOP/Installing+FreePBX+13+on+CentOS+6 and did a yum update for all components.

Still the same error :frowning:

The script it is running has very little in it, so at a loss what is wrong.

<?php
$config = FreePBX::ModulesConf()->ProcessedConfig;
if(in_array('res_digium_phones.so',$config['modules']['noload']) && !in_array('res_pjsip_endpoint_identifier_dpma.so',$config['modules']['noload'])) {
        FreePBX::ModulesConf()->removenoload('res_digium_phones.so');
}

Graham

cat /var/www/html/admin/libraries/BMO/ModulesConf.class.php

Also where’s the bug report?

Bug Report, my bad. But, now we have better information :slight_smile:

<?php
// vim: set ai ts=4 sw=4 ft=php:
/**
 * This is the FreePBX Big Module Object.
 *
 * License for all code of this FreePBX module can be found in the license file inside the module directory
 * Copyright 2006-2014 Schmooze Com Inc.
 */
namespace FreePBX;
class ModulesConf {

        private $conf;
        public $ProcessedConfig;

        public function __construct() {

                $this->conf = \FreePBX::create()->ConfigFile("modules.conf");

                $this->ProcessedConfig =& $this->conf->config->ProcessedConfig;

                // Now, is it empty? We want some defaults..
                if (!is_array($this->ProcessedConfig) || sizeof($this->ProcessedConfig) == 0 ) {
                        $this->conf->addEntry("modules", "autoload=yes");
                        $this->conf->addEntry("modules", "preload=pbx_config.so");
                        $this->conf->addEntry("modules", "preload=chan_local.so");
                        $this->conf->addEntry("modules", "preload=res_mwi_blf.so");
                        $this->conf->addEntry("modules", "preload=func_db.so");
                        $this->conf->addEntry("modules", "preload=res_odbc.so");
                        $this->conf->addEntry("modules", "preload=res_config_odbc.so");
                        $this->conf->addEntry("modules", "preload=cdr_adaptive_odbc.so");
                        $this->conf->addEntry("modules", "noload=chan_also.so");
                        $this->conf->addEntry("modules", "noload=chan_oss.so");
                        $this->conf->addEntry("modules", "noload=app_directory_odbcstorage.so");
                        $this->conf->addEntry("modules", "noload=app_voicemail_odbcstorage.so");
                }
                // https://issues.asterisk.org/jira/browse/ASTERISK-25966
                //  and
                // https://issues.asterisk.org/jira/browse/ASTERISK-25957
                if(empty($this->ProcessedConfig['modules']['preload'])) {
                        $this->conf->addEntry("modules", "preload=func_db.so");
                        $this->conf->addEntry("modules", "preload=res_odbc.so");
                        $this->conf->addEntry("modules", "preload=res_config_odbc.so");
                        $this->conf->addEntry("modules", "preload=cdr_adaptive_odbc.so");
                } else {
                        // Make sure all of our mandatory preloads are there.
                        $mandatory = array("func_db.so", "res_odbc.so", "res_config_odbc.so", "cdr_adaptive_odbc.so");
                        foreach ($mandatory as $m) {
                                if (
                                        (is_array($this->ProcessedConfig['modules']['preload']) && !in_array($m, $this->ProcessedConfig['modules']['preload'])) ||
                                        (is_string($this->ProcessedConfig['modules']['preload']) && $this->ProcessedConfig['modules']['preload'] != $m)) {
                                                $this->conf->addEntry("modules", "preload=$m");
                                        }
                        }
                }
        }

        public function noload($module = null) {

                if ($module == null)
                        throw new \Exception("Wasn't given a module to noload");

                $current = $this->conf->config->ProcessedConfig['modules'];

                if (is_array($module)) {
                        foreach($module as $m) {
                                if (!isset($current['noload']) || !is_array($current['noload']) || !in_array($m, $current['noload']))
                                        $this->conf->addEntry("modules", "noload=$m");
                        }
                } else {
                        if (!isset($current['noload']) || !is_array($current['noload']) || !in_array($module, $current['noload']))
                                $this->conf->addEntry("modules", "noload=$module");
                }
        }

        public function removenoload($module = null) {
                if ($module == null)
                        throw new \Exception("Wasn't given a module to remove the noload tag from");

                if (is_array($module)) {
                        foreach($module as $m) {
                                $this->conf->removeEntry("modules", "noload", $m);
                        }
                } else {
                        $this->conf->removeEntry("modules", "noload", $module);
                }
        }

        public function preload($module = null) {

                if ($module == null)
                        throw new \Exception("Wasn't given a module to preload");

                $current = $this->conf->config->ProcessedConfig['modules'];

                if (is_array($module)) {
                        foreach($module as $m) {
                                if (!isset($current['preload']) || !is_array($current['preload']) || !in_array($m, $current['preload']))
                                        $this->conf->addEntry("modules", "preload=$m");
                        }
                } else {
                        if (!isset($current['preload']) || !is_array($current['preload']) || !in_array($module, $current['preload']))
                                $this->conf->addEntry("modules", "preload=$module");
                }
        }

        public function removepreload($module = null) {
                if ($module == null)
                        throw new \Exception("Wasn't given a module to remove the preload tag from");

                if (is_array($module)) {
                        foreach($module as $m) {
                                $this->conf->removeEntry("modules", "preload", $m);
                        }
                } else {
                        $this->conf->removeEntry("modules", "preload", $module);
                }
        }

        public function load($module = null) {

                if ($module == null)
                        throw new Exception("Wasn't given a module to load");

                $current = $this->conf->config->ProcessedConfig['modules'];

                if (is_array($module)) {
                        foreach($module as $m) {
                                if (!isset($current['load']) || !is_array($current['load']) || !in_array($m, $current['load'])) {
                                        $this->conf->addEntry("modules", "load=$m");
                                }
                        }
                } else {
                        if (!isset($current['load']) || !is_array($current['load']) || !in_array($module, $current['load'])) {
                                $this->conf->addEntry("modules", "load=$module");
                        }
                }
        }

        public function removeload($module = null) {
                if ($module == null)
                        throw new Exception("Wasn't given a module to remove the load tag from");

                if (is_array($module)) {
                        foreach($module as $m) {
                                $this->conf->removeEntry("modules", "load", $m);
                        }
                } else {
                        $this->conf->removeEntry("modules", "load", $module);
                }
        }
}