PHP Fatal error: Class 'cronmanager' not found

After doing an upgrade this morning I now have this error;

[root@nbopbx ~]# fwconsole ma upgradeall
PHP Fatal error: Class ‘cronmanager’ not found in /var/www/html/admin/libraries/Console/Extnotify.class.php on line 15
Whoops\Exception\ErrorException: Class ‘cronmanager’ not found in file /var/www/html/admin/libraries/Console/Extnotify.class.php on line 15
Stack trace:

  1. Whoops\Exception\ErrorException->() /var/www/html/admin/libraries/Console/Extnotify.class.php:15

Looking at [root@nbopbx ~]# /var/lib/asterisk/bin/module_admin listonline
one line is;
core 14.0.18.37 Disabled; Pending upgrade to 14.0.18.45

is this why cronmanager is not found? Any fwconsole command returns the same whoops error.

I have been researching for a couple of hours now so I would really appreciate any help/suggestions.

Thank you in advance

Edwin

This is not a class from FreePBX. Never has been. Please paste the output of this file

cat /var/www/html/admin/libraries/Console/Extnotify.class.php

I just carried out this mornings upgrades and it crashed our system. I am getting;
PHP Fatal error: Class ‘cronmanager’ not found in /var/www/html/admin/libraries/Console/Extnotify.class.php on line 15. Not sure yet if this is the same issue as yours @hardocp?

This is not a class that FreePBX owns. Is it something you created?

not at all Andrew.??

Please paste the output of this file

cat /var/www/html/admin/libraries/Console/Extnotify.class.php

[root@nbopbx ~]# cat /var/www/html/admin/libraries/Console/Extnotify.class.php

