developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #749: 749-jCoordinator-exception-loop-when-response-constructor-fails-variant.2.diff

File 749-jCoordinator-exception-loop-when-response-constructor-fails-variant.2.diff, 1.8 KB (added by Julien, 13 years ago)

final one, better approach, indent fixed

  • lib/jelix/core/jCoordinator.class.php

     
    2323 */
    2424class jCoordinator {
    2525
    26    /**
    27     * plugin list
    28     * @var  array
    29     */
     26    /**
     27     * plugin list
     28     * @var  array
     29     */
    3030    public $plugins = array();
    3131
    3232    /**
     
    249249    /**
    250250     * instancy a response object corresponding to the default response type
    251251     * of the current resquest
     252     * @param boolean $originalResponse TRUE to get the original, non overloaded response
    252253     * @return mixed  error string or false
    253254     */
    254     public function initDefaultResponseOfRequest(){
    255         global $gJConfig;
     255    public function initDefaultResponseOfRequest($originalResponse = false){
     256        if($originalResponse)
     257            $responses = $GLOBALS['gJConfig']->responses;
     258        else
     259            $responses = $GLOBALS['gJConfig']->_coreResponses;
    256260
    257         $type= $this->request->defaultResponseType;
     261        $type = $this->request->defaultResponseType;
    258262
    259         if(!isset($gJConfig->responses[$type])){
     263        if(!isset($responses[$type]))
    260264            return jLocale::get('jelix~errors.default.response.type.unknow',array($this->moduleName.'~'.$this->actionName,$type));
     265
     266        try{
     267            $respclass = $responses[$type];
     268            require_once ($responses[$type.'.path']);
     269            $this->response = new $respclass();
     270            return false;
    261271        }
    262 
    263         $respclass = $gJConfig->responses[$type];
    264         require_once ($gJConfig->responses[$type.'.path']);
    265 
    266         $this->response = new $respclass();
    267 
    268         return false;
     272        catch(Exception $e){
     273            return $this->initDefaultResponseOfRequest(true);
     274        }
    269275    }
    270276
    271277    /**