Exemplo n.º 1
0
 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->getContext()->getLogger()->info('{sfController} dispatch request');
         }
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->getContext()->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         $e->printStackTrace();
     } catch (Exception $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         try {
             // wrap non symfony exceptions
             $sfException = new sfException();
             $sfException->printStackTrace($e);
         } catch (Exception $e) {
             header('HTTP/1.0 500 Internal Server Error');
         }
     }
 }
 /**
  * Dispatches a request.
  *
  * @param string A module name
  * @param string An action name
  * @param array  An associative array of parameters to be set
  */
 public function dispatch($moduleName, $actionName, $parameters = array())
 {
     try {
         // set parameters
         $this->getContext()->getRequest()->getParameterHolder()->add($parameters);
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         // wrap non symfony exceptions
         $sfException = new sfException();
         $sfException->printStackTrace($e);
     }
 }
  /**
   * Forwards to the 404 action.
   */
  public function printStackTrace()
  {
    $exception = null === $this->wrappedException ? $this : $this->wrappedException;

    if (sfConfig::get('sf_debug'))
    {
      $response = sfContext::getInstance()->getResponse();
      if (null === $response)
      {
        $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher());
        sfContext::getInstance()->setResponse($response);
      }

      $response->setStatusCode(404);

      return parent::printStackTrace();
    }
    else
    {
      // log all exceptions in php log
      if (!sfConfig::get('sf_test'))
      {
        error_log($this->getMessage());
      }

      sfContext::getInstance()->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action'));
    }
  }
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     if (method_exists($this, 'setName')) {
         $this->setName('sfWebBrowserInvalidResponseException');
     }
     parent::__construct($message, $code);
 }
 public function __construct($code, $message, $file, $line, $context = null)
 {
     parent::__construct($message, $code);
     $this->context = $context;
     $this->file = $file;
     $this->line = $line;
 }
Exemplo n.º 6
0
 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         if (empty($moduleName) || empty($actionName)) {
             throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
         }
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfError404Exception $e) {
         if (!sfConfig::get('sf_web_debug')) {
             $this->forward('dmFront', 'error404');
         } else {
             $e->printStackTrace();
         }
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
 /**
  * Forwards to the error action.
  */
 public function printStackTrace()
 {
     $exception = is_null($this->wrappedException) ? $this : $this->wrappedException;
     if (sfConfig::get('sf_debug')) {
         $response = sfContext::getInstance()->getResponse();
         if (is_null($response)) {
             $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher());
             sfContext::getInstance()->setResponse($response);
         }
         $response->setStatusCode($this->httpStatusCode);
         return sfException::printStackTrace();
         // skip sfError404Exception::printStackTrace()
     } else {
         // log all exceptions in php log
         if (!sfConfig::get('sf_test')) {
             error_log($this->getMessage());
         }
         if ($this->getMessage()) {
             sfContext::getInstance()->getRequest()->setParameter('error_message', $this->getMessage());
         }
         $module = sfConfig::get('sf_error_' . $this->httpStatusCode . '_module', sfConfig::get('sf_error_404_module', 'default'));
         $action = sfConfig::get('sf_error_' . $this->httpStatusCode . '_action', sfConfig::get('sf_error_404_action', 'error'));
         sfContext::getInstance()->getController()->forward($module, $action);
     }
 }
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     if ($this->getName() === null) {
         $this->setName('deppPropelActAsLaunchableException');
     }
     parent::__construct($message, $code);
 }
 /**
  * Class constructor.
  *
  * @param	string	the error message
  * @param	int		the error code
  */
 public function __construct($message = null, $code = 0)
 {
     // jme- removed this function. it doesnt exist
     // - in sfExceptions.php you can find
     //   - name    = get_class($exception);
     // $this->setName('sfDateTimeException');
     parent::__construct($message, $code);
 }
 /**
  * Class constructor.
  *
  * @param string error message
  * @param int error code
  */
 public function __construct($message = null, $code = 0)
 {
     // Legacy support for 1.0
     if (method_exists($this, 'setName')) {
         $this->setName('sfImageTransformException');
     }
     parent::__construct($message, $code);
 }
Exemplo n.º 11
0
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     $this->setName('sfStopException');
     // disable xdebug to avoid backtrace in error log
     if (function_exists('xdebug_disable')) {
         xdebug_disable();
     }
     parent::__construct($message, $code);
 }
