Development

Changeset 6551

You must first sign up to be able to contribute.

Changeset 6551

Show
Ignore:
Timestamp:
12/17/07 19:48:03 (1 year ago)
Author:
fabien
Message:

merged trunk (to r6550)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/action/sfAction.class.php

    r6223 r6551  
    6565   * 
    6666   */ 
    67   public function forward404($message = ''
    68   { 
    69     throw new sfError404Exception($message); 
     67  public function forward404($message = null
     68  { 
     69    throw new sfError404Exception($this->get404Message($message)); 
    7070  } 
    7171 
     
    7878   * @throws sfError404Exception 
    7979   */ 
    80   public function forward404Unless($condition, $message = ''
     80  public function forward404Unless($condition, $message = null
    8181  { 
    8282    if (!$condition) 
    8383    { 
    84       throw new sfError404Exception($message); 
     84      throw new sfError404Exception($this->get404Message($message)); 
    8585    } 
    8686  } 
     
    9494   * @throws sfError404Exception 
    9595   */ 
    96   public function forward404If($condition, $message = ''
     96  public function forward404If($condition, $message = null
    9797  { 
    9898    if ($condition) 
    9999    { 
    100       throw new sfError404Exception($message); 
     100      throw new sfError404Exception($this->get404Message($message)); 
    101101    } 
    102102  } 
     
    511511    sfConfig::set('mod_'.strtolower($this->getModuleName()).'_view_class', $class); 
    512512  } 
     513 
     514  /** 
     515   * Returns a formatted message for a 404 error. 
     516   * 
     517   * @param  string An error message (null by default) 
     518   * 
     519   * @return string The error message or a default one if null 
     520   */ 
     521  protected function get404Message($message = null) 
     522  { 
     523    return is_null($message) ? sprintf('This request has been forwarded to a 404 error page by the action "%s/%s".', $this->getModuleName(), $this->getActionName()) : $message; 
     524  } 
    513525} 
  • branches/1.1/lib/command/sfCommandLogger.class.php

    r6490 r6551  
    4040  { 
    4141    $priority = isset($event['priority']) ? $event['priority'] : self::INFO; 
     42    unset($event['priority']); 
    4243 
    4344    $prefix = ''; 
  • branches/1.1/lib/config/sfFactoryConfigHandler.class.php

    r6497 r6551  
    117117          { 
    118118            $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); 
     119            unset($parameters['database']); 
    119120          } 
    120121 
  • branches/1.1/lib/exception/sfError404Exception.class.php

    r5139 r6551  
    2424  public function printStackTrace() 
    2525  { 
     26    // log all exceptions in php log 
     27    $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 
     28    error_log($exception->getMessage()); 
     29 
    2630    if (sfConfig::get('sf_debug')) 
    2731    { 
     
    3236    else 
    3337    { 
     38      // log all exceptions in php log 
     39      if (!sfConfig::get('sf_test')) 
     40      { 
     41        error_log($this->getMessage()); 
     42      } 
     43 
    3444      sfContext::getInstance()->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action')); 
    3545    } 
  • branches/1.1/lib/exception/sfException.class.php

    r6513 r6551  
    4141  } 
    4242 
    43   public function setWrappedException($e) 
     43  /** 
     44   * Changes the wrapped exception. 
     45   * 
     46   * @param Exception An Exception instance 
     47   */ 
     48  public function setWrappedException(Exception $e) 
    4449  { 
    4550    $this->wrappedException = $e; 
     
    5156  public function printStackTrace() 
    5257  { 
     58    $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 
     59 
    5360    if (!sfConfig::get('sf_test')) 
    5461    { 
     62      // log all exceptions in php log 
     63      error_log($exception->getMessage()); 
     64 
    5565      // clean current output buffer 
    5666      while (@ob_end_clean()); 
     
    6373    try 
    6474    { 
    65       $this->outputStackTrace(); 
     75      $this->outputStackTrace($exception); 
    6676    } 
    6777    catch (Exception $e) 
     
    7888   * Gets the stack trace for this exception. 
    7989   */ 
    80   protected function outputStackTrace() 
    81   { 
    82     $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 
    83  
     90  static protected function outputStackTrace($exception) 
     91  { 
    8492    if (class_exists('sfContext', false) && sfContext::hasInstance()) 
    8593    { 
     
    8896      if (sfConfig::get('sf_logging_enabled')) 
    8997      { 
    90         $dispatcher->notify(new sfEvent($this, 'application.log', array($this->getMessage(), 'priority' => sfLogger::ERR))); 
    91       } 
    92  
    93       $event = $dispatcher->notifyUntil(new sfEvent($this, 'application.throw_exception', array('exception' => $exception))); 
     98        $dispatcher->notify(new sfEvent($exception, 'application.log', array($exception->getMessage(), 'priority' => sfLogger::ERR))); 
     99      } 
     100 
     101      $event = $dispatcher->notifyUntil(new sfEvent($exception, 'application.throw_exception')); 
    94102      if ($event->isProcessed()) 
    95103      { 
     
    108116    } 
    109117 
    110     $message = null !== $this->getMessage() ? $this->getMessage() : 'n/a'; 
    111     $name    = get_class($this); 
     118    $message = null !== $exception->getMessage() ? $exception->getMessage() : 'n/a'; 
     119    $name    = get_class($exception); 
    112120    $format  = 0 == strncasecmp(PHP_SAPI, 'cli', 3) ? 'plain' : 'html'; 
    113121    $traces  = self::getTraces($exception, $format); 
  • branches/1.1/lib/log/sfLogger.class.php

    r6490 r6551  
    217217  { 
    218218    $priority = isset($event['priority']) ? $event['priority'] : self::INFO; 
     219    unset($event['priority']); 
    219220    $subject  = $event->getSubject(); 
    220221    $subject  = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main'); 
  • branches/1.1/lib/storage/sfMySQLSessionStorage.class.php

    r4890 r6551  
    136136   * @throws <b>sfDatabaseException</b> If the session data cannot be written 
    137137   */ 
    138   public function sessionWrite($id, &$data) 
     138  public function sessionWrite($id, $data) 
    139139  { 
    140140    // get table/column 
  • branches/1.1/lib/storage/sfPostgreSQLSessionStorage.class.php

    r4890 r6551  
    136136   * @throws <b>sfDatabaseException</b> If the session data cannot be written 
    137137   */ 
    138   public function sessionWrite($id, &$data) 
     138  public function sessionWrite($id, $data) 
    139139  { 
    140140    // get table/column 
  • branches/1.1/lib/util/sfBrowser.class.php

    r6459 r6551  
    519519  } 
    520520 
    521   public function listenToException($event) 
     521  public function listenToException(sfEvent $event) 
    522522  { 
    523523    $this->currentException = $event->getSubject(); 
  • branches/1.1/test/other/tasksTest.php

    r6502 r6551  
    5858} 
    5959 
    60 $t = new lime_test(33, new lime_output_color()); 
     60$t = new lime_test(35, new lime_output_color()); 
    6161$c = new symfony_cmd(); 
    6262$c->initialize($t); 
     
    7474$t->ok(is_dir($c->tmp_dir.DS.'apps'.DS.'frontend'.DS.'modules'.DS.'foo'), '"generate:module" creates a "foo" directory under "modules" directory'); 
    7575 
     76copy(dirname(__FILE__).'/fixtures/propel/schema.yml', $c->tmp_dir.DS.'config'.DS.'schema.yml'); 
     77copy(dirname(__FILE__).'/fixtures/propel/databases.yml', $c->tmp_dir.DS.'config'.DS.'databases.yml'); 
     78copy(dirname(__FILE__).'/fixtures/propel/propel.ini', $c->tmp_dir.DS.'config'.DS.'propel.ini'); 
     79 
    7680// propel:* 
    77 copy(dirname(__FILE__).'/fixtures/propel/schema.yml', $c->tmp_dir.DS.'config'.DS.'schema.yml'); 
    78  
    7981$content = $c->execute_command('propel:build-sql'); 
    8082$t->ok(file_exists($c->tmp_dir.DS.'data'.DS.'sql'.DS.'lib.model.schema.sql'), '"propel:build-sql" creates a "schema.sql" file under "data/sql" directory'); 
     
    8284$content = $c->execute_command('propel:build-model'); 
    8385$t->ok(file_exists($c->tmp_dir.DS.'lib'.DS.'model'.DS.'Article.php'), '"propel:build-model" creates model classes under "lib/model" directory'); 
     86 
     87$c->execute_command('propel:insert-sql'); 
     88$file = dirname(__FILE__).DS.'..'.DS.'..'.DS.'lib'.DS.'plugins'.DS.'sfPropelPlugin'.DS.'lib'.DS.'vendor'.DS.'propel-generator'.DS.'database.sqlite'; 
     89$t->ok(file_exists($file), '"propel:insert-sql" creates tables in the database'); 
     90rename($file, $c->tmp_dir.'/data/database.sqlite'); 
    8491 
    8592$content = $c->execute_command('propel:init-crud frontend articleInitCrud Article');