PHP ERROR: Type: 1
-
Can someone explain what error is this?, lately im getting this error.
21:30:27 PHP ERROR: Type: 1, File: /etc/inc/captiveportal.inc, Line: 1746, Message: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, array given in /etc/inc/captiveportal.inc:1746
Stack trace:
#0 /etc/inc/captiveportal.inc(1746): explode()
#1 /etc/inc/captiveportal.inc(1802): portal_ip_from_client_ip()
#2 /etc/inc/captiveportal.inc(1823): portal_hostname_from_client_ip()
#3 /usr/local/captiveportal/index.php(60): portal_reply_page()
#4 {main}
thrown -
It's an invalid value in the captive portal setup.
What pfSense version is that?
-
@stephenw10 this is the version.
-
Ok, what is your CP setup? Do you have a custom login page etc?
-
That line is selecting the interface(s) the CP zone is running on. Do you have some unusual or old/invalid interface set?
-
https://redmine.pfsense.org/issues/15907
Applied in changeset 64075a4359d070c300e09a94c2cf1f4854ce649b
-
@stephenw10 we have a custom html captive portal uploaded on pfsense machine,
-
@Luca-De-Andreis so we will wait for the update?, thats a weird bug, thank god the captive portal still works fine.
-
@DavcoreTech
Apply patch 64075a4359d070c300e09a94c2cf1f4854ce649b solves the problem. -
@Luca-De-Andreis said in PHP ERROR: Type: 1:
https://redmine.pfsense.org/issues/15907
Yup you can just apply the fix as a patch using the System Patches package.
-
@DavcoreTech said in PHP ERROR: Type: 1:
#3 /usr/local/captiveportal/index.php(60): portal_reply_page()
The error start here : on line 60.
reply_pages() is called, because the test "empty($cpcfg))" failed.
This test fails if a portal user types in manually a http(s) URL to access the login page.
This should never be needed, and if done, the URL has to be corecly 'formatted', that is, it should contain a parameter like "https://portal.your-domaine.tld:8003/index.php?zone=cpzone1" where cpzone1 must be valid : it must exist in the config.xml as a portal settings block.When "https://portal.your-domaine.tld:8003" is used, there is no $cpzone parameter.
Thus the test in index.php "empty($cpcfg)" fails. And then "reply_pages()" (line 60) is called which needs a valid $cpzone, as it is using it without prior testing.
Result : Booomm (PHP error).Again : normally, this error can't really happen, as who is entering a wrong portal access URL anyway ? Nobody should need to do this. But, apparently, people do it anyway (can some one tell me why ??)
I don't fully understand the patch :
as in this context, $cpzone is undefined ....
The real ? better ? solution would be :
Btw : see also here - as discovered a while ago.
-
@Gertjan same i dont know how to add the patch, is there a tutprial?
-
Install it :
Then: here it is : System > Patches
Go for teh
button.
As you have the patch ID : here :
use that, and enter a useful patch description, so you'll know later on where you got it from :
and then the big bleu Save button at the bottom.
Now you see this :
Do what is proposd : fetch the patch ! ( Click on the bleu Fetch ).
Now you should be able to see a bleu Apply button.
I don't have that button, as I solved this issue using another method.There is also the manual method, and for this you need a text editor.
As the actual change is : change [] for "" on line 1746 in the fiel /etc/inc/captiveportal.incI'm not sure if this actually resolves the issue - see above for my motivation.
And again, : normally, this PHP error isn't actually a bug, but also a feature, as it shows something is wrong with the (your) portal usage.
Nobody should enter the captive portal login manually. It's like email addresses and phone number : don't enter them manually as chances are great you do it wrong.
I'm using the portal for more then a decade now, never had to enter the URL 'by hand'. -
@Gertjan thank you, already apply the patch hopefully if will be solve,