本文整理汇总了PHP中XenForo_Db::rollbackAll方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Db::rollbackAll方法的具体用法?PHP XenForo_Db::rollbackAll怎么用?PHP XenForo_Db::rollbackAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Db
的用法示例。
在下文中一共展示了XenForo_Db::rollbackAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: likeContent
public function likeContent($contentType, $contentId, $contentUserId, $likeUserId = null, $likeDate = null)
{
// hoist bits out of the Like Transaction
SV_DeadlockAvoidance_DataWriter::enterTransaction();
$ret = false;
try {
$ret = parent::likeContent($contentType, $contentId, $contentUserId, $likeUserId, $likeDate);
} catch (Zend_Db_Statement_Mysqli_Exception $e) {
SV_DeadlockAvoidance_DataWriter::exitTransaction(false);
@XenForo_Db::rollbackAll();
// something went wrong, retry
if (stripos($e->getMessage(), "Deadlock found when trying to get lock; try restarting transaction") !== false) {
SV_DeadlockAvoidance_DataWriter::enterTransaction();
$ret = parent::likeContent($contentType, $contentId, $contentUserId, $likeUserId, $likeDate);
} else {
throw $e;
}
} finally {
SV_DeadlockAvoidance_DataWriter::exitTransaction($ret);
}
return $ret;
}
示例2: logException
public static function logException(Exception $e, $rollbackTransactions = true)
{
try {
$db = XenForo_Application::get('db');
if ($db->getConnection()) {
$rootDir = XenForo_Application::getInstance()->getRootDir();
$file = $e->getFile();
if (strpos($file, $rootDir) === 0) {
$file = substr($file, strlen($rootDir));
if (strlen($file) && ($file[0] == '/' || $file[0] == '\\')) {
$file = substr($file, 1);
}
}
$requestPaths = XenForo_Application::get('requestPaths');
$request = array('url' => $requestPaths['fullUri'], '_GET' => $_GET, '_POST' => $_POST);
if ($rollbackTransactions) {
XenForo_Db::rollbackAll($db);
}
$db->insert('xf_error_log', array('exception_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::hasInstance() ? XenForo_Visitor::getUserId() : null, 'ip_address' => XenForo_Model::create('XenForo_Model_Login')->convertIpToLong(), 'exception_type' => get_class($e), 'message' => $e->getMessage(), 'filename' => $file, 'line' => $e->getLine(), 'trace_string' => $e->getTraceAsString(), 'request_state' => serialize($request)));
}
} catch (Exception $e) {
}
}
示例3: runDeferred
public function runDeferred(array $deferred, $targetRunTime, &$status, &$canCancel)
{
$this->resetUniqueDeferInserts();
$canCancel = false;
if (!$this->deleteDeferredById($deferred['deferred_id'])) {
// already being run
return false;
}
$runner = XenForo_Deferred_Abstract::create($deferred['execute_class']);
if (!$runner) {
return false;
}
$data = unserialize($deferred['execute_data']);
if (!self::$_shutdownRegistered) {
self::$_shutdownRegistered = true;
register_shutdown_function(array(__CLASS__, 'shutdownHandleFatalDeferred'));
}
self::$_runningDeferred = $deferred;
try {
$output = $runner->execute($deferred, $data, $targetRunTime, $status);
self::$_runningDeferred = false;
} catch (Exception $e) {
self::$_runningDeferred = false;
// transactions are likely from the manual runner, so we need to roll them back
// as they probably won't be committed
XenForo_Db::rollbackAll();
if ($deferred['manual_execute']) {
// reinsert and throw so a refresh will catch it
XenForo_Application::defer($deferred['execute_class'], $data, $deferred['unique_key'], $deferred['manual_execute'], $deferred['trigger_date'], true);
throw $e;
} else {
// log and ignore
XenForo_Error::logException($e, false);
$output = false;
$status = "{$deferred['execute_class']} threw exception. See error log.";
// TODO: phrase?
}
}
if ($output === 'exit') {
// this is for debugging - restore to previous state
XenForo_Db::rollbackAll();
XenForo_Application::defer($deferred['execute_class'], $data, $deferred['unique_key'], $deferred['manual_execute'], $deferred['trigger_date'], true);
exit;
} else {
if (is_array($output)) {
$canCancel = $runner->canCancel();
return XenForo_Application::defer($deferred['execute_class'], $output, $deferred['unique_key'], $deferred['manual_execute'], $deferred['trigger_date'], true);
} else {
return false;
}
}
}
示例4: logException
public static function logException($e, $rollbackTransactions = true, $messagePrefix = '')
{
$isValidArg = $e instanceof Exception || $e instanceof Throwable;
if (!$isValidArg) {
throw new Exception("logException requires an Exception or a Throwable");
}
try {
$db = XenForo_Application::getDb();
if ($db->getConnection()) {
if ($rollbackTransactions) {
@XenForo_Db::rollbackAll($db);
}
$dbVersionId = @$db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
// do not log errors when an upgrade is pending
return;
}
if (!file_exists(XenForo_Helper_File::getInternalDataPath() . '/install-lock.php')) {
// install hasn't finished yet, don't write
return;
}
$rootDir = XenForo_Application::getInstance()->getRootDir();
$file = $e->getFile();
if (strpos($file, $rootDir) === 0) {
$file = substr($file, strlen($rootDir));
if (strlen($file) && ($file[0] == '/' || $file[0] == '\\')) {
$file = substr($file, 1);
}
}
$requestPaths = XenForo_Application::get('requestPaths');
$request = array('url' => $requestPaths['fullUri'], '_GET' => $_GET, '_POST' => $_POST);
// don't log passwords
foreach ($request['_POST'] as $key => &$value) {
if (strpos($key, 'password') !== false || $key == '_xfToken') {
$value = '********';
}
}
$db->insert('xf_error_log', array('exception_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::hasInstance() ? XenForo_Visitor::getUserId() : null, 'ip_address' => XenForo_Helper_Ip::getBinaryIp(), 'exception_type' => get_class($e), 'message' => $messagePrefix . $e->getMessage(), 'filename' => $file, 'line' => $e->getLine(), 'trace_string' => $e->getTraceAsString(), 'request_state' => serialize($request)));
}
} catch (Exception $e) {
}
}