Exemplo n.º 12
0
 /**
  *
  */
 public function __construct($message = null, $http_error_code = 0)
 {
     $this->setName('HttpException');
     try {
         sfContext::getInstance()->getLogger()->err($message);
     } catch (Exception $e) {
     }
     parent::__construct($message, $http_error_code);
 }
 /**
  * Dispatches a request.
  *
  * @param string $moduleName  A module name
  * @param string $actionName  An action name
  * @param array  $parameters  An associative array of parameters to be set
  */
 public function dispatch($moduleName, $actionName, $parameters = array())
 {
     try {
         // set parameters
         $this->context->getRequest()->getParameterHolder()->add($parameters);
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
Exemplo n.º 14
0
 /**
  * Initializes the current sfContext instance.
  *
  * @param sfApplicationConfiguration $configuration  An sfApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->configuration = $configuration;
     $this->dispatcher = $configuration->getEventDispatcher();
     try {
         $this->loadFactories();
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
     $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
     // register our shutdown function
     register_shutdown_function(array($this, 'shutdown'));
 }
  /**
   * Outputs some debug information about the current response.
   *
   * @param string $realOutput Whether to display the actual content of the response when an error occurred
   *                           or the exception message and the stack trace to ease debugging
   */
  public function debug($realOutput = false)
  {
    print $this->tester->error('Response debug');

    if (!$realOutput && null !== sfException::getLastException())
    {
      // print the exception and the stack trace instead of the "normal" output
      $this->tester->comment('WARNING');
      $this->tester->comment('An error occurred when processing this request.');
      $this->tester->comment('The real response content has been replaced with the exception message to ease debugging.');
    }

    printf("HTTP/1.X %s\n", $this->response->getStatusCode());

    foreach ($this->response->getHttpHeaders() as $name => $value)
    {
      printf("%s: %s\n", $name, $value);
    }

    foreach ($this->response->getCookies() as $cookie)
    {
      vprintf("Set-Cookie: %s=%s; %spath=%s%s%s%s\n", array(
        $cookie['name'],
        $cookie['value'],
        null === $cookie['expire'] ? '' : sprintf('expires=%s; ', date('D d-M-Y H:i:s T', $cookie['expire'])),
        $cookie['path'],
        $cookie['domain'] ? sprintf('; domain=%s', $cookie['domain']) : '',
        $cookie['secure'] ? '; secure' : '',
        $cookie['httpOnly'] ? '; HttpOnly' : '',
      ));
    }

    echo "\n";
    if (!$realOutput && null !== $exception = sfException::getLastException())
    {
      echo $exception;
    }
    else
    {
      echo $this->response->getContent();
    }
    echo "\n";
  }
 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Dispatch request')));
         }
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         if (empty($moduleName) || empty($actionName)) {
             throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
         }
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
Exemplo n.º 17
0
 /**
  * Executes a basic pre-render check to verify all required variables exist
  * and that the template is readable.
  *
  * @throws sfRenderException If the pre-render check fails
  */
 protected function preRenderCheck()
 {
     if (null === $this->template) {
         // a template has not been set
         throw new sfRenderException('A template has not been set.');
     }
     if (!is_readable($this->directory . '/' . $this->template)) {
         // 404?
         if ('404' == $this->context->getResponse()->getStatusCode()) {
             // use default exception templates
             $this->template = sfException::getTemplatePathForError($this->context->getRequest()->getRequestFormat(), false);
             $this->directory = dirname($this->template);
             $this->template = basename($this->template);
             $this->setAttribute('code', '404');
             $this->setAttribute('text', 'Not Found');
         } else {
             throw new sfRenderException(sprintf('The template "%s" does not exist or is unreadable in "%s".', $this->template, $this->directory));
         }
     }
     // check to see if this is a decorator template
     if ($this->decorator && !is_readable($this->decoratorDirectory . '/' . $this->decoratorTemplate)) {
         throw new sfRenderException(sprintf('The decorator template "%s" does not exist or is unreadable in "%s".', $this->decoratorTemplate, $this->decoratorDirectory));
     }
 }
Exemplo n.º 18
0
<?php

include sfException::getTemplatePathForError('xml', false);
Exemplo n.º 19
0
 /**
  * Tries to load a class that has been specified in autoload.yml.
  *
  * @param  string  $class  A class name.
  *
  * @return boolean Returns true if the class has been loaded
  */
 public function loadClass($class)
 {
     $class = strtolower($class);
     // class already exists
     if (class_exists($class, false) || interface_exists($class, false)) {
         return true;
     }
     // we have a class path, let's include it
     if (isset($this->classes[$class])) {
         try {
             require $this->classes[$class];
         } catch (sfException $e) {
             $e->printStackTrace();
         } catch (Exception $e) {
             sfException::createFromException($e)->printStackTrace();
         }
         return true;
     }
     // see if the file exists in the current module lib directory
     if (sfContext::hasInstance() && ($module = sfContext::getInstance()->getModuleName()) && isset($this->classes[$module . '/' . $class])) {
         try {
             require $this->classes[$module . '/' . $class];
         } catch (sfException $e) {
             $e->printStackTrace();
         } catch (Exception $e) {
             sfException::createFromException($e)->printStackTrace();
         }
         return true;
     }
     return false;
 }
Exemplo n.º 20
0
 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->getContext()->getLogger()->info('{sfController} dispatch request');
         }
         sfFilter::$filterCalled = array();
         $request = $this->getContext()->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         $e->printStackTrace();
     } catch (Exception $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         try {
             $sfException = new sfException($e->getMessage());
             $sfException->printStackTrace($e);
         } catch (Exception $e) {
             header('HTTP/1.0 500 Internal Server Error');
         }
     }
 }
