SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

From: Geoffrey T. D. <da...@us...> - 2001年08月18日 02:38:37
Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv30089/lib
Modified Files:
 Tag: release-1_2-branch
	db_filesystem.php 
Log Message:
Attempt to fix SF bug #413446.
I think this bug was due to using PHP's file() function to slurp in the
files (as an array of lines). The files, being serialized data, consist
of only one (sometimes very long) line. I think (at least in some PHPs)
this make the file() function unhappy. 
Fixed to use fread() rather than file(). Also make sure to open files
in 'binary' mode.
Index: db_filesystem.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/db_filesystem.php,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C2 -r1.4.2.2 -r1.4.2.3
*** db_filesystem.php	2001年08月18日 02:05:28	1.4.2.2
--- db_filesystem.php	2001年08月18日 02:38:34	1.4.2.3
***************
*** 46,62 ****
 function RetrievePage($dbi, $pagename, $pagestore) {
 $filename = $dbi[$pagestore] . "/" . $pagename;
! if ($fd = @fopen($filename, "r")) {
 $locked = flock($fd, 1); # Read lock
 if (!$locked) { 
 ExitWiki("Timeout while obtaining lock. Please try again"); 
 }
! if ($data = file($filename)) {
 // unserialize $data into a hash
! $pagehash = unserialize(join("\n", $data));
! 		 }	
! 		 fclose($fd);
! 		 if($data) {
! 		 return $pagehash;
! 		 }
 } else {
 return -1;
--- 46,65 ----
 function RetrievePage($dbi, $pagename, $pagestore) {
 $filename = $dbi[$pagestore] . "/" . $pagename;
! if ($fd = @fopen($filename, "rb")) {
 $locked = flock($fd, 1); # Read lock
 if (!$locked) { 
 ExitWiki("Timeout while obtaining lock. Please try again"); 
 }
! if ($data = fread($fd, filesize($filename))) {
 // unserialize $data into a hash
! $pagehash = unserialize($data);
! 	 if (!is_array($pagehash))
! 		ExitWiki(sprintf("'%s': corrupt file",
! 				 htmlspecialchars($filename)));
! 	 }	
! 	 fclose($fd);
! 	 if ($data) {
! 	 return $pagehash;
! 	 }
 } else {
 return -1;
***************
*** 80,93 ****
 
 $filename = $dbi . "/" . $pagename;
! if($fd = fopen($filename, 'a')) { 
 $locked = flock($fd,2); #Exclusive blocking lock 
 if (!$locked) { 
 ExitWiki("Timeout while obtaining lock. Please try again"); 
! } 
 
 #Second (actually used) filehandle 
! $fdsafe = fopen($filename, 'w'); 
! fwrite($fdsafe, $pagedata); 
! fclose($fdsafe); 
 fclose($fd);
 } else {
--- 83,101 ----
 
 $filename = $dbi . "/" . $pagename;
! if($fd = fopen($filename, 'a+b')) { 
 $locked = flock($fd,2); #Exclusive blocking lock 
 if (!$locked) { 
 ExitWiki("Timeout while obtaining lock. Please try again"); 
! }
! 	 
 
 #Second (actually used) filehandle 
! #$fdsafe = fopen($filename, 'wb'); 
! #fwrite($fdsafe, $pagedata); 
! #fclose($fdsafe);
! 
! 	 rewind($fd);
! 	 ftruncate($fd, 0);
! fwrite($fd, $pagedata); 
 fclose($fd);
 } else {
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /