Bug #15303 [Fbk->Bgs]: Unserialize throws error

From: Date: Fri, 20 Mar 2009 15:31:22 +0000
Subject: Bug #15303 [Fbk->Bgs]: Unserialize throws error
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-207@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=15303&edit=1 ID: 15303 Updated by: till@php.net Reported By: mick at deafzone dot ch Summary: Unserialize throws error -Status: Feedback +Status: Bogus Type: Bug Package: Mail_Queue Operating System: Apache Package Version: 1.2.2 PHP Version: 5.2.6 Assigned To: till Roadmap Versions: New Comment: -Status: Feedback +Status: Bogus Sorry, but your problem does not imply a bug in PEAR itself. For a list of more appropriate places to ask for help using PEAR, please visit http://pear.php.net/support/ as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PEAR. Works. Static is evil. Woo! Previous Comments: ------------------------------------------------------------------------ [2009-03-12 11:16:04] mick Yup, it works now after changing the Singleton with another design pattern. Thanks for the hint man! I never thought that the Singleton can mess up the references in the memory. Cheers Michael ------------------------------------------------------------------------ [2009-03-12 10:15:58] kguest mick - have you tested this since? ;-) ------------------------------------------------------------------------ [2009-01-15 20:13:13] mick Thank you man for the link. I needed that update and have changed my code, removed that global state. So I will test my code within the next days... Thank you very much Daniel for your much appreciated input! Cheers Michael ------------------------------------------------------------------------ [2009-01-15 10:07:22] doconnor Ewww... singleton = global state. Is there any possible way that you can avoid using a singleton here? That will probably make your problem go right away, as there will be no mess between calls to email stuff. More detail: http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/ ------------------------------------------------------------------------ [2008-12-14 20:01:27] mick And there the 'attachment, the singleton class SGL_Email_Queue: define('SGL_MAIL_QUEUE_SEND_DELAY', 2); define('SGL_MAIL_QUEUE_BUFFER', 55); class SGL_Email_Queue { private static $instance; private $oMailQueue; private function __construct() { SGL::logMessage(null, PEAR_LOG_DEBUG); $aDBOptions = array( 'type' => 'db', 'phptype' => SGL_DB::getDefaultType(), 'dsn' => SGL_DB::getDsn(SGL_DSN_STRING), 'mail_table' => 'mail_queue' ); $aMailOptions = array( 'driver' => SGL_Emailer::getBackend() ); $this->oMailQueue = new Mail_Queue($aDBOptions, $aMailOptions); } public static function singleton() { SGL::logMessage(null, PEAR_LOG_DEBUG); if (!isset(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; } public function put($sFrom, $sTo, $sBody) { SGL::logMessage(null, PEAR_LOG_DEBUG); return $this->oMailQueue->put($sFrom, $sTo, $aHeaders, $sBody); } private static function getLockFileName() { return 'mail_queue.lock'; } private function getLockFileDirectory() { return SGL_TMP_DIR; } private static function getLockFileUrl() { return self::getLockFileDirectory() . '/' . self::getLockFileName(); } public static function lock() { SGL::logMessage(null, PEAR_LOG_DEBUG); $args = '-t ' . self::getLockFileDirectory() . ' ' . self::getLockFileName(); $fullPath = System::mktemp($args); if (empty($fullPath)) { return SGL::raiseFormattedError('Cannot create mail queue lock file with the arguments %args!', $args); } else { // temporary lock file successfuly created, // it will be removed when the script has finished // its execution return true; } } public static function isLocked() { $lockFileUrl = self::getLockFileUrl(); return file_exists($lockFileUrl); } public function sendMailsInQueue() { SGL::logMessage(null, PEAR_LOG_DEBUG); $count = 0; set_time_limit(0); // use a higher buffer size for better performance; // but the higher it is, the less memory you'll have for // other operations! $this->oMailQueue->setBufferSize(SGL_MAIL_QUEUE_BUFFER); $this->oMailQueue->container->setOption (MAILQUEUE_ALL, MAILQUEUE_START, 1); while ($mail = $this->oMailQueue->get()) { if (PEAR::isError($mail)) { return $mail; } $sBody = $mail->getBody(); if (!$sBody{0}) { // empty body found, something was wrong! $sendResult = SGL::raiseError('Empty mail body found!'); } else { $sendResult = $this->oMailQueue->sendMail($mail, false); } // delete always $deleteResult = $this->oMailQueue->deleteMail($mail->getId()); if (PEAR::isError($sendResult)) { return $sendResult; } else if (PEAR::isError($deleteResult)) { return $deleteResult; } $count++; sleep(SGL_MAIL_QUEUE_SEND_DELAY); } return $count; } } ------------------------------------------------------------------------ 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://pear.php.net/bugs/bug.php?id=15303 -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=15303&edit=1

« previous php.pear.bugs (#207) next »