Bug #9313
closedPHP Fatal error: Uncaught Error: Call to a member function addGlobal() on null in /usr/local/www/firewall_shaper_vinterface.php:415
100%
Description
Crash report begins. Anonymous machine information:
arm
11.2-RELEASE-p6
FreeBSD 11.2-RELEASE-p6 #4 ed5153fb2b9(factory-RELENG_2_4_4): Wed Dec 12 15:08:15 EST 2018 root@buildbot2.nyi.netgate.com:/build/factory-crossbuild-244/obj/armv6/tDULKC6G/arm.armv6/build/factory-crossbuild-244/pfSense/tmp/FreeBSD-src/sys/pfSense-uFW
Crash report details:
PHP Errors:
[08-Feb-2019 20:18:53 Europe/Paris] PHP Fatal error: Uncaught Error: Call to a member function addGlobal() on null in /usr/local/www/firewall_shaper_vinterface.php:415
Stack trace:
#0 {main}
thrown in /usr/local/www/firewall_shaper_vinterface.php on line 415
No FreeBSD crash data found.
Updated by Jim Pingle almost 6 years ago
There must be something unique to your configuration triggering this. It does not appear to be a general issue affecting all users.
Please attach the <dnshaper></dnshaper>
portion of the config.xml file from the affected firewall.
Updated by Jim Pingle almost 6 years ago
- Status changed from New to Feedback
- Priority changed from Normal to Low
Updated by Anonymous almost 6 years ago
I looked at the code - I guess that $sform is null.
By default $dontshow is false. So by default it will expect $sform to not be null.
In case "add", $sform is not set in all cases and $dontshow is not set to true when $sform is not set. Same in "show", "enable" and "disable". $input_errors is set though.
When "$action" is "add", the code is supposedly not entered but << $action != "add" >> is strictly speaking not the correct comparison, it should be
<< $action !== "add" >> (0!="add" is false!). This is however not the cause.
This error may have occurred while deleting queues.
The system log shows this:
./system.log:Feb 8 20:18:53 pf3 php-fpm27165: /firewall_shaper_vinterface.php: PHP ERROR: Type: 1, File: /usr/local/www/firewall_shaper_vinterface.php, Line: 415, Message: Uncaught Error: Call to a member function addGlobal() on null in /usr/local/www/firewall_shaper_vinterface.php:415 Stack trace: #0 {main} thrown
./system.log:Feb 8 20:18:53 pf3 php-fpm27165: /firewall_shaper_vinterface.php: New alert found: PHP ERROR: Type: 1, File: /usr/local/www/firewall_shaper_vinterface.php, Line: 415, Message: Uncaught Error: Call to a member function addGlobal() on null in /usr/local/www/firewall_shaper_vinterface.php:415 Stack trace: #0 {main} thrown
At that timestamp, the nginx.log does show a "show" action from a "delete" action:
nginx.log:Feb 8 20:18:44 pf3 pf3.domain.name nginx: 192.168.5.20 - - [08/Feb/2019:20:18:44 +0100] "GET /firewall_shaper_vinterface.php HTTP/2.0" 499 0 "https://192.168.5.251/firewall_shaper_vinterface.php?pipe=outMailOthers&queue=outMailOthers&action=delete" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36"
nginx.log:Feb 8 20:18:53 pf3 pf3.domain.name nginx: 192.168.5.20 - - [08/Feb/2019:20:18:53 +0100] "GET /firewall_shaper_vinterface.php?pipe=outMailOthers&queue=outMailOthers&action=show HTTP/2.0" 200 6011 "https://192.168.5.251/firewall_shaper_vinterface.php?pipe=outMailOthers&queue=outMailOthers&action=delete" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
It looks like the "outMailOthers" was deleted and then requested to be shown. So in << case "show", the $sform would not have been set.
n
$dfltmsg is false, $dontshow is false, $action is "show", so th enext code is executed with an $sform that is unset.
$sform->addGlobal(new Form_Button(
'delete',
($queue && ($qname != $pipe)) ? 'Delete this queue':'Delete Limiter',
$url,
'fa-trash'
))->addClass('btn-danger');
It is not clear how I got from the delete action to the show action. Possibly a deleted queue was still shown - I may have opened multiple pages to delete queues and I may have clicked on a link to the deleted queue.
IMHO, nothing to do with my configuration, and some code here that must be corrected and be made more robust:
- Compare strings with "===";
- Improve coping with $sform not being set and $input_errors.
As requested, here is the current dnshaper section:
<dnshaper>
<queue>
<name>in</name>
<number>1</number>
<qlimit></qlimit>
<plr></plr>
<description><![CDATA[In]]></description>
<bandwidth>
<item>
<bw>2500</bw>
<burst></burst>
<bwscale>Kb</bwscale>
<bwsched>none</bwsched>
</item>
</bandwidth>
<enabled></enabled>
<buckets></buckets>
<mask>none</mask>
<maskbits></maskbits>
<maskbitsv6></maskbitsv6>
<delay>0</delay>
</queue>
<queue>
<name>out</name>
<number>2</number>
<qlimit></qlimit>
<plr></plr>
<description><![CDATA[out]]></description>
<bandwidth>
<item>
<bw>500</bw>
<burst></burst>
<bwscale>Kb</bwscale>
<bwsched>none</bwsched>
</item>
</bandwidth>
<enabled></enabled>
<buckets></buckets>
<mask>none</mask>
<maskbits></maskbits>
<maskbitsv6></maskbitsv6>
<delay>0</delay>
</queue>
</dnshaper>
Updated by Anonymous almost 6 years ago
Extra note:
The next line shows that I did get from the queue "delete" action to the "show" action of the same queue.
nginx.log:Feb 8 20:18:53 pf3 pf3.domain.name nginx: 192.168.5.20 - - [08/Feb/2019:20:18:53 +0100] "GET /firewall_shaper_vinterface.php?pipe=outMailOthers&queue=outMailOthers&action=show HTTP/2.0" 200 6011 "https://192.168.5.251/firewall_shaper_vinterface.php?pipe=outMailOthers&queue=outMailOthers&action=delete"
It looks like the list of queues to show is computed before the queue is deleted during the delete action?
Updated by Jim Pingle almost 6 years ago
- Status changed from Feedback to In Progress
- Assignee set to Jim Pingle
- Target version set to 48
- Affected Architecture All added
- Affected Architecture deleted (
SG-1000)
OK, I was able to reproduce it following your procedure, hitting a URL for a queue that had already been deleted.
There is a "queue not found" error at the top of the page, but also the php error in the middle. I have a fix ready to commit.
Updated by Jim Pingle almost 6 years ago
- Status changed from In Progress to Feedback
- % Done changed from 0 to 100
Applied in changeset 069585172e6408195b16bbe3090aeba56699ee51.
Updated by Jim Pingle almost 6 years ago
- Target version changed from 48 to 2.5.0
Updated by Jim Pingle over 5 years ago
- Target version changed from 2.5.0 to 2.4.4-p3
Updated by Jim Pingle over 5 years ago
- Status changed from Feedback to Resolved
Tested on a different system. Saw the PHP the error on 2.4.4-p2, upgraded to -p3 and only the nice "Queue not found" error shows.