MailSo optimizations: Logging, Fetch Callback

Contacts: remove transaction support
This commit is contained in:
RainLoop Team 2014-05-26 19:50:23 +04:00
parent 2f074433a2
commit d07e3b0247
11 changed files with 245 additions and 317 deletions

View file

@ -1681,6 +1681,7 @@ class ImapClient extends \MailSo\Net\NetClient
{ {
$oImapResponse = null; $oImapResponse = null;
$sEndTag = (null === $sEndTag) ? $this->getCurrentTag() : $sEndTag; $sEndTag = (null === $sEndTag) ? $this->getCurrentTag() : $sEndTag;
while (true) while (true)
{ {
$oImapResponse = Response::NewInstance(); $oImapResponse = Response::NewInstance();
@ -2258,8 +2259,16 @@ class ImapClient extends \MailSo\Net\NetClient
$this->writeLog('Callback for '.$sParent.' / '.$sLiteralAtomUpperCase. $this->writeLog('Callback for '.$sParent.' / '.$sLiteralAtomUpperCase.
' - try to read '.$iLiteralLen.' bytes.', \MailSo\Log\Enumerations\Type::NOTE); ' - try to read '.$iLiteralLen.' bytes.', \MailSo\Log\Enumerations\Type::NOTE);
try
{
\call_user_func($this->aFetchCallbacks[$sFetchKey], \call_user_func($this->aFetchCallbacks[$sFetchKey],
$sParent, $sLiteralAtomUpperCase, $rImapLiteralStream); $sParent, $sLiteralAtomUpperCase, $rImapLiteralStream);
}
catch (\Exception $oException)
{
$this->writeLog('Callback Exception', \MailSo\Log\Enumerations\Type::NOTICE);
$this->writeLogException($oException);
}
$iNotReadLiteralLen = 0; $iNotReadLiteralLen = 0;
while (!\feof($rImapLiteralStream)) while (!\feof($rImapLiteralStream))

View file

@ -204,7 +204,17 @@ abstract class Driver
\MailSo\Log\Enumerations\Type::ERROR \MailSo\Log\Enumerations\Type::ERROR
))) )))
{ {
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), '--- FlushCache: WriteOnErrorOnly', \MailSo\Log\Enumerations\Type::INFO, 'LOGS'); $sFlush = '--- FlushLogCache: WriteOnErrorOnly';
if (isset($this->aCache[0]) && empty($this->aCache[0]))
{
$this->aCache[0] = $sFlush;
array_unshift($this->aCache, '');
}
else
{
array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName); $this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true; $this->bFlushCache = true;
@ -213,8 +223,16 @@ abstract class Driver
} }
else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly) else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly)
{ {
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), '--- FlushCache: WriteOnTimeoutOnly['. $sFlush = '--- FlushLogCache: WriteOnTimeoutOnly ['.(\time() - APP_START_TIME).'sec]';
(\time() - APP_START_TIME).'/'.$this->iWriteOnTimeoutOnly.']', \MailSo\Log\Enumerations\Type::NOTE, 'LOGS'); if (isset($this->aCache[0]) && empty($this->aCache[0]))
{
$this->aCache[0] = $sFlush;
array_unshift($this->aCache, '');
}
else
{
array_unshift($this->aCache, $sFlush);
}
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName); $this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);

View file

