ID: 21087 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: XP PHP Version: 4.3.0RC3 New Comment:
Keep this at feedback. (and note that I am not [EMAIL PROTECTED] and that my previous comment on this was my first). Previous Comments: ------------------------------------------------------------------------ [2002-12-19 11:17:24] [EMAIL PROTECTED] Sorry for the misunderstanding. First of all I did not know that you were a developer working the problem. Nothing in your comment told me that. Secondly, I have already stated that I will try to produce a smaller script (see my original post). I just haven't had time to work the problem. As to the buffering, without it, the full text is not written out. It gets truncated. ------------------------------------------------------------------------ [2002-12-19 07:43:14] [EMAIL PROTECTED] Please try and cut down the script to a complete self-contained example that I can run here. I'm not going to spend hours debugging a long, incomplete code fragment. What I'm looking for it something like this: $fp = fopen($filename, "w"); $len = fwrite($fp, $data); fclose($fp); echo "Wrote $len bytes"; If that works, try adding in the flock calls. If that works, try adding in those set_file_buffer calls (NB: there does not seem to be a need to play with file buffering in this case). Please help me to help you. ------------------------------------------------------------------------ [2002-12-19 07:16:01] [EMAIL PROTECTED] I'm running Apache 1.3.27. I haven't tested it under *nix. As far as a code snippet, I will assume that it is in this code, somewhere: if ($admin_from_web==true) { $row = 0; $insert_msg = ''; $fp = fopen("$path_to_gb",'r') or die("$unable_to_access_file_msg $path_to_gb"); set_file_buffer($fp,$buffersize); flock($fp,1); $num = 16; for ($i=0;$i<$num;$i++) { $j = $i+1; $head_array[$i] = ${"col$j"}; } while ($data = fgetcsv($fp,$csv_buffer_size,",")) { $row++; if ($row<2) continue; $new_msg = ""; if ($data[0]==$msgid) { if (!empty($update)) { reset ($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) { $found=false; for ($i=0;$i<count($head_array);$i++) { if ($key==$head_array[$i]) { $rec[$i] = $val; $found=true; } if ($found) break; } } $msg = $label_name."$data[4] (ip = ".getenv(REMOTE_ADDR).") - $head_array[0]:$msgid ".$on." ".date($date_format)." $at ".date($time_format)."\n"; for ($c=0;$c<$num;$c++) { if ($c==0) $comma=""; else $comma=","; if ($c==13&&$row>1) { $rec[$c] = htmlspecialchars($rec[$c],ENT_QUOTES); $rec[$c] = str_replace("&#","&#",$rec[$c]); $new_msg .= $comma."\"$rec[$c]\""; } elseif ($c<4) $new_msg .= $comma."$rec[$c]"; else $new_msg .= $comma."\"$rec[$c]\""; if (chop($data[$c])!=chop($rec[$c])) { $msg .= "$head_array[$c]: [$data[$c]]\n\n$head_array[$c]: [$rec[$c]]\n\n\n"; } } $new_msg .= "\n"; if ($admin_email_advice_on_gb_edit && !empty($admin_email_address)) { $to = "$admin_email_address,$admin_email_address_addl"; $subject = "$admin_email_subject_on_gb_edit"; @mail($to, $subject, "$msg","From: $admin_email_address") ; } } } else { for ($c=0;$c<$num;$c++) { $val = $data[$c]; if ($c==0) $comma=""; else $comma=","; if ($c==13&&$row>1) $new_msg .= $comma."\"$val\""; elseif ($c<4&&$row>1) $new_msg .= $comma."$val"; else $new_msg .= $comma."\"$val\""; } $new_msg .= "\n"; } if (!empty($new_msg)) $newgb[] = $new_msg; } flock($fp,3); fclose($fp); unset($delete); unset($update); $buffersize = round(filesize($path_to_gb)*1.5); $fp = fopen("$path_to_gb",'w') or die("$unable_to_access_file_msg $path_to_gb"); set_file_buffer($fp,$buffersize); flock($fp,1); for ($i=0;$i<count($newgb);$i++) { if ($i==0) $prefx = "<? Header(\"HTTP/1.0 403 Forbidden\");exit; ?>\n"; else $prefx = ""; fwrite($fp,$prefx.$newgb[$i]); } flock($fp,3); fclose($fp); } ------------------------------------------------------------------------ [2002-12-19 06:29:35] [EMAIL PROTECTED] I've read similar bug report from several of our users (we have free hosting server with aprox. 60,000 users, currently running latest RC of php-4.3.0 with apache-2.0.43), but I've not been able to reproduce it. Can you please paste here part of your code ? ------------------------------------------------------------------------ [2002-12-18 18:58:42] [EMAIL PROTECTED] This is just a heads up. I can reproduce it but can't figure out why. I have a guestbook script that I wrote (KISGB) and it works perfectly under all prior to 4.3.x versions. However, 4.3.0RC3 (don't know about previous RC's) will not recreate the file. Basically the script is trying to rewrite a configuration file. It fails every time (writing out a file of zero length) but I can't find anything on the logs. As soon as I restore a previous non 4.2.3x release, it works flawlessly. I will continue to try to produce a smaller script to replicate it, but it will fail 100% of the time under 4.3.0. I will also add that the script is a phpNUKE module, so it is operating within that framework. It is a flat file, not a MySQL table. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21087&edit=1