php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71055 Intepreter compiled with litespeed SAPI breaks __DIR__ in CLI
Submitted: 2015-12-08 10:25 UTC Modified: 2018-03-12 09:23 UTC
From: grzegorz129 at gmail dot com Assigned: gwang (profile)
Status: Closed Package: Other web server
PHP Version: 7.0.0 OS: Linux x64
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-08 10:25 UTC] grzegorz129 at gmail dot com
Description:
------------
I have PHP 7 compiled with litespeed SAPI support. Binary works as expected while used with webserver, but acts weird while invoked from console. That bug was introduced in 7.0.0 release and wasn't present in RC8.

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:

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


PHP also thinks files are located elsewhere:
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


RC8 looks correct though:
# 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

I also spot one difference which may be relevant - running binary from console final version identifies SAPI as "litespeed" while RC8 reports "cli".


Configuration
------------- 
Configuration is identical on both servers.

Compilation options:
'./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-pdo-pgsql' '--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'

PHP.ini:
memory_limit = 256M
date.timezone = "Europe/Warsaw"
post_max_size = 16M
upload_max_filesize = 10M
max_execution_time = 120
enable_dl = Off
expose_php = Off

intl.default_locale = "pl_PL.UTF-8"
mysql.connect_timeout = 5
mysql.default_host = localhost
session.cookie_httponly = On
session.use_only_cookies = On

opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=4000

Test script:
---------------
<?php
 //Save in it eg. test/test.php and call using php7 test/test.php
 //DO NOT enter test directory
 var_dump(__DIR__);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-08 10:26 UTC] grzegorz129 at gmail dot com
Related topic on Litespeed Tech. support forum: https://www.litespeedtech.com/support/forum/threads/lsapi-integration-breaks-__dir__-in-cli.13493/
 [2015-12-08 10:34 UTC] grzegorz129 at gmail dot com
I asked a fried using lsws and his PHP presented the same issue. In his case RC7 works correctly while final breaks.
So, I think there's a problem with litespeed path and not in my system configuration.


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$ php7 app/test.php 
string(35) "/var/www/html/symfony/clean/app/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$ php app/test.php 
string(31) "/var/www/html/symfony/clean/app"
 [2015-12-08 11:31 UTC] grzegorz129 at gmail dot com
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:

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
 [2018-03-11 17:25 UTC] cmb@php.net
-Status: Open +Status: Assigned -Package: Scripting Engine problem +Package: Other web server -Assigned To: +Assigned To: gwang
 [2018-03-12 09:23 UTC] gwang@php.net
-Status: Assigned +Status: Closed
 [2018-03-12 09:23 UTC] gwang@php.net
This problem should have been addressed a while ago. I no longer be able to reproduce it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC