Réorganiser la liste des extensions PHP

Contenu

Il m’est arrivé que php segfault (plante) sans raison apparente et sans logger aucune information, le script ci-dessous réorganise l’ordre dans lequel les modules sont chargé.

#!/bin/sh

# =============================================================
# Fix php/extensions.ini order
#
# Script based on the idea and information(s) of
# - http://www.pingle.org/2007/09/22/php-crashes-extensions-workaround
# - http://nerdstock.org/php_extensions
#
# Please copy your original php/extensions.ini to a save place before
# running this script!
#
# There is no guaranty the script is working for you or don't damage
# your system. Use at own Risk!
#
# 2011-04-03 olli hauer
#
# License: BSD
#  http://www.freebsd.org/copyright/freebsd-license.html

INI=/usr/local/etc/php/extensions.ini

EXT="session.so fileinfo.so crack.so ssh2.so imagick.so ldap.so
    simplexml.so dba.so ctype.so apc.so ftp.so mbstring.so tokenizer.so
    filter.so pgsql.so gmp.so mcrypt.so tidy.so xmlwriter.so mhash.so gd.so
    ncurses.so readline.so gettext.so iconv.so dbase.so calendar.so exif.so
    zlib.so curl.so mailparse.so xmlrpc.so bz2.so sysvmsg.so pdf.so openssl.so
    ming.so dom.so hash.so xmlreader.so gnupg.so bcmath.so pcre.so xsl.so
    wddx.so memcache.so soap.so spl.so sqlite.so recode.so pdo.so pdo_mysql.so
    pdo_sqlite.so mysqli.so mysql.so imap.so sockets.so pspell.so xml.so"


if [ ! -e ${INI} ] ; then
    echo "cannot find ${INI}"
    exit 1
fi

# cleanup previous run
[ -e ${INI}.new ] && rm -f ${INI}.new
cp -f ${INI} ${INI}.work

for e in ${EXT}; do
    if egrep -q "^extension=${e}" ${INI}.work ; then
        echo extension=${e} >> ${INI}.new
        sed -i '' -e "/${e}/d" ${INI}.work
    fi
done

if [ -s ${INI}.work ]; then
    echo "; additional extension(s) not known by $(basename $0)" >> ${INI}.new
    # sybase_ct needs to be loaded last.
    grep ^extension ${INI}.work | grep -v sybase_ct.so >> ${INI}.new
    grep ^extension=sybase_ct.so ${INI}.work >> ${INI}.new
    AE=1
fi
[ -e ${INI}.work ] && rm -f ${INI}.work
if cmp -s ${INI} ${INI}.new ; then
    echo "No changes found, remove ${INI}.new"
    rm -f ${INI}.new
    AE=0
fi

if [ ${AE} -ne 0 ]; then
cat << _EOF
==============================
New INI is saved as ${INI}.new

Additional extension(s) not known by $(basename $0)
are added to the end of new INI file.

Please review the new INI, and replace it on your own!
    Do some Basic tests:
    php -V
    php -m
    php -i
    apachectl graceful
    ...

_EOF
fi

cat << _EOF
If the segfault issue is not gone, or you cannot find the issue
    - ask on the [email protected] mailing list
or
    - open a PR:
    Synopsys: lang/php5 Segmentation fault.
    Additional try debugging with command:
    gdb php ./php.core

    http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/debugging.html


_EOF

Pascal
FreeBSD   php  

comments powered by Disqus