<?php
namespace FreePBX\Console\Command;
//Symfony stuff all needed add these
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Extnotify extends Command {
        protected function configure(){
    $this->FreePBX = \FreePBX::Create();
                $this->FreePBXConf = $this->FreePBX->Config();
    $this->nt = \notifications::create($this->FreePBX->Database);
    $this->cm = \cronmanager::create($this->FreePBX->Database);
    $this->mid = $this->cm->get_machineid();
    $this->email = $this->cm->get_email();
    $this->brand = $this->FreePBXConf->get('DASHBOARD_FREEPBX_BRAND')?$this->FreePBXConf->get('DASHBOARD_FREEPBX_BRAND'):'FreePBX';
                $this->setName('extnotify')
                ->setDescription(_('Sends Scheduled Notifications'))
                ->setDefinition(array(
                        new InputArgument('args', InputArgument::IS_ARRAY, null, null),));
        }
        protected function execute(InputInterface $input, OutputInterface $output){
                $args = $input->getArgument('args');
                $this->cm->run_jobs();
    $this->updateSecurity();
    if($this->email){
      $this->unsignedEmail();
      $this->securityEmail();
      $this->updateEmail();
      $this->hookEmails();
    }else{
      $this->nt->add_notice('freepbx', 'NOEMAIL', _('No email address for online update checks'), _('You are automatically checking for online updates nightly but you have no email address setup to send the results. This can be set in Module Admin. They will continue to show up here.'), 'config.php?display=modules#email', 'PASSIVE', false);
    }
        }
  protected function send_email($to,$subject,$message,$priority = 3){
    $em = clone \FreePBX::Email();
    $em->setTo(array($to));
    $em->setSubject($subject);
    $em->setBody($message);
    $em->setPriority($priority);
    return $em->send();
  }
  protected function updateSecurity(){
    if($this->FreePBXConf->get('AUTOSECURITYUPDATES')) {
        $mf = \module_functions::create();
        $mods = $mf->get_security();
        $mods = is_array($mods) ? $mods : array();
        if(!empty($mods)) {
                set_time_limit(0); //we NEED these updates
                $ampsbin = $this->FreePBXConf->get('AMPSBIN');
                $errorvuls = array();
                foreach($mods as $rawname => $info) {
                        $mi = $mf->getinfo($rawname);
                        if(!isset($mi[$rawname])) {
                                //module doesnt exist on this system
                                continue;
                        }
                        switch($mi[$rawname]['status']) {
                                case MODULE_STATUS_NOTINSTALLED:
                                case MODULE_STATUS_DISABLED:
                                case MODULE_STATUS_BROKEN:
                                        $action = "download";
                                break;
                                case MODULE_STATUS_ENABLED:
                                case MODULE_STATUS_NEEDUPGRADE:
                                        $action = "upgrade";
                                break;
                                default:
                                        $action = "";
                                break;
                        }
                        if(empty($action)) {
                                //not sure what to do???
                                $errorvuls[$rawname] = $info;
                                continue;
                        }
                        exec($ampsbin."/fwconsole ma ".escapeshellarg($action)." ".escapeshellarg($rawname)." --format=json",$out,$ret);
                        if($ret != 0) {
                                $errorvuls[$rawname] = $info;
                        }
                }
                $this->nt->delete("freepbx", "VULNERABILITIES");
                if(!empty($errorvuls)) {
                        //unable to automatically update these modules
                        if (!empty($errorvuls)) {
                                $cnt = count($errorvuls);
                                if ($cnt == 1) {
                                        $text = _("There is 1 module vulnerable to security threats");
                                } else {
                                        $text = sprintf(_("There are %s modules vulnerable to security threats"), $cnt);
                                }
                                $extext = "";
                                foreach($errorvuls as $m => $vinfo) {
                                        $extext .= sprintf(
                                                _("%s (Cur v. %s) should be upgraded to v. %s to fix security issues: %s")."\n",
                                                $m, $vinfo['curver'], $vinfo['minver'], implode($vinfo['vul'],', ')
                                        );
                                }
                                $this->nt->add_security('freepbx', 'VULNERABILITIES', $text, $extext, 'config.php?display=modules');
                        }
                } else {
                        $text = _("Modules vulnerable to security threats have been updated");
                        foreach($mods as $m => $vinfo) {
                                $extext .= sprintf(
                                        _("%s has been automatically upgraded to fix security issues: %s")."\n",
                                        $m, implode($vinfo['vul'],', ')
                                );
                        }
                        $extext = $extext.". "._("You can disable this in advanced settings under 'Allow Automatic Security Updates'");
                        $this->nt->add_notice('freepbx', 'AUTOVULNUPDATE', $text, $extext, 'config.php?display=modules',true,true);
                }
        }
    }
  }
  protected function unsignedEmail(){
    if(!$this->FreePBXConf->get('SEND_UNSIGNED_EMAILS_NOTIFICATIONS')){
      return true;
    }
    $send_email = false;

    $unsigned = $this->nt->list_signature_unsigned();
    $text = '';
    if (count($unsigned)) {
      $send_email = true;
      $text = $htext;
      $text .= "\n" . _("UNSIGNED MODULES NOTICE:")."\n\n";
      foreach ($unsigned as $item) {
        $text .= $item['display_text'].":\n";
        $text .= $item['extended_text']."\n";
      }
    }
    $text .= "\n\n";

    if ($send_email && (! $this->cm->check_hash('update_sigemail', $text))) {
      $this->cm->save_hash('update_sigemail', $text);
      if ($this->send_email($this->email, sprintf(_("%s: New Unsigned Modules Notifications (%s)"),$this->brand, $this->mid), $text)) {
        $this->nt->delete('freepbx', 'SIGEMAILFAIL');
      } else {
        $this->nt->add_error('freepbx', 'SIGEMAILFAIL', _('Failed to send unsigned modules notification email'), sprintf(_('An attempt to send email to: %s with unsigned modules notifications failed'),$this->email));
      }
    }
  }
  protected function securityEmail(){
    $text = "";
        $send_email = false;

        $security = $this->nt->list_security();
        if (count($security)) {
                $send_email = true;
                $text = $htext . "\n";
                $text .= _("SECURITY NOTICE:")."\n\n";
                foreach ($security as $item) {
                        $text .= $item['display_text'].":\n";
                        $text .= $item['extended_text']."\n";
                }
        }
        $text .= "\n\n";

        if ($send_email && (! $this->cm->check_hash('update_semail', $text))) {
                $this->cm->save_hash('update_semail', $text);
                if ($this->send_email($this->email, sprintf(_("%s: New Security Notifications (%s)"),$this->brand, $this->mid), $text)) {
                        $this->nt->delete('freepbx', 'SEMAILFAIL');
                } else {
                        $$this->nt->add_error('freepbx', 'SEMAILFAIL', _('Failed to send security notification email'), sprintf(_('An attempt to send email to: %s with security notifications failed'),$this->email));
                }
        }
  }
  protected function updateEmail(){
    $text = "";
        $send_email = false;

        $updates = $this->nt->list_update();
        if (count($updates)) {
                $send_email = true;
                $text = $htext . "\n";
                $text .= _("UPDATE NOTICE:")."\n\n";
                foreach ($updates as $item) {
                        $text .= $item['display_text']."\n";
                        $text .= $item['extended_text']."\n\n";
                }
        }

        if ($send_email && (! $this->cm->check_hash('update_email', $text))) {
                $this->cm->save_hash('update_email', $text);
                if ($this->send_email($this->email, sprintf(_("%s: New Online Updates Available (%s)"),$brand,$mid), $text)) {
                        $this->nt->delete('freepbx', 'EMAILFAIL');
                } else {
                        $this->nt->add_error('freepbx', 'EMAILFAIL', _('Failed to send online update email'), sprintf(_('An attempt to send email to: %s with online update status failed'),$this->email));
                }
        }
  }
  protected function hookEmails(){
    $hooks = \FreePBX::Hooks()->processHooks();
    foreach ($hooks as $key => $value) {
      if(!isset($value['message'])){
        continue;
      }
      $to = isset($value['to'])?$value['to']:$this->email;
      $subject = isset($value['subject'])?$value['subject']:sprintf(_("Automated notification from %s"),$key);
      $message = $value['$message'];
      $priority = isset($value['priority'])?$value['priority']:3;
      if ((!$this->cm->check_hash($key.'_email', $message))) {
        $this->cm->save_hash($key.'_email', $message);
        if($this->send_email($to, $subject, $message, $priority)){
          $this->nt->delete('freepbx', 'EMAILFAIL');
        }else{
          $this->nt->add_error('freepbx', 'EMAILFAIL', _('Failed to send online hook email'), sprintf(_('An attempt to send email to: %s from %s failed'),$this->email, $key));
        }
      }
    }
  }
}
[root@nbopbx ~]#
1 Like

