/** * @deprecated Since 5.0 * @return null */ function eZDisplayDebug() { $ini = eZINI::instance(); if ($ini->variable('DebugSettings', 'DebugOutput') != 'enabled') { return null; } $scriptStopTime = microtime(true); $type = $ini->variable("DebugSettings", "Debug"); //eZDebug::setHandleType( eZDebug::HANDLE_NONE ); if ($type == "inline" or $type == "popup") { $asHtml = true; if ($ini->variable("DebugSettings", "DebugToolbar") == 'enabled' && $ini->variable("SiteAccessSettings", "CheckValidity") !== 'true' && $asHtml == true && !$GLOBALS['eZRedirection']) { $tpl = eZTemplate::factory(); $result = "<tr><td colspan='2'>" . $tpl->fetch('design:setup/debug_toolbar.tpl') . "</td></tr>"; eZDebug::appendTopReport("Debug toolbar", $result); } eZDebug::appendBottomReport('Template Usage Statistics', eZTemplatesStatisticsReporter::generateStatistics($asHtml)); eZDebug::setScriptStop($scriptStopTime); return eZDebug::printReport($type == "popup", $asHtml, true, false, true, true, $ini->variable("DebugSettings", "DisplayIncludedFiles") == 'enabled'); } return null; }
function multipleezjscServerCalls($calls, $contentType = 'json') { $r = array(); foreach ($calls as $key => $call) { $response = array('error_text' => '', 'content' => ''); if ($call instanceof ezjscServerRouter) { try { $response['content'] = $call->call(); } catch (Exception $e) { $response['error_text'] = $e->getMessage(); } } else { $response['error_text'] = 'Not a valid ezjscServerRouter argument: "' . htmlentities($call, ENT_QUOTES) . '"'; } $r[] = ezjscAjaxContent::autoEncode($response, $contentType); } return $r; } if ($debugOutput && ($contentType === 'xml' || $contentType === 'xhtml')) { echo "<!--\r\n"; eZDebug::printReport(false, false); echo "\r\n-->"; } else { if ($debugOutput && $contentType === 'json') { echo "/*\r\n"; eZDebug::printReport(false, false); echo "\r\n*/"; } } eZDB::checkTransactionCounter(); eZExecution::cleanExit();
/** * This is called whenever an error occurs in one of the database handlers. * * If a transaction is active it will be invalidated as well. * * @access protected * @throws eZDBException */ function reportError() { // If we have a running transaction we must mark as invalid // in which case a call to commit() will perform a rollback if ($this->TransactionCounter > 0) { $this->invalidateTransaction(); // This is the unique ID for this incidence which will also be placed in the error logs. $transID = 'TRANSID-' . md5(time() . mt_rand()); eZDebug::writeError('Transaction in progress failed due to DB error, transaction was rollbacked. Transaction ID is ' . $transID . '.', 'eZDBInterface::commit ' . $transID); $this->rollback(); if ($this->errorHandling == eZDB::ERROR_HANDLING_EXCEPTIONS) { throw new eZDBException($this->ErrorMessage, $this->ErrorNumber); } else { // Stop execution immediately while allowing other systems (session etc.) to cleanup eZExecution::cleanup(); eZExecution::setCleanExit(); // Give some feedback, and also possibly show the debug output eZDebug::setHandleType(eZDebug::HANDLE_NONE); $ini = eZINI::instance(); $adminEmail = $ini->variable('MailSettings', 'AdminEmail'); if (!eZSys::isShellExecution()) { if (!headers_sent()) { header("HTTP/1.1 500 Internal Server Error"); } $site = eZSys::serverVariable('HTTP_HOST'); $uri = eZSys::serverVariable('REQUEST_URI'); print "<div class=\"fatal-error\" style=\""; print 'margin: 0.5em 0 1em 0; ' . 'padding: 0.25em 1em 0.75em 1em;' . 'border: 4px solid #000000;' . 'background-color: #f8f8f4;' . 'border-color: #f95038;" >'; print "<b>Fatal error</b>: A database transaction in eZ Publish failed.<br/>"; print "<p>"; print "The current execution was stopped to prevent further problems.<br/>\n" . "You should contact the <a href=\"mailto:{$adminEmail}?subject=Transaction failed on {$site} and URI {$uri} with ID {$transID}\">System Administrator</a> of this site with the information on this page.<br/>\n" . "The current transaction ID is <b>{$transID}</b> and has been logged.<br/>\n" . "Please include the transaction ID and the current URL when contacting the system administrator.<br/>\n"; print "</p>"; print "</div>"; $templateResult = null; if (function_exists('eZDisplayResult')) { eZDisplayResult($templateResult); } } else { fputs(STDERR, "Fatal error: A database transaction in eZ Publish failed.\n"); fputs(STDERR, "\n"); fputs(STDERR, "The current execution was stopped to prevent further problems.\n" . "You should contact the System Administrator ({$adminEmail}) of this site.\n" . "The current transaction ID is {$transID} and has been logged.\n" . "Please include the transaction ID and the name of the current script when contacting the system administrator.\n"); fputs(STDERR, "\n"); fputs(STDERR, eZDebug::printReport(false, false, true)); } // PHP execution stops here exit(1); } } }
function shutdown($exitCode = false, $exitText = false) { $cli = eZCLI::instance(); if (class_exists('eZDB') and eZDB::hasInstance()) { $db = eZDB::instance(false, array('show_errors' => false)); // Perform transaction check $transactionCounterCheck = eZDB::checkTransactionCounter(); if (isset($transactionCounterCheck['error'])) { $cli->error($transactionCounterCheck['error']); } if ($this->UseSession and $db->isConnected()) { eZUser::logoutCurrent(); eZSession::remove(); } } $webOutput = $cli->isWebOutput(); if ($this->UseDebugOutput or eZDebug::isDebugEnabled()) { if ($this->DebugMessage) { fputs(STDERR, $this->DebugMessage); } fputs(STDERR, eZDebug::printReport(false, $webOutput, true, $this->AllowedDebugLevels, $this->UseDebugAccumulators, $this->UseDebugTimingPoints, $this->UseIncludeFiles)); } eZExecution::cleanup(); eZExecution::setCleanExit(); $this->setIsInitialized(false); if ($exitCode !== false) { $this->ExitCode = $exitCode; } if ($this->ExitCode !== false) { if ($exitText !== false) { $cli->output($exitText); } exit($this->ExitCode); } }