Changeset 6551
- Timestamp:
- 12/17/07 19:48:03 (1 year ago)
- Files:
-
- branches/1.1/lib/action/sfAction.class.php (modified) (4 diffs)
- branches/1.1/lib/command/sfCommandLogger.class.php (modified) (1 diff)
- branches/1.1/lib/config/sfFactoryConfigHandler.class.php (modified) (1 diff)
- branches/1.1/lib/exception/sfError404Exception.class.php (modified) (2 diffs)
- branches/1.1/lib/exception/sfException.class.php (modified) (6 diffs)
- branches/1.1/lib/log/sfLogger.class.php (modified) (1 diff)
- branches/1.1/lib/storage/sfMySQLSessionStorage.class.php (modified) (1 diff)
- branches/1.1/lib/storage/sfPostgreSQLSessionStorage.class.php (modified) (1 diff)
- branches/1.1/lib/util/sfBrowser.class.php (modified) (1 diff)
- branches/1.1/test/other/fixtures/propel/databases.yml (added)
- branches/1.1/test/other/fixtures/propel/propel.ini (added)
- branches/1.1/test/other/tasksTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/action/sfAction.class.php
r6223 r6551 65 65 * 66 66 */ 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)); 70 70 } 71 71 … … 78 78 * @throws sfError404Exception 79 79 */ 80 public function forward404Unless($condition, $message = '')80 public function forward404Unless($condition, $message = null) 81 81 { 82 82 if (!$condition) 83 83 { 84 throw new sfError404Exception($ message);84 throw new sfError404Exception($this->get404Message($message)); 85 85 } 86 86 } … … 94 94 * @throws sfError404Exception 95 95 */ 96 public function forward404If($condition, $message = '')96 public function forward404If($condition, $message = null) 97 97 { 98 98 if ($condition) 99 99 { 100 throw new sfError404Exception($ message);100 throw new sfError404Exception($this->get404Message($message)); 101 101 } 102 102 } … … 511 511 sfConfig::set('mod_'.strtolower($this->getModuleName()).'_view_class', $class); 512 512 } 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 } 513 525 } branches/1.1/lib/command/sfCommandLogger.class.php
r6490 r6551 40 40 { 41 41 $priority = isset($event['priority']) ? $event['priority'] : self::INFO; 42 unset($event['priority']); 42 43 43 44 $prefix = ''; branches/1.1/lib/config/sfFactoryConfigHandler.class.php
r6497 r6551 117 117 { 118 118 $defaultParameters[] = sprintf("'database' => \$this->getDatabaseManager()->getDatabase('%s'),", isset($parameters['database']) ? $parameters['database'] : 'default'); 119 unset($parameters['database']); 119 120 } 120 121 branches/1.1/lib/exception/sfError404Exception.class.php
r5139 r6551 24 24 public function printStackTrace() 25 25 { 26 // log all exceptions in php log 27 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 28 error_log($exception->getMessage()); 29 26 30 if (sfConfig::get('sf_debug')) 27 31 { … … 32 36 else 33 37 { 38 // log all exceptions in php log 39 if (!sfConfig::get('sf_test')) 40 { 41 error_log($this->getMessage()); 42 } 43 34 44 sfContext::getInstance()->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action')); 35 45 } branches/1.1/lib/exception/sfException.class.php
r6513 r6551 41 41 } 42 42 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) 44 49 { 45 50 $this->wrappedException = $e; … … 51 56 public function printStackTrace() 52 57 { 58 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 59 53 60 if (!sfConfig::get('sf_test')) 54 61 { 62 // log all exceptions in php log 63 error_log($exception->getMessage()); 64 55 65 // clean current output buffer 56 66 while (@ob_end_clean()); … … 63 73 try 64 74 { 65 $this->outputStackTrace( );75 $this->outputStackTrace($exception); 66 76 } 67 77 catch (Exception $e) … … 78 88 * Gets the stack trace for this exception. 79 89 */ 80 protected function outputStackTrace() 81 { 82 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 83 90 static protected function outputStackTrace($exception) 91 { 84 92 if (class_exists('sfContext', false) && sfContext::hasInstance()) 85 93 { … … 88 96 if (sfConfig::get('sf_logging_enabled')) 89 97 { 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')); 94 102 if ($event->isProcessed()) 95 103 { … … 108 116 } 109 117 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); 112 120 $format = 0 == strncasecmp(PHP_SAPI, 'cli', 3) ? 'plain' : 'html'; 113 121 $traces = self::getTraces($exception, $format); branches/1.1/lib/log/sfLogger.class.php
r6490 r6551 217 217 { 218 218 $priority = isset($event['priority']) ? $event['priority'] : self::INFO; 219 unset($event['priority']); 219 220 $subject = $event->getSubject(); 220 221 $subject = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main'); branches/1.1/lib/storage/sfMySQLSessionStorage.class.php
r4890 r6551 136 136 * @throws <b>sfDatabaseException</b> If the session data cannot be written 137 137 */ 138 public function sessionWrite($id, &$data)138 public function sessionWrite($id, $data) 139 139 { 140 140 // get table/column branches/1.1/lib/storage/sfPostgreSQLSessionStorage.class.php
r4890 r6551 136 136 * @throws <b>sfDatabaseException</b> If the session data cannot be written 137 137 */ 138 public function sessionWrite($id, &$data)138 public function sessionWrite($id, $data) 139 139 { 140 140 // get table/column branches/1.1/lib/util/sfBrowser.class.php
r6459 r6551 519 519 } 520 520 521 public function listenToException( $event)521 public function listenToException(sfEvent $event) 522 522 { 523 523 $this->currentException = $event->getSubject(); branches/1.1/test/other/tasksTest.php
r6502 r6551 58 58 } 59 59 60 $t = new lime_test(3 3, new lime_output_color());60 $t = new lime_test(35, new lime_output_color()); 61 61 $c = new symfony_cmd(); 62 62 $c->initialize($t); … … 74 74 $t->ok(is_dir($c->tmp_dir.DS.'apps'.DS.'frontend'.DS.'modules'.DS.'foo'), '"generate:module" creates a "foo" directory under "modules" directory'); 75 75 76 copy(dirname(__FILE__).'/fixtures/propel/schema.yml', $c->tmp_dir.DS.'config'.DS.'schema.yml'); 77 copy(dirname(__FILE__).'/fixtures/propel/databases.yml', $c->tmp_dir.DS.'config'.DS.'databases.yml'); 78 copy(dirname(__FILE__).'/fixtures/propel/propel.ini', $c->tmp_dir.DS.'config'.DS.'propel.ini'); 79 76 80 // propel:* 77 copy(dirname(__FILE__).'/fixtures/propel/schema.yml', $c->tmp_dir.DS.'config'.DS.'schema.yml');78 79 81 $content = $c->execute_command('propel:build-sql'); 80 82 $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'); … … 82 84 $content = $c->execute_command('propel:build-model'); 83 85 $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'); 90 rename($file, $c->tmp_dir.'/data/database.sqlite'); 84 91 85 92 $content = $c->execute_command('propel:init-crud frontend articleInitCrud Article');