Example #1
0
 function dispatch()
 {
     $module = Piwik_Common::getRequestVar('module', '', 'string');
     $updater = new Piwik_Updater();
     $updater->addComponentToCheck('core', Piwik_Version::VERSION);
     $updates = $updater->getComponentsWithNewVersion();
     if (!empty($updates)) {
         Piwik::deleteAllCacheOnUpdate();
     }
     if (self::getComponentUpdates($updater) !== null && $module != 'CoreUpdater' && $module != 'Proxy') {
         if (Piwik_FrontController::shouldRethrowException()) {
             throw new Exception("Piwik and/or some plugins have been upgraded to a new version. Please run the update process first. See documentation: http://piwik.org/docs/update/");
         } else {
             Piwik::redirectToModule('CoreUpdater');
         }
     }
 }
/**
 * Exception handler used to display nicely exceptions in Piwik
 * 
 * @param Exception $exception
 */
function Piwik_ExceptionHandler(Exception $exception)
{
    try {
        Zend_Registry::get('logger_exception')->logEvent($exception);
    } catch (Exception $e) {
        if (Piwik_FrontController::shouldRethrowException()) {
            throw $exception;
        }
        // case when the exception is raised before the logger being ready
        // we handle the exception a la mano, but using the Logger formatting properties
        $event = array();
        $event['errno'] = $exception->getCode();
        $event['message'] = $exception->getMessage();
        $event['errfile'] = $exception->getFile();
        $event['errline'] = $exception->getLine();
        $event['backtrace'] = $exception->getTraceAsString();
        $formatter = new Piwik_Log_Exception_Formatter_ScreenFormatter();
        $message = $formatter->format($event);
        $message .= "<br /><br />And this exception raised another exception \"" . $e->getMessage() . "\"";
        Piwik::exitWithErrorMessage($message);
    }
}