can you paste the output from: fwconsole ma downloadinstall framework

[root@nbopbx ~]# fwconsole ma downloadinstall framework
PHP Fatal error: Class ‘cronmanager’ not found in /var/www/html/admin/libraries/Console/Extnotify.class.php on line 15
Whoops\Exception\ErrorException: Class ‘cronmanager’ not found in file /var/www/html/admin/libraries/Console/Extnotify.class.php on line 15
Stack trace:

  1. Whoops\Exception\ErrorException->() /var/www/html/admin/libraries/Console/Extnotify.class.php:15
    [root@nbopbx ~]#

I am unable to carry out any fwconsole command Andrew.

It looks like you installed FreePBX 14 around 2016.

Between Wed Sep 14 13:56:39 2016 and Thu Dec 1 00:56:16 2016

Before FreePBX 14.0.1beta3 was released

Does that sound correct?

I went live at my business in March 2017. I do recall using the v 14 Distro on the Sangoma site in January 17 but definitely did not install between those dates, It has worked almost flawlessly until this morning.

We have been down all day, I was hoping to restore last nights backups to get back in service, without fwconsole I should use a command line to restore (which I am looking for),

just rm -Rf /var/www/html/admin/libraries/Console/Extnotify.class.php

Thank you very much Andrew, I have now done the upgrades, back in service.

What is the significance of the file Extnotify.class.php? I noticed it was last accessed on December 15.

It was created during the beta cycle of FreePBX 14 on Wed Sep 14 13:56:39 2016

on Thu Dec 1 00:56:16 2016 it was renamed to Sendmail.class.php

Framework upgrades don’t remove old files so this old file was being loaded into your system.

It’s hitting you now because it referenced a class called Cronmanager that was used previously back in 2016 but was just now removed.

3 Likes

Thank you Andrew, great service and much appreciated.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.