Exemplo n.º 21
0
 /**
  * Resets the current exception.
  */
 public function resetCurrentException()
 {
     $this->currentException = null;
     sfException::clearLastException();
 }
Exemplo n.º 22
0
 /**
  * Sets the wrapped exception.
  *
  * @param Exception $e An Exception instance
  */
 public function setWrappedException(Exception $e)
 {
     $this->wrappedException = $e;
     self::$lastException = $e;
 }
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     $this->setName('sfInitializationException');
     parent::__construct($message, $code);
 }
Exemplo n.º 24
0
    error_reporting(sfConfig::get('sf_error_reporting'));
    // create bootstrap file for next time
    if (!sfConfig::get('sf_in_bootstrap') && !$sf_debug && !sfConfig::get('sf_test')) {
        $configCache->checkConfig($sf_app_config_dir_name . '/bootstrap_compile.yml');
    }
    // required core classes for the framework
    // create a temp var to avoid substitution during compilation
    if (!$sf_debug && !sfConfig::get('sf_test')) {
        $core_classes = $sf_app_config_dir_name . '/core_compile.yml';
        $configCache->import($core_classes, false);
    }
    $configCache->import($sf_app_config_dir_name . '/php.yml', false);
    $configCache->import($sf_app_config_dir_name . '/routing.yml', false);
    // include all config.php from plugins
    sfLoader::loadPluginConfig();
    // compress output
    ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
} catch (sfException $e) {
    $e->printStackTrace();
} catch (Exception $e) {
    if (sfConfig::get('sf_test')) {
        throw $e;
    }
    try {
        // wrap non symfony exceptions
        $sfException = new sfException();
        $sfException->printStackTrace($e);
    } catch (Exception $e) {
        header('HTTP/1.0 500 Internal Server Error');
    }
}
 public function dispatch()
 {
     try {
         sfFilter::$filterCalled = array();
         $request = $this->context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         if (empty($moduleName) || empty($actionName)) {
             throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
         }
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
Exemplo n.º 26
0
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     $this->setName('sfError404Exception');
     parent::__construct($message, $code);
 }
Exemplo n.º 27
0
 /**
  * Clears the $lastException property (added for #6342)
  */
 public static function clearLastException()
 {
     self::$lastException = null;
 }
Exemplo n.º 28
0
<?php

if ('500' != $sf_error_log->getType()) {
    return;
}
?>

<?php 
$e = new sfException();
$traces = $e->getTraces($sf_error_log->getExceptionObject(), 'html');
?>

<style>
  #main { font: 11px Verdana, Arial, sans-serif; color: #333 }
  ul { list-style: decimal }
  ul li { padding-bottom: 5px; margin: 0 }
  ol { font-family: monospace; white-space: pre; list-style-position: inside; margin: 0; padding: 10px 0 }
  ol li { margin: -5px; padding: 0 }
  ol .selected { font-weight: bold; background-color: #ddd; padding: 2px 0 }
</style>

<script type="text/javascript">
function toggle(id)
{
  el = document.getElementById(id); el.style.display = el.style.display == 'none' ? 'block' : 'none';
}
</script>

<ul id="main">
  <li><?php 
echo implode("</li>\n<li>", $traces);
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     parent::__construct($message, $code);
     $this->setName('sfContextException');
 }
Exemplo n.º 30
0
 /**
  * Handles autoloading of classes.
  *
  * @param  string $class A class name.
  *
  * @return boolean Returns true if the class has been loaded
  */
 public function autoload($class)
 {
     $class = strtolower($class);
     // class already exists
     if (class_exists($class, false) || interface_exists($class, false)) {
         return true;
     }
     // we have a class path, let's include it
     if (isset($this->classes[$class])) {
         try {
             require $this->classes[$class];
         } catch (sfException $e) {
             $e->printStackTrace();
         } catch (Exception $e) {
             sfException::createFromException($e)->printStackTrace();
         }
         return true;
     }
     return false;
 }