Bug #11898
closedPHP error from apcupsd dashboard widget when battery is charging
100%
Description
Not clear exactly what led to this, but one of my systems running apcupsd had the following PHP error in its log:
[04-May-2021 09:57:13 America/Indiana/Indianapolis] PHP Warning: strrpos(): needle is not a string or an integer in /usr/local/www/widgets/widgets/apcupsd.widget.php on line 130
The same error was repeated about 90 times over a span of 20 minutes, about 15 seconds apart which is around when the widget would be updating. There must have been some data that was returned at the time which it had trouble parsing.
pfSense-pkg-apcupsd-0.3.91_9
The line in question is:
if (($bchrg != null) && (in_array("ONLINE", $statusarray)) && ($bchrg < 100) && (strrpos($statstr, $mainstatarray) === false)) {
Related issues
Updated by Anthony Messina over 1 year ago
After upgrading to 23.01-RELEASE I also see similar behavior:
21:07:12 PHP ERROR: Type: 1, File: /usr/local/www/widgets/widgets/apcupsd.widget.php, Line: 130, Message: Uncaught TypeError: strrpos(): Argument #2 ($needle) must be of type string, array given in /usr/local/www/widgets/widgets/apcupsd.widget.php:130
Stack trace:
#0 /usr/local/www/widgets/widgets/apcupsd.widget.php(130): strrpos('ONLINE ', Array)
#1 /usr/local/www/widgets/widgets/apcupsd.widget.php(339): compose_apc_contents('apcupsd-0')
#2 {main}
thrown
See also: https://redmine.pfsense.org/issues/13970
Updated by Jim Pingle over 1 year ago
- Related to Regression #13970: PHP error in apcupsd widget from UTF-8 string handling added
Updated by Jim Pingle over 1 year ago
- Subject changed from PHP error from apcupsd dashboard widget to PHP error from apcupsd dashboard widget when battery is charging
- Assignee set to Jim Pingle
- Start date deleted (
05/07/2021)
I was able to reproduce this by forcing the battery charge < 100. Not sure what the original logic is trying to do there but it's obviously wrong.
Updated by Jim Pingle over 1 year ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Fix merged, will be in builds soon (might be a couple days)
Updated by Jordan G over 1 year ago
updating APCUPSd package to 0.3.92_1 does not produce this issue any longer when battery charge <100%