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

TypError unpack() expects parameter 2 to be string, bool given in Http/Helpers #152

Closed
josefsabl opened this issue Mar 9, 2019 · 6 comments
Closed

Comments

@josefsabl
Copy link

@josefsabl josefsabl commented Mar 9, 2019

Version: dev-master#db73233

Bug Description

When I run the app on the PHP built-in server I get the unpack() expects parameter 2 to be string, bool given. The reason is that:

  • $_SERVER['REMOTE_ADDR'] === string(5) "[::1]"
  • which gets passed to inet_pton
  • which returns false
  • which is passed to unpack
  • which results in TypeError

See attached tracy.
TypeError_ unpack() expects parameter 2 to be string, bool given.zip

Is this a Nette bug? Is it PHP Server bug? Am I doing something wrong? I don't think I changed anything in the php server settings.

Steps To Reproduce

none

Expected Behavior

no crash, obviously

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Mar 9, 2019

PHP is probably not compiled with IPv6 support http://php.net/manual/en/function.inet-pton.php

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Mar 9, 2019

No, it is caused by square brackets.

I tried run php -S [::1]:8000 and $_SERVER['REMOTE_ADDR'] contains ::1. Which version do you use?

@josefsabl

This comment has been minimized.

Copy link
Author

@josefsabl josefsabl commented Mar 9, 2019

Hey, thanks for reacting so swiftly!

I am using version 7.3.1 for windows.

I am running it through PhpStorm run configuration, that generates command like this:

F:\php\7.3.1\php.exe -S localhost:88 -t F:\Projects\my_project\www --php-ini php.ini F:\Projects\my_project\local\serverRouter.php

When I run it manually similar to your example

F:\php\7.3.1\php.exe -S [::1]:88 -t F:\Projects\my_project\www --php-ini php.ini F:\Projects\my_project\local\serverRouter.php

Problem persists and $_SERVER['REMOTE_ADDR'] contains [::1].

Running it like this doesn't obviously work (generates invalid ip address error)

F:\php\7.3.1\php.exe -S ::1:88 -t F:\Projects\my_project\www --php-ini php.ini F:\Projects\my_project\local\serverRouter.php

Doing:

F:\php\7.3.1\php.exe -S 127.0.0.1:88 -t F:\Projects\my_project\www --php-ini php.ini F:\Projects\my_project\local\serverRouter.php

... however does fix this.

It is obviously some problem with the php itself? I guess that [::1] is invalid ip spec and nothing is wrong with Nette.

Thank you for the direction! I can at last remove the

        if ($_SERVER['REMOTE_ADDR'] === '[::1]') {
            $_SERVER['REMOTE_ADDR'] = '::1';
        };

workaround :-)

PS: The strange thing is that this is the "Worked yesterday" kind of bug :-/

@josefsabl josefsabl changed the title unpack() expects parameter 2 to be string, bool given in Http/Helpers TypError unpack() expects parameter 2 to be string, bool given in Http/Helpers Mar 9, 2019
@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Mar 9, 2019

It seems like bug in PHP 7.3, previous PHP are correct. Can you report it?

@dg dg closed this in fa9b839 Mar 9, 2019
@josefsabl

This comment has been minimized.

Copy link
Author

@josefsabl josefsabl commented Mar 10, 2019

I've already reported it in the PHP for Windows chat channel. Not sure if anyone read it. I will try to report to PHP devs as well.

@josefsabl

This comment has been minimized.

Copy link
Author

@josefsabl josefsabl commented Mar 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.