|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-07-20 20:23 UTC] t_mueller_stolzenhain at yahoo dot de
Description:
------------
After updating PHP to version 5.2.6 on a windows 2003 server running under IIS, it was not possible to update PEAR anymore. Each package created some error messages like
Notice: unserialize(): Error at offset 1139 of 4783 bytes in PEAR\Registry.php on line 1062
After putting the line
$data = str_replace("\15\12", "\12", $data);
before the unserialize-including line, the error message disappeared an I was able to update PEAR again.
I asume, this is an IIS related issue, because on an other Computer with PHP 5.2.5 (running on Win XP and Apache) are no error messages.
Reproduce code:
---------------
These are the lines 1058-1064 from /PEAR/PEAR/Registry.php including one line with an fix
$this->_closePackageFile($fp);
$data = file_get_contents($this->_packageFileName($package, $channel));
set_magic_quotes_runtime($rt);
$data = str_replace("\15\12", "\12", $data);//additional line with fix
$data = unserialize($data);
if ($key === null) {
return $data;
}
Expected result:
----------------
no error message
Actual result:
--------------
e.g.
Notice: unserialize(): Error at offset 1139 of 4783 bytes in PEAR\Registry.php on line 1062
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
I don't have a sample script (I'm not able to create an text with two different line endings in it), but I found the reason for that issue: As you know, PEAR is storing some information inside the .registry directory in *.reg files. Some of these files I found converted to the windows style, means they had a windows line ending ("\15\12") instead of the linux line ending ("\12"). After reformating these files with the linux line ending, the error messages disappeared, and the PEAR update was running without any error messages. I asume, the most of the files on a windows computer have the windows line ending included, not the linux line ending. PHP is able to detect that it is running on a windows computer, and unserialize should be able to handle the windows line ending without error message.sample to reproduce the error I had: <?php //the original array $a = array( 'a23' => 'abcdefg hij' ); //make it serial $s = serialize($a); //just to see the serial string var_dump($s); //the serialized array $s1 = 'a:1:{s:3:"a23";s:11:"abcdefg hij";}'; //the same with linux line end character $s2 = "a:1:{s:3:\"a23\";s:11:\"abcdefg\12hij\";}"; //the same with windows line end character, same I had in my PEAR files $s3 = "a:1:{s:3:\"a23\";s:11:\"abcdefg\15\12hij\";}"; //turn it back to an array $a1 = unserialize($s1); // ok $a2 = unserialize($s2); // ok $a3 = unserialize($s3); // not ok ?>