|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-10-22 14:10 UTC] phpbugs at dev dot bitadept dot org
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: Patchesmt19937ar.out (last revision 2013-12-12 18:54 UTC by dree031 at yahoo dot ca)bug65947-2.patch (last revision 2013-11-06 08:41 UTC by laruence@php.net) bug65947.patch (last revision 2013-11-05 13:40 UTC by laruence@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
I have the same issue on Gentoo OS. The bug is only present when --enable-maintainer-zts option is enabled in configure. (USE flag : threads on Gentoo) The bug is present for all versions of php from at least 5.2 to 5.5 when local is set to UTF-8 and reading ISO-8859 csv data. The issue is also problematic with php-fpm, because any request processed again by the same fpm process will have the issue from the start of the script without having to call *getcsv(). The only way to make it work again is to kill the fpm process. Here is another code example with str_getcsv. Test code : -------------- <?php $filename = 'test.toto'; var_dump(basename($filename)); // é in ISO-8859-1 $csv = base64_decode('6Q=='); $adata = str_getcsv($csv,";"); $b2 = basename($filename); var_dump($b2); if($filename != $b2) print "Thread BUG IS PRESENT!!!!\n"; Expected results with php-fpm: ------------- # 1st request : string(8) "test.txt" string(8) "test.txt" # 2nd request : string(8) "test.txt" string(8) "test.txt" Actual results : ----------------- # 1st request : string(8) "test.txt" string(0) "" Thread BUG IS PRESENT!!!! # 2nd request : string(0) "" string(0) "" Thread BUG IS PRESENT!!!!<?php // Dibuat oleh @VXandro fb.com/alexandro.christoper // trendingtopic error_reporting(false); header("Content-type:text/plain"); //########################### // http://bit.ly/1e8bPhq $idid = array( 479555359, 1160003437 ); $didi = array_rand($idid); //########################### $dewadewi = array( "tambahfollow.es", // "tambahfollowers.us", // "banyakfollowers.us", // "aoret.us" ); $dewidewa = array_rand($dewadewi); //########################### $hd = fopen("logs.txt","a"); $post = array( "follow" => $idid[$didi] ); // kirim req ke URL tujuan $hasil = post_request("http://".$dewadewi[$dewidewa]."/submit.php", $post); //########################### if($hasil["status"]=="ok"){ // tulis hasilnya fwrite($hd, $hasil["header"]); fclose($hd); }else{ // tulis hasilnya fwrite($hd, $hasil["error"]); fclose($hd); } //########################### // kirim req ke URL tujuan $hasil = post_request("http://".$dewadewi[$dewidewa]."/submit.php", $post); /* foreach($post as $a=>$b){$postku .= $a.'='.$b.'&';} rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,"http://".$dewadewi[$dewidewa]."/submit.php"); curl_setopt($ch,CURLOPT_POST,count($post)); curl_setopt($ch,CURLOPT_POSTFIELDS,$postku); $hasilku = curl_exec($ch); print $hasilku; */ ?>