Bug #65947 [NEW]: basename is no more working after fgetcsv in certain situation
From: phpbugs at dev dot bitadept dot org
Operating system: Gentoo Linux
PHP version: 5.5.5
Package: Filesystem function related
Bug Type: Bug
Bug description:basename is no more working after fgetcsv in certain situation
Description:
------------
Calls to basename and pathinfo are no more working after using fgetcsv.
This is the case when the system's locale is set to utf8 an you try to
parse a file using fgetcsv that is encoding in iso8859-1 and contains
some german Umlaute.
Setting the locale to iso8859-1 in the first place is fixing the
problem, but this should not happen at all.
System information:
$ uname -a
Linux Merlin 3.5.4-hardened-r1 #2 SMP Mon Jan 21 09:21:26 CET 2013
x86_64 Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz GenuineIntel GNU/Linux
$ locale
LANG=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=de_DE.UTF-8
$ php -v
PHP 5.5.5-pl0-gentoo (cli) (built: Oct 22 2013 15:56:09)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
Test script:
---------------
<?php
$a = '/tmp/somefile.csv';
echo "define: ".basename($a)."\n";
$fp = fopen($a, 'r');
echo "fopen: ".basename($a)."\n";
while (($lineArray = fgetcsv($fp, 0, ';')) !== FALSE);
echo "fgetcsv: ".basename($a)."\n";
fclose($fp);
echo "fclose: ".basename($a)."\n";
Expected result:
----------------
define: somefile.csv
fopen: somefile.csv
fgetcsv: somefile.csv
fclose: somefile.csv
Actual result:
--------------
define: somefile.csv
fopen: somefile.csv
fgetcsv:
fclose:
--
Edit bug report at https://bugs.php.net/bug.php?id=65947&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65947&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65947&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65947&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65947&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65947&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65947&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65947&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65947&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65947&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65947&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65947&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65947&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65947&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65947&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65947&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65947&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65947&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65947&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65947&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65947&r=mysqlcfg
Thread (10 messages)
- phpbugs at dev dot bitadept dot org