Changeset 6522
- Timestamp:
- 12/16/07 13:23:03 (10 months ago)
- Files:
-
- trunk/lib/action/sfAction.class.php (modified) (2 diffs)
- trunk/lib/controller/sfConsoleController.class.php (modified) (1 diff)
- trunk/lib/controller/sfFrontWebController.class.php (modified) (1 diff)
- trunk/lib/exception/sfError404Exception.class.php (modified) (1 diff)
- trunk/lib/exception/sfException.class.php (modified) (7 diffs)
- trunk/lib/exception/sfStopException.class.php (modified) (1 diff)
- trunk/lib/filter/sfBasicSecurityFilter.class.php (modified) (2 diffs)
- trunk/lib/plugins/sfPropelPlugin/test/functional/browseTest.php (modified) (1 diff)
- trunk/lib/util/sfCore.class.php (modified) (1 diff)
- trunk/test/functional/genericTest.php (modified) (1 diff)
- trunk/test/functional/sfTestBrowserTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/action/sfAction.class.php
r6516 r6522 131 131 132 132 $this->getController()->forward($module, $action); 133 $this->getResponse()->send();134 133 135 134 throw new sfStopException(); … … 191 190 { 192 191 $this->getController()->redirect($url, 0, $statusCode); 193 $this->getResponse()->send();194 192 195 193 throw new sfStopException(); trunk/lib/controller/sfConsoleController.class.php
r5139 r6522 36 36 catch (sfException $e) 37 37 { 38 $e->printStackTrace();38 echo $e->getStackTrace(); 39 39 } 40 40 catch (Exception $e) 41 41 { 42 sfException::createFromException($e)->printStackTrace();42 echo sfException::createFromException($e)->getStackTrace(); 43 43 } 44 44 } trunk/lib/controller/sfFrontWebController.class.php
r6514 r6522 47 47 // make the first request 48 48 $this->forward($moduleName, $actionName); 49 50 $this->context->getResponse()->send();51 49 } 52 50 catch (sfException $e) 53 51 { 54 $ e->printStackTrace();52 $this->context->setResponse($e->asResponse()); 55 53 } 56 54 catch (Exception $e) 57 55 { 58 sfException::createFromException($e)->printStackTrace();56 $this->context->setResponse(sfException::createFromException($e)->asResponse()); 59 57 } 58 59 $this->context->getResponse()->send(); 60 60 } 61 61 } trunk/lib/exception/sfError404Exception.class.php
r6519 r6522 20 20 { 21 21 /** 22 * Forwards to the 404 action.22 * @see sfException 23 23 */ 24 public function printStackTrace()24 public function asResponse() 25 25 { 26 // log all exceptions in php log27 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException;28 error_log($exception->getMessage());29 30 26 if (sfConfig::get('sf_debug')) 31 27 { 32 sfContext::getInstance()->getResponse()->setStatusCode(404); 33 34 return parent::printStackTrace(); 28 $response = parent::asResponse(); 29 $response->setStatusCode(404); 35 30 } 36 31 else 37 32 { 33 // log all exceptions in php log 34 if (!sfConfig::get('sf_test')) 35 { 36 error_log($this->getMessage()); 37 } 38 38 39 $context = sfContext::getInstance(); 40 $context->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action')); 41 $response = $context->getResponse(); 42 } 39 43 40 $context->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action')); 41 $context->getResponse()->send(); 42 } 44 return $response; 43 45 } 44 46 } trunk/lib/exception/sfException.class.php
r6519 r6522 41 41 } 42 42 43 /** 44 * Changes the wrapped exception. 45 * 46 * @param Exception An Exception instance 47 */ 43 48 public function setWrappedException($e) 44 49 { … … 47 52 48 53 /** 49 * Prints the stack trace for this exception. 50 */ 51 public function printStackTrace() 54 * Returns the exception as a sfWebResponse object. 55 * 56 * @param sfWebResponse A sfWebResponse instance 57 */ 58 public function asResponse() 52 59 { 53 60 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 54 55 // log all exceptions in php log56 error_log($exception->getMessage());57 61 58 62 if (!sfConfig::get('sf_test')) … … 61 65 while (@ob_end_clean()); 62 66 63 header('HTTP/1.0 500 Internal Server Error'); 64 } 67 // log all exceptions in php log 68 error_log($exception->getMessage()); 69 } 70 71 $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher()); 72 $response->setStatusCode(500); 65 73 66 74 try 67 75 { 68 $ this->outputStackTrace($exception);76 $content = self::getStackTrace($exception); 69 77 } 70 78 catch (Exception $e) 71 79 { 72 }73 74 if (!sfConfig::get('sf_test')) 75 {76 exit(1); 77 }80 $content = $e->getMessage(); 81 } 82 83 $response->setContent($content); 84 85 return $response; 78 86 } 79 87 … … 81 89 * Gets the stack trace for this exception. 82 90 */ 83 static protected function outputStackTrace($exception)91 static protected function getStackTrace($exception) 84 92 { 85 93 if (class_exists('sfContext', false) && sfContext::hasInstance()) … … 95 103 if ($event->isProcessed()) 96 104 { 97 return ;105 return $event->getReturnValue(); 98 106 } 99 107 } … … 104 112 $file = sfConfig::get('sf_web_dir').'/errors/error500.php'; 105 113 114 ob_start(); 106 115 include is_readable($file) ? $file : sfConfig::get('sf_symfony_data_dir').'/web/errors/error500.php'; 107 116 108 return ;117 return ob_get_clean(); 109 118 } 110 119 … … 126 135 } 127 136 137 ob_start(); 128 138 include sfConfig::get('sf_symfony_data_dir').'/data/exception.'.($format == 'html' ? 'php' : 'txt'); 139 140 return ob_get_clean(); 129 141 } 130 142 trunk/lib/exception/sfStopException.class.php
r6519 r6522 20 20 { 21 21 /** 22 * Stops the current action.22 * @see sfException 23 23 */ 24 public function printStackTrace()24 public function asResponse() 25 25 { 26 // log all exceptions in php log 27 $exception = is_null($this->wrappedException) ? $this : $this->wrappedException; 28 error_log($exception->getMessage()); 26 return sfContext::getInstance()->getResponse(); 29 27 } 30 28 } trunk/lib/filter/sfBasicSecurityFilter.class.php
r6514 r6522 72 72 // the user doesn't have access, exit stage left 73 73 $controller->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); 74 $this->context->getResponse()->send();75 74 76 75 throw new sfStopException(); … … 81 80 // the user is not authenticated 82 81 $controller->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); 83 $this->context->getResponse()->send();84 82 85 83 throw new sfStopException(); trunk/lib/plugins/sfPropelPlugin/test/functional/browseTest.php
r6482 r6522 21 21 $b-> 22 22 get('/error')-> 23 isStatusCode( 200)->23 isStatusCode(500)-> 24 24 isRequestParameter('module', 'error')-> 25 25 isRequestParameter('action', 'index')-> trunk/lib/util/sfCore.class.php
r5402 r6522 42 42 catch (sfException $e) 43 43 { 44 $e->printStackTrace();44 echo $e->getStackTrace(); 45 45 } 46 46 catch (Exception $e) 47 47 { 48 sfException::createFromException($e)->printStackTrace();48 echo sfException::createFromException($e)->getStackTrace(); 49 49 } 50 50 } trunk/test/functional/genericTest.php
r6482 r6522 110 110 $b-> 111 111 get('/configSettingsMaxForwards/selfForward')-> 112 isStatusCode( 200)->112 isStatusCode(500)-> 113 113 checkResponseElement('body', '/Too many forwards have been detected for this request/i') 114 114 ; trunk/test/functional/sfTestBrowserTest.php
r6482 r6522 26 26 27 27 get('/exception/throwsException')-> 28 isStatusCode( 200)->28 isStatusCode(500)-> 29 29 isRequestParameter('module', 'exception')-> 30 30 isRequestParameter('action', 'throwsException')-> … … 35 35 36 36 get('/exception/throwsSfException')-> 37 isStatusCode( 200)->37 isStatusCode(500)-> 38 38 isRequestParameter('module', 'exception')-> 39 39 isRequestParameter('action', 'throwsSfException')->