@ -48,14 +48,6 @@ abstract class PdoAbstract
return array('', '', '', ''); return array('', '', '', '');
} }
/**
* @return bool
*/
protected function isTransactionSupported()
{
return \in_array($this->sDbType, array('mysql'));
}
/** /**
* @return \PDO * @return \PDO
* *
@ -364,11 +356,6 @@ abstract class PdoAbstract
$oPdo = $this->getPDO(); $oPdo = $this->getPDO();
if ($oPdo) if ($oPdo)
{ {
if ($this->isTransactionSupported())
{
$oPdo->beginTransaction();
}
$sQuery = 'DELETE FROM rainloop_system WHERE sys_name = ? AND value_int <= ?;'; $sQuery = 'DELETE FROM rainloop_system WHERE sys_name = ? AND value_int <= ?;';
$this->writeLog($sQuery); $this->writeLog($sQuery);
@ -385,18 +372,6 @@ abstract class PdoAbstract
$bResult = !!$oStmt->execute(array($sName.'_version', $iVersion)); $bResult = !!$oStmt->execute(array($sName.'_version', $iVersion));
} }
} }
if ($this->isTransactionSupported())
{
if ($bResult)
{
$oPdo->commit();
}
else
{
$oPdo->rollBack();
}
}
} }
return $bResult; return $bResult;
@ -466,11 +441,6 @@ rl_email text NOT NULL DEFAULT \'\'
{ {
try try
{ {
if ($this->isTransactionSupported())
{
$oPdo->beginTransaction();
}
foreach ($aQ as $sQuery) foreach ($aQ as $sQuery)
{ {
if ($bResult) if ($bResult)
@ -487,27 +457,10 @@ rl_email text NOT NULL DEFAULT \'\'
} }
} }
} }
if ($this->isTransactionSupported())
{
if ($bResult)
{
$oPdo->rollBack();
}
else
{
$oPdo->commit();
}
}
} }
catch (\Exception $oException) catch (\Exception $oException)
{ {
$this->writeLog($oException); $this->writeLog($oException);
if ($this->isTransactionSupported())
{
$oPdo->rollBack();
}
throw $oException; throw $oException;
} }
} }
@ -568,11 +521,6 @@ rl_email text NOT NULL DEFAULT \'\'
{ {
try try
{ {
if ($this->isTransactionSupported())
{
$oPdo->beginTransaction();
}
foreach ($aQuery as $sQuery) foreach ($aQuery as $sQuery)
{ {
$this->writeLog($sQuery); $this->writeLog($sQuery);
@ -585,27 +533,10 @@ rl_email text NOT NULL DEFAULT \'\'
break; break;
} }
} }
if ($this->isTransactionSupported())
{
if ($bResult)
{
$oPdo->commit();
}
else
{
$oPdo->rollBack();
}
}
} }
catch (\Exception $oException) catch (\Exception $oException)
{ {
$this->writeLog($oException); $this->writeLog($oException);
if ($this->isTransactionSupported())
{
$oPdo->rollBack();
}
throw $oException; throw $oException;
} }

View file

@ -442,11 +442,6 @@ class PdoAddressBook
try try
{ {
if ($this->isTransactionSupported())
{
$this->beginTransaction();
}
$aFreq = array(); $aFreq = array();
if ($bUpdate) if ($bUpdate)
{ {
@ -582,19 +577,9 @@ class PdoAddressBook
} }
catch (\Exception $oException) catch (\Exception $oException)
{ {
if ($this->isTransactionSupported())
{
$this->rollBack();
}
throw $oException; throw $oException;
} }
if ($this->isTransactionSupported())
{
$this->commit();
}
return 0 < $iIdContact; return 0 < $iIdContact;
} }
@ -619,11 +604,6 @@ class PdoAddressBook
$mResult = false; $mResult = false;
try try
{ {
if ($this->isTransactionSupported())
{
$this->beginTransaction();
}
$sSql = 'INSERT INTO rainloop_ab_tags '. $sSql = 'INSERT INTO rainloop_ab_tags '.
'(id_user, tag_name) VALUES (:id_user, :tag_name)'; '(id_user, tag_name) VALUES (:id_user, :tag_name)';
@ -642,19 +622,9 @@ class PdoAddressBook
} }
catch (\Exception $oException) catch (\Exception $oException)
{ {
if ($this->isTransactionSupported())
{
$this->rollBack();
}
throw $oException; throw $oException;
} }
if ($this->isTransactionSupported())
{
$this->commit();
}
return $mResult; return $mResult;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long