#39785 [Opn->Fbk]: implode() causes PHP CGI to fail if given a NULL value
| From: | tony2001@php.net | Date: | Sun, 10 Dec 2006 11:06:17 +0000 |
| Subject: | #39785 [Opn->Fbk]: implode() causes PHP CGI to fail if given a NULL value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-106159@lists.php.net to get a copy of this message | ||
ID: 39785
Updated by: tony2001@php.net
Reported By: me at nbishop dot name
-Status: Open
+Status: Feedback
Bug Type: Arrays related
Operating System: Fedora Core 4
PHP Version: 5.2.0
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2006-12-10 09:38:11] me at nbishop dot name
Description:
------------
This was some code I had been using since migrating to PHP5 since about
5.1.2 I believe at least, has worked since then until the server got
upgraded to PHP 5.2.0
In short, I have a database call that gets made before the function,
the database return can be NULL if no one has added anything into it
(its a banned IP result, if no IPs are banned, result is NULL).
Basically what happens is if I do implode("," array($data['banned']));,
in PHP 5.2 now it causes what seems to be the PHP CGI to fail (My server
gives me a '400 Internal Server Error' message).
Sadly I don't have access to apache logs and such, so I can't give you
much more beyond that.
PHP Configure Command:
../configure --program-suffix=5 --with-pear=/usr/local/lib/php5
--with-config-file-path=/usr/local/lib/php5
--with-libxml-dir=/usr/local/php5 --without-sqlite
--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap
--with-xsl=/usr/local/php5 --enable-mbstring=all
--with-curl=/usr/local/php5 --with-mcrypt=/usr/local/php5 --with-gd
--with-pdo-mysql=/usr/local/mysql --with-freetype-dir
--with-libxml-dir=/usr/local/php5 --with-mysql=/usr/local/mysql
--with-zlib --enable-debug=no --enable-safe-mode=no
--enable-discard-path=no --with-png-dir=/usr/lib --enable-track-vars
--with-db --with-gdbm --enable-force-cgi-redirect --with-ttf=/usr/
--enable-ftp --enable-dbase --enable-memory-limit --enable-calendar
--enable-wddx --with-jpeg-dir=/usr/src/php5/jpeg-6b --enable-bcmath
--enable-gd-imgstrttf --enable-shmop --enable-mhash
--with-mhash=/usr/src/php5/mhash-0.8.9/ --with-openssl --enable-xslt
--with-xslt-sablot --with-dom --with-dom-xslt --with-dom-exslt
--with-imap --with-iconv=/usr/local --with-bz2 --with-gettext
--enable-exif --with-idn
Reproduce code:
---------------
$ban_array = implode(",", array($data['Banned']));
if (strstr($ban_array, $_SERVER['REMOTE_ADDR'])) {
die("Banned");
}
Expected result:
----------------
That used to (if an IP matched in the banned IP's array from the
database) pop up the 'Banned' error message, else if the database value
for 'Banned' came back NULL, it would still continue to process with no
errors.
I managed to work around this now in PHP 5.2 however by replacing the
$ban_array line and adding another line before it, like such:
$banned = array(ltrim($data['Banned']));
$ban_array = implode(",", $banned);
Actual result:
--------------
Function ends up causing the server to kick out a 400 Internal Server
Error, no script process, nothing, so error reporting variables didn't
do nothing to show anything, cause it seems to cause the PHP CGI itself
to fail some how.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39785&edit=1