Skip to content
Extraits de code Groupes Projets
Valider 0563a808 rédigé par mattab's avatar mattab
Parcourir les fichiers

Fixing last test

parent 469aa03f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -212,6 +212,7 @@ class Piwik_Tracker
try {
if ($this->isVisitValid()) {
self::connectDatabaseIfNotConnected();
$visit = $this->getNewVisitObject();
......@@ -226,6 +227,7 @@ class Piwik_Tracker
printDebug("The request is invalid: empty request, or maybe tracking is disabled in the config.ini.php via record_statistics=0");
}
} catch (Piwik_Tracker_Db_Exception $e) {
$this->outputTransparentGif();
printDebug("<b>" . $e->getMessage() . "</b>");
$this->exitWithException($e, $isAuthenticated);
} catch (Piwik_Tracker_Visit_Excluded $e) {
......@@ -373,19 +375,29 @@ class Piwik_Tracker
if ($this->usingBulkTracking) {
// when doing bulk tracking we return JSON so the caller will know how many succeeded
$result = array('succeeded' => $this->countOfLoggedRequests);
// send error when in debug mode or when authenticated (which happens when doing log importing,
// for example)
if ((isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) || $authenticated) {
$result['error'] = Piwik_Tracker_GetErrorMessage($e);
}
echo Piwik_Common::json_encode($result);
exit;
}
if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) {
Piwik_Common::sendHeader('Content-Type: text/html; charset=utf-8');
$trailer = '<span style="color: #888888">Backtrace:<br /><pre>' . $e->getTraceAsString() . '</pre></span>';
$headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Zeitgeist/templates/simpleLayoutHeader.tpl');
$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Zeitgeist/templates/simpleLayoutFooter.tpl');
$headerPage = str_replace('{$HTML_TITLE}', 'Piwik &rsaquo; Error', $headerPage);
echo $headerPage . '<p>' . Piwik_Tracker_GetErrorMessage($e) . '</p>' . $trailer . $footerPage;
} // If not debug, but running authenticated (eg. during log import) then we display raw errors
elseif ($authenticated) {
Piwik_Common::sendHeader('Content-Type: text/html; charset=utf-8');
echo Piwik_Tracker_GetErrorMessage($e);
} else {
Piwik_Tracker_ExitWithException($e, $authenticated);
$this->outputTransparentGif();
}
exit;
}
/**
......@@ -431,7 +443,7 @@ class Piwik_Tracker
case self::STATE_NOSCRIPT_REQUEST:
case self::STATE_NOTHING_TO_NOTICE:
default:
$this->outputTransparentGif();
$this->outputTransparentGif();
printDebug("Nothing to notice => default behaviour");
break;
}
......@@ -749,28 +761,3 @@ function Piwik_Tracker_GetErrorMessage($e)
return $e->getMessage();
}
}
/**
* Displays exception in a friendly UI and exits.
*
* @param Exception $e
* @param bool $authenticated
*/
function Piwik_Tracker_ExitWithException($e, $authenticated = false)
{
Piwik_Common::sendHeader('Content-Type: text/html; charset=utf-8');
if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) {
$trailer = '<span style="color: #888888">Backtrace:<br /><pre>' . $e->getTraceAsString() . '</pre></span>';
$headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Zeitgeist/templates/simpleLayoutHeader.tpl');
$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Zeitgeist/templates/simpleLayoutFooter.tpl');
$headerPage = str_replace('{$HTML_TITLE}', 'Piwik &rsaquo; Error', $headerPage);
echo $headerPage . '<p>' . Piwik_Tracker_GetErrorMessage($e) . '</p>' . $trailer . $footerPage;
} // If not debug, but running authenticated (eg. during log import) then we display raw errors
elseif ($authenticated) {
echo Piwik_Tracker_GetErrorMessage($e);
}
exit;
}
......@@ -7,7 +7,7 @@
*
* @package Piwik
*/
$GLOBALS['PIWIK_TRACKER_DEBUG'] = !false;
$GLOBALS['PIWIK_TRACKER_DEBUG'] = false;
$GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = false;
define('PIWIK_ENABLE_TRACKING', true);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter