RE: Bug #11749 Updated: Unserialize dies with Apache Module but is FINE with CGI

From: Date: Fri, 29 Jun 2001 10:31:25 +0000
Subject: RE: Bug #11749 Updated: Unserialize dies with Apache Module but is FINE with CGI
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-58400@lists.php.net to get a copy of this message
You may consider it fixed if you like. However... the data file failed to load in Module, and did load in CGI. Shouldn't they be identical? -Brian -----Original Message----- From: Bug Database [mailto:php-dev@lists.php.net] Sent: June 29, 2001 1:17 AM To: btanner@home.net Subject: Bug #11749 Updated: Unserialize dies with Apache Module but is FINE with CGI ID: 11749 Updated by: thies Reported By: btanner@home.net Old-Status: Open Status: Closed Bug Type: Scripting Engine problem Operating system: PHP Version: 4.0.6 Assigned To: Comments: binary mode only makes a difference when youstore carriage-returns in your file. i bet your "old" test did not have CR in the data. i consider this problem "fixed" Previous Comments: --------------------------------------------------------------------------- [2001-06-28 11:29:14] btanner@home.net After changing all my reads and writes to forced binary reads and right, all is well with Win32 Apache module. IMHO, this is still a bug. If the behaviour is this for the module, it should also be the same for the CGI. Why did this work? --------------------------------------------------------------------------- [2001-06-27 14:32:13] btanner@home.net If it helps: a)Script b)Datafile can be found in zip form at: http://www.zaam.com/zend/bug11749.zip Thanks for all your help on this guys. --------------------------------------------------------------------------- [2001-06-27 14:06:09] btanner@home.net Bingo.. got it down to a reasonable amount of code. I'll provide the code here (its still 65 lines). I have kept the "save" method, although it is not used in this example. Reason being is that I am loading an object that I previously saved, so its possible that the save method is the offender. Here you go. I'll also reply to this message in php-dev (if the list ever starts working) -- with the datafile attached. --Code starts-- <? class Module_Variable{ var $Type; var $Name; var $Value; function Module_Variable($Name,$Value,$Type="S"){ $this->Name=$Name; $this->Value=$Value; $this->Type=$Type; } } //end of module_variable class class Module { var $Variables; // Array of Configuration Variables for this Module var $Inclusions; // Array of Inclusions in case of newuser,deleteuser,etc,etc var $Path; // Path from Root to get to this module var $Name; var $Loaded; // Has this module been loaded, or not? function Module($Name,$Path){ $this->Name=$Name; $this->Path=$Path; $this->Loaded=0; $this->Variables=""; } function Save(){ $ModCode=serialize($this); $FileLocation=__DATAPATH."mod_data/".$this->Name.".mod"; $FilePointer=fopen($FileLocation,"w"); $WriteCheck=fwrite($FilePointer,$ModCode); if(!$WriteCheck) die("Error writing output..."); fclose($FilePointer); } function Load(){ $FileLocation=$this->Name.".mod"; $FilePointer=@fopen($FileLocation,"r"); if(!$FilePointer) $this->HandleError($FileLocation); $EncodedString=fread($FilePointer,filesize($FileLocation)); fclose($FilePointer); $VarObject=unserialize($EncodedString); $this->Variables=$VarObject->Variables; $this->Loaded=1; } }//end the class $MyModule=new Module("login",""); $MyModule->Load(); print("<hr><Br>Good so far"); ?> --------------------------------------------------------------------------- [2001-06-27 13:11:08] sniper@php.net Please include a short example of both script and the class you get this with. --------------------------------------------------------------------------- [2001-06-27 12:33:39] btanner@home.net I've been running fine on CGI for a while now, jumping between 4.04, 4.07-dev, 4.05 When I tried to switch from 4.05 CGI to 4.05 4.05-Apache ... one of my files does not unserialize properly. The error message is: Warning: unserialize() failed at offset 487 of 2797 bytes in c:program filesapache groupapachehtdocsgt2librariesclassesmodule.class on line 189 If you guys know something about this, please let me know, as soon as possible. In the mean time, I am going to make a script that saves a serialized object to disk. I will save it to a file using CGI and then Apache modules. Then, I will try to load em both using Apache and CGI modules... see what turns up. --------------------------------------------------------------------------- The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online. ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=11749&edit=2

« previous php.dev (#58400) next »