Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong mailer() function is used when CACTI_VERSION below 1.2.0 #77

Closed
gmourani opened this issue Nov 22, 2018 · 10 comments
Closed

Wrong mailer() function is used when CACTI_VERSION below 1.2.0 #77

gmourani opened this issue Nov 22, 2018 · 10 comments

Comments

@gmourani
Copy link

Plugin reportit : 1.1.2
Cacti : 1.1.38

I've successfully created a new report and this morning when trying to see the result, I can see in the Cacti log the following. Look like Cacti has automatically disable the plugin !

2018/11/22 00:00:02 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'reportit'

2018/11/22 00:00:02 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler)(/lib/functions.php: 4628 cacti_debug_backtrace)
2018/11/22 00:00:02 - ERROR PHP ERROR in Plugin 'reportit': Call to undefined function cacti_sizeof() in file: /var/www/html/cacti/plugins/reportit/lib/funct_mailer.php on line: 212

Regards,

@netniV
Copy link
Member

netniV commented Nov 22, 2018

Download the last fest develop version

@gmourani
Copy link
Author

Thanks, this fixed the problem. It's normal that running the command "php /var/www/html/cacti/plugins/reportit/runtime.php -d" as apache user, doesn't update the 'Last run (EST)' time in the view.php page and doing the same via the WUI (reports.php), update it ?

@netniV
Copy link
Member

netniV commented Nov 23, 2018

It should run the same no matter which method is used. If you run that via sudo, you should see what output appears. Also, check the cacti.log and apache error log to see if any errors appear.

@gmourani
Copy link
Author

Yes, "Last run (EST)" is updated. I can see the following in CLI, I suppose it's normal.

php /var/www/html/cacti/plugins/reportit/runtime.php -d
PHP Notice: Array to string conversion in /var/www/html/cacti/lib/functions.php on line 3648
PHP Notice: Array to string conversion in /var/www/html/cacti/lib/functions.php on line 3648
PHP Warning: trim() expects parameter 1 to be string, array given in /var/www/html/cacti/include/phpmailer/class.phpmailer.php on line 874
PHP Warning: trim() expects parameter 1 to be string, array given in /var/www/html/cacti/include/phpmailer/class.phpmailer.php on line 874

@netniV
Copy link
Member

netniV commented Nov 27, 2018

Can you run that again with --debug after downloading the latest development version?

Just curious to see what occurs.

@gmourani
Copy link
Author

Here the returning output when executed as apache user in CLI.
php /var/www/html/cacti/plugins/reportit/runtime.php -d --debug > result.txt
PHP Notice: Undefined offset: 1 in /var/www/html/cacti/lib/functions.php on line 3648
PHP Notice: Array to string conversion in /var/www/html/cacti/lib/functions.php on line 3648
PHP Warning: trim() expects parameter 1 to be string, array given in /var/www/html/cacti/include/phpmailer/class.phpmailer.php on line 874
PHP Notice: Array to string conversion in /var/www/html/cacti/lib/functions.php on line 3648
PHP Notice: Array to string conversion in /var/www/html/cacti/lib/functions.php on line 3648
PHP Warning: trim() expects parameter 1 to be string, array given in /var/www/html/cacti/include/phpmailer/class.phpmailer.php on line 874
PHP Warning: trim() expects parameter 1 to be string, array given in /var/www/html/cacti/include/phpmailer/class.phpmailer.php on line 874

Also, I've attached the result in txt file to this message (~8MB).
result.txt

@netniV
Copy link
Member

netniV commented Nov 28, 2018

OK so the problem seems to be that the version detection code is making you use the built in mailer. However, ReportIT needs the 1.2 mailer (which has had a bit of an overhaul to function better). As such, it's passing in arrays which the 1.1.x mailer will not understand. To that end, we added v1_2_0_mailer() as a pure ripped copy to reportit's own libraries so that could be used in place of the 1.1.38 version which doesn't handle things the way that's expect.

@netniV
Copy link
Member

netniV commented Nov 28, 2018

OK, here is where I must have been confused, I tested the cacti version detection code, and it seems to be inverted to what I've coded. I tested four versions against the '1.2.0' string which said that the following signs were true (1):

   1.1.1:  [ <] 1 [<=] 1 [ =]   [=>]   [ >]
  1.1.38:  [ <] 1 [<=] 1 [ =]   [=>]   [ >]
   1.2.0:  [ <]   [<=] 1 [ =] 1 [=>]   [ >]
   1.3.1:  [ <]   [<=]   [ =]   [=>]   [ >] 1

If you are running 1.1.38, it should have picked the v1_2_0_mailer, but was instead picking the builtin mailer.

if (cacti_version_compare(CACTI_VERSION, '1.2.0', '<')) {
        $mailer_func = "mailer";
} else {
        include_once(__DIR__ . '/funct_mailer.php');
        $mailer_func = "v1_2_0_mailer";
}

@netniV netniV changed the title Plugin reportit disabled by Cacti Wrong mailer() function is used when CACTI_VERSION below 1.2.0 Nov 28, 2018
netniV added a commit that referenced this issue Nov 28, 2018
@netniV
Copy link
Member

netniV commented Nov 28, 2018

This is now in the main development code, please check and close if issue is resolved. This was not an issue if you were running 1.2.0 beta as that mailer() function was already compatible.

@gmourani
Copy link
Author

Tested with latest dev code and the issue is resolved, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants