#39785 [NEW]: implode() causes PHP CGI to fail if given a NULL value
| From: | me at nbishop dot name | Date: | Sun, 10 Dec 2006 09:38:11 +0000 |
| Subject: | #39785 [NEW]: implode() causes PHP CGI to fail if given a NULL value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-106154@lists.php.net to get a copy of this message | ||
From: me at nbishop dot name
Operating system: Fedora Core 4
PHP version: 5.2.0
PHP Bug Type: Arrays related
Bug description: implode() causes PHP CGI to fail if given a NULL value
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 bug report at http://bugs.php.net/?id=39785&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39785&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39785&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39785&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39785&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39785&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39785&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39785&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39785&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39785&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39785&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39785&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39785&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39785&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39785&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39785&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39785&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39785&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39785&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39785&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39785&r=mysqlcfg