#25185 [Opn]: Unserialize can't decode string from serialize

From: Date: Thu, 21 Aug 2003 20:06:23 +0000
Subject: #25185 [Opn]: Unserialize can't decode string from serialize
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-46446@lists.php.net to get a copy of this message
 ID:               25185
 User updated by:  cpuidle at gmx dot de
 Reported By:      cpuidle at gmx dot de
 Status:           Open
 Bug Type:         *General Issues
 Operating System: Windows
 PHP Version:      4.3.3RC4
 New Comment:

The filereading hint was a good suggestion- it does actually seem to
work if I'm using file_get_contents instead of join('',file($file))-
could smdb. explain why?

Kindly,
Andi


Previous Comments:
------------------------------------------------------------------------

[2003-08-21 14:59:58] cpuidle at gmx dot de

I'm sorry. The function where the file is written is obviously not
download, but this one:

function saveHTTPcache($url,$resp){
  $cfile='cache/imdb/'.md5($url);
  $string=serialize($resp);
  @fwrite(@fopen("$cfile", "w"),$string,strlen($string));
}

------------------------------------------------------------------------

[2003-08-21 14:47:40] cpuidle at gmx dot de

Have not tried the snapshot yet- is it supposed to fix (un)serialize or
load/store?

Andi

------------------------------------------------------------------------

[2003-08-21 14:46:20] cpuidle at gmx dot de

This is the code to save and restore the data:

function download($url, $local){
  $resp = fetchHTTP($url);
	$writefile = @fopen($local, "wb");
	if(!$writefile) return false;
	if(!fwrite($writefile, $resp[data], strlen($resp[data]))) return
false;
	fclose($writefile);
	return true;
}

function getHTTPcache($url){
  $cfile='../videodb/cache/imdb/'.md5($url);
    $resp = unserialize(join('',file($cfile)));
    return $resp;
}

------------------------------------------------------------------------

[2003-08-21 10:06:36] helly@php.net

The problem doesn't have to do anything with serialize/unserialize but
with the way you store/load the serialized data. Can you tell us how?
And do you do any manual changes to the serialized data or even view it
with an external editor?

------------------------------------------------------------------------

[2003-08-21 07:59:27] sniper@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/25185

-- 
Edit this bug report at http://bugs.php.net/?id=25185&edit=1



Thread (8 messages)

« previous php.bugs (#46446) next »