ext-ds icon indicating copy to clipboard operation
ext-ds copied to clipboard

Error after add extension=ds.so to php.ini

Open akondas opened this issue 9 years ago • 40 comments

If i run command

 php -d extension=ds.so some_file.php

Then Ds extension works ok. But when i want add this line to php.ini:

extension=ds.so

Then php throw error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/ds.so'
 - /usr/lib/php/20151012/ds.so: undefined symbol: php_json_serializable_ce in Unknown on line 0

My PHP version: PHP 7.0.3 on Ubuntu 14.04

akondas avatar Feb 09 '16 10:02 akondas

There is currently a hard dependency on the json extension, which is a bug because it shouldn't try to implement JsonSerializable if the json extension is not loaded.

Try enabling the json extension, or specifying ds.so after json is already enabled.

rtheunissen avatar Feb 09 '16 10:02 rtheunissen

@rtheunissen thanks for the quick response. Unfortunately json extension is allready loaded:

Module 'json' already loaded

I check in get_loaded_extensions and json exist. Should i add something else to php.ini ?

akondas avatar Feb 09 '16 10:02 akondas

What's your output for php -m?

rtheunissen avatar Feb 09 '16 11:02 rtheunissen

I think it's just a loading order issue, potentially more than one .ini

What's your output for php -i | grep ini?

rtheunissen avatar Feb 09 '16 11:02 rtheunissen

@rtheunissen ok, json extension was loaded in additional ini file (conf.d). To fix this problem i create new file (for example 30-ds.ini) with content extension=ds.so and put it in /etc/php/7.0/fpm/conf.d. Now ds extension is load as last:

Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-intl.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-pdo_pgsql.ini,
/etc/php/7.0/cli/conf.d/20-pgsql.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/30-ds.ini

Thanks for help :+1:

akondas avatar Feb 09 '16 13:02 akondas

@nikic I'm facing issue again. Wouldn't this have been fixed in https://github.com/php-ds/extension/pull/34 ?

rtheunissen avatar Aug 07 '16 19:08 rtheunissen

@rtheunissen #34 fixed the loading order issue for static builds. I guess to fix it for so's we should add

PHP_ADD_EXTENSION_DEP(ds, spl)
PHP_ADD_EXTENSION_DEP(ds, json)

to the config.m4.

nikic avatar Aug 07 '16 19:08 nikic

The w32 variant is ADD_EXTENSION_DEP('ds', 'spl') etc.

nikic avatar Aug 07 '16 19:08 nikic

@nikic attempted to fix this in c2def79fde25dbfa20ce3de8bf4de088424b9ed5, rebuilt, still getting undefined symbol: php_json_serializable_ce. Am I missing something in the m4?

rtheunissen avatar Aug 07 '16 19:08 rtheunissen

Hello. I'm facing this issue too. At moment I do what @itcraftsmanpl say. I think at least that solution must be documented at readme. I spend an hour before think in search on closed issues for an answer. :sweat_smile:

But the extension is awesome. Thanks you guys. :smile:

yybalam avatar Aug 10 '16 00:08 yybalam

Seems like the only solution is to not add ds.so directly to the main php.ini but to create a new one with a higher alphabetic ranking like @itcraftsmanpl did. This used to be part of the readme.

What's interesting here is that I'm only seeing this issue when I'm using a release build of PHP, ie. when I'm not building PHP myself. When I use phpbrew to build and install, adding to the main php.ini works just fine. I'm guessing static build vs dynamic?

rtheunissen avatar Aug 10 '16 00:08 rtheunissen

I've added a note in README.md, not much else that can be done.

rtheunissen avatar Aug 10 '16 09:08 rtheunissen

I was getting the same Unable to load dynamic library ... undefined symbol: php_json_serializable_ce issue as @itcraftsmanpl on Linux Mint, regardless of whether I installed using pecl install ds or did git clone and built the code. Changing /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module
; priority=30
 extension=ds.so

and then doing

 $ sudo phpenmod ds

worked, but only after I manually removed all the 20-ds.ini symbolic links. Thanks so much for this extension!

kurt-krueckeberg avatar Oct 17 '16 23:10 kurt-krueckeberg

I'm facing this issue too :( . I've used the trick of naming the file 30-ds.ini (and ensured that there is not any 20-ds.ini file anywhere), but the problem is happening anyway.

I'm working with PHP7.0, and Ubuntu 16.04. I've installed the extension through PECL. And.. the JSON extension is also installed and loaded.

castarco avatar Oct 20 '16 12:10 castarco

Well, I found that even though I edit /etc/php/7.0/mods-available/ds.ini to look like:

; configuration for php ds module
; priority=30
extension=ds.so

And even though I first did

  $ sudo phpdismod ds

This did not remove the 20-ds.ini symbolic links

$ cd /etc/php/7.0/
$ find . -name "*ds.ini"
./apache2/conf.d/20-ds.ini
./fpm/conf.d/20-ds.ini
./mods-available/ds.ini
./cli/conf.d/20-ds.ini
./cli/conf.d/30-ds.ini

So that after I edited /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module
; priority=30
extension=ds.so

instead of

; configuration for php ds module
; priority=20
 extension=ds.so

and even after I did

 $ sudo phpdismod ds

before doing

$ sudo phpenmod ds

The old 20-ds.ini symbolic links were still present, and I had to manually remove them by hand. Then the error message went away,

kurt-krueckeberg avatar Oct 20 '16 13:10 kurt-krueckeberg

Well, I found that even though I edit /etc/php/7.0/mods-available/ds.ini to look like:

; configuration for php ds module ; priority=30 extension=ds.so

And even though I first did

$ sudo phpdismod ds

This did not remove the 20-ds.ini symbolic links

$ cd /etc/php/7.0/ $ find . -name "*ds.ini"

./apache2/conf.d/20-ds.ini ./fpm/conf.d/20-ds.ini ./mods-available/ds.ini ./cli/conf.d/20-ds.ini ./cli/conf.d/30-ds.ini

So that after I edited /etc/php/7.0/mods-available/ds.ini to be:

; configuration for php ds module ; priority=30 extension=ds.so

instead of

; configuration for php ds module ; priority=20 extension=ds.so

and eve after I did

$ sudo phpdismod ds

before doing

$ sudo phpenmod ds

The old 2-ds.ini symbolic links were still present, and I had to manually remove them by hand.

This showed that there were both 20-ds.ini and 30-ds.ini symbolic links.

On 10/20/2016 08:51 AM, Andreu Correa Casablanca wrote:

I'm facing this issue too :( . I've used the trick of naming the file 30-ds.ini (and ensuring that there is not 20-ds.ini file), but the problem is happening anyway.

I'm working with PHP7.0, and Ubuntu 16.04. I've installed the extension through PECL.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/php-ds/extension/issues/2#issuecomment-255096772, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH9yoJpZTInh6QdU3t-twoMjFt8VV0cks5q12PagaJpZM4HWSF0.

kurt-krueckeberg avatar Oct 20 '16 13:10 kurt-krueckeberg

@castarco After ensure that you put a 30-ds.ini also check to remove (or comment) the extension=ds.so from your php.ini file.

yybalam avatar Oct 20 '16 14:10 yybalam

@yybalam I haven't any line like this one in my php.ini file. I've looked for it with grep and the vim's search feature.

P.D.: I'm working only with the PHP CLI, I'm not using (nor installed) PHP-FPM nor phpmod for Apache.

castarco avatar Oct 20 '16 14:10 castarco

Do php -m to see which extensions are active On 10/20/2016 10:45 AM, Andreu Correa Casablanca wrote:

@yybalam https://github.com/yybalam I haven't any line like this one in my php.ini file. I've looked for it with |grep| and the |vim|'s search feature.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/php-ds/extension/issues/2#issuecomment-255126890, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH9yrlyNErW-XPzucvSdI3r63Pg0g38ks5q135ygaJpZM4HWSF0.

kurt-krueckeberg avatar Oct 20 '16 14:10 kurt-krueckeberg

@kkruecke I've did it before. This is the result:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
intl
json
libxml
mbstring
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Xdebug
Zend OPcache

castarco avatar Oct 20 '16 15:10 castarco

@castarco

I haven't any line like this one in my php.ini file

Are you using php -d extension=ds.so then?

rtheunissen avatar Oct 21 '16 00:10 rtheunissen

Hi @rtheunissen , yes. I'm using this option, and sometimes I use dynamic loading, with a call to dl, but this last workaround is a little bit dirty since it's a very insecure method.

castarco avatar Oct 21 '16 12:10 castarco

I am running Linux Mint 18. Neither Ubuntu nor Mint 18 does use one single php.ini. Instead Linux Mint and Ubuntu have structured the installation of php extensions to use a separate .ini files that reside in /etc/php/7.0/mods-available/. When you enable an extension using "phpenmod", it creates a symbolic links to the mods-available file:

$ sudo phpenmod ds $ find /etc/php/7.0 -name "*ds.ini"

./apache2/conf.d/30-ds.ini ./fpm/conf.d/30-ds.ini ./mods-available/ds.ini ./cli/conf.d/30-ds.ini

On 10/20/2016 08:43 PM, Rudi Theunissen wrote:

@castarco https://github.com/castarco

I haven't any line like this one in my php.ini file

Are you using |php -d extension=ds.so| then?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/php-ds/extension/issues/2#issuecomment-255265630, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH9yq08ZfWIbZdrM6QtUPyioO5vQb0Fks5q2AqXgaJpZM4HWSF0.

kurt-krueckeberg avatar Oct 25 '16 18:10 kurt-krueckeberg

I ran into this problem on centos7 / php7.

I had to make an INI file called z_ds.ini and not 30-ds.ini like suggested earlier in the thread. In centos7/php7, the /etc/php.d/ files do not have numeric prefixes for easy ordering, hence why I had to prefix with z_.

Good luck.

jdestefx avatar Nov 16 '16 00:11 jdestefx

This is so infuriating, how are other extensions not also running into this problem / how is this still a thing? Thanks for all the feedback here everyone, I'm going to link the readme directly to this issue.

rtheunissen avatar Nov 16 '16 00:11 rtheunissen

@rtheunissen - Other extensions are also suffering from this. The issue is with distribution's PHPs not doing the standard PHP thing. I have written an explanation at https://derickrethans.nl/undefined-symbol.html about the how and why.

derickr avatar Dec 01 '16 16:12 derickr

I had this problem too and I was a little stupid, actually when removing dirty symbolic links, do not forget to remove it for CLI too and not only for Apache/Nginx.

I had the error "php_json_serializable_ce" (described sooner in this topic) and I solved it like this:

cd /etc/php/7.1/apache2/conf.d
rm 20-ds.ini

cd /etc/php/7.1/**cli**/conf.d
rm 20-ds.ini

grizzlylab avatar Dec 05 '16 19:12 grizzlylab

I'm using Fedora 25 (PHP 7.0.20) and I have had the same problem. Just creating a new config file /etc/php.d/50-ds.ini, as teached on @derickr post, worked perfectly.

Inside the file, just extension=ds.so is needed.

lsrocha avatar Jun 20 '17 02:06 lsrocha

I am using ubuntu and having the same problem with PHP 7.0.18

miradnan avatar Jun 28 '17 12:06 miradnan

This is not a bug, just the nature of how some distributions handle their INI loading.

rtheunissen avatar Oct 17 '18 17:10 rtheunissen