[Fixed] LsAPI integration breaks __DIR__ in CLI

#1
Hi!
I came across very weird bug. I have PHP 7 compiled using lsws webpanel. Everything seems to work correctly while PHP files are invoked via HTTP, but using lsws php binary from shell produces strange results.

First of all I tested if __DIR__ implementation is consistent between all PHP versions: https://3v4l.org/1lRa2 - yup, it is.
Next I created file inside app catalog named test.php. Than I invoked it from outside of the app directory:

Code:
root@server:/home/[redacted]# php app/test.php
string(19) "/home/[redacted]/app"
root@server:/home/[redacted]# php7 app/test.php
string(23) "/home/[redacted]/app/app"

# php --version
PHP 5.6.11 (cli) (built: Jul 13 2015 01:48:23) (DEBUG)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

# php7 -v
PHP 7.0.0 (litespeed) (built: Dec  4 2015 10:46:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
You can't event imagine how many tools got broken ;)
PHP also thinks files are located elsewhere:
Code:
require_once(/home/[redacted]/app/app/bootstrap.php.cache): failed to open stream: No such file or directory in /home/[redacted]/app/app/console on line 10
 
#3
@mistwang: I think you misunderstood the issue - I use PHP binary compiled for lsws.
Code:
# which php7
/usr/bin/php7
# ls -l /usr/bin/php7
lrwxrwxrwx 1 root root 30 Sep  4 12:11 /usr/bin/php7 -> /usr/local/lsws/lsphp7/bin/php
On another server I checked, situation looks different. I believe the only difference is PHP7.0.0RC8 instead of final and compilation date.
Code:
# php7 test/test.php
string(10) "/home/test"
# php7 --version
PHP 7.0.0RC8 (cli) (built: Dec  2 2015 14:03:35) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
# php7 --info | grep litespeed
Configure Command =>  './configure'  '--prefix=/usr/local/lsws/lsphp7' '--with-libdir=/lib/x86_64-linux-gnu' '--with-curl' '--with-gd' '--enable-exif' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/lib/x86_64-linux-gnu' '--with-ttf' '--with-gettext' '--with-jpeg-dir=/usr/include' '--with-libpng' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysqli' '--with-pdo-mysql' '--with-pear' '--with-zlib' '--enable-zip' '--with-bz2' '--with-iconv' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--with-gmp' '--enable-sockets' '--enable-intl' '--enable-mbstring' '--with-mcrypt=/usr' '--enable-opcache' '--with-litespeed'
I also spotted another difference - binary on the first server identifies as "PHP 7.0.0 (litespeed)", but on the second one it's "PHP 7.0.0RC8 (cli)".


Edit:
I asked a friend using lsws and his PHP presented the same issue. In his case RC7 works correctly while final breaks.

Code:
luklew@server:/var/www/html/symfony/clean$ php -v
PHP 7.0.0RC7 (cli) (built: Nov 17 2015 15:10:42) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

luklew@server:/var/www/html/symfony/clean$ php -i | grep config
Configure Command =>  './configure'  '--prefix=/usr/local/lsws/lsphp7' '--with-mysqli' '--with-pdo-mysql' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--with-iconv' '--with-mcrypt' '--with-openssl' '--with-sqlite3' '--with-litespeed' '--with-bz2' '--enable-zip' '--enable-mbstring'
Openssl default config => /usr/lib/ssl/openssl.cnf
TEXTDOMAIN => im-config
$_SERVER['TEXTDOMAIN'] => im-config

luklew@server:/var/www/html/symfony/clean$ php app/test.php
string(31) "/var/www/html/symfony/clean/app"
-----

luklew@server:/var/www/html/symfony/clean$ php7 -v
PHP 7.0.0 (litespeed) (built: Dec  4 2015 09:58:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

luklew@server:/var/www/html/symfony/clean$ php7 -i | grep config
Configure Command =>  './configure'  '--prefix=/usr/local/lsws/lsphp7' '--with-mysqli' '--with-pdo-mysql' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--with-iconv' '--with-mcrypt' '--with-openssl' '--with-sqlite3' '--with-litespeed' '--with-bz2' '--enable-zip' '--enable-mbstring'
Openssl default config => /usr/lib/ssl/openssl.cnf
TEXTDOMAIN => im-config
$_SERVER['TEXTDOMAIN'] => im-config

luklew@server:/var/www/html/symfony/clean$ php7 app/test.php
string(35) "/var/www/html/symfony/clean/app/app"
Edit2:
After further test I discovered problem is related not to final release of 7.0.0 but to some changes inside lsapi patch. I now recompiled PHP7.0.0RC8 with newest lsapi and it's also buggy:

Code:
root@server:/home/test# php7 app/test.php
string(23) "/home/test/app/app"
root@server:/home/test# php7 -v
PHP 7.0.0RC8 (litespeed) (built: Dec  8 2015 12:23:53)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
 
Last edited:
#5
As I remember correctly during compilation 6.9 is already used - am I wrong?
So if I recompile PHP now will I get this bug fixed? Of course I have to remove cached files ;)



p.s. I'm the OP for that topic - I finally managed to create my own account instead of asking a friend to post :p
 
Top