Bonjour,

Voilà on trouve partout ce problème sur le net mais je ne trouve pas MA solution.

Je sais qu'il ne s'agit pas à proprement parlé d'un problème avec Zend Framework mais plutôt PHP mais bon vu que mon appli est développée sous ZF je post ici .

Voilà mon problème : j'ai une classe qui traite du XML à l'aide de SimpleXml. Quand j'essaie de stocker mon objet en session : "Fatal error: Exception thrown without a stack frame in Unknown on line 0". Qui correspond semble t'il à une boucle d'exceptions dues à l'utilisation de mon SimpleXml utilisant des ressources externes. Bref, un problème semble t'il assez classique. Pour détourner cette erreur j'ai voulu ne plus stocker mon objet SimpleXml dans mon objet mais cela ne change rien. Le simple fait de travailler avec du SimpleXml dans mes fonctions membres me renvoie interminablement à la même erreur.

J'ai fait plusieurs tests et j'ai même essayé de créer l'objet SimpleXml en dehors de ma classe.

Voilà mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
 
<?php
require_once 'info.php';
require_once 'constant.php';
require_once 'database.php';
require_once 'javascript.php';
require_once 'rule.php';
require_once 'stylesheet.php';
require_once 'variable.php';
require_once 'displayer.php';
 
class Extension{
	// protected $domdoc_xml;
 
	private $_infos;
	private $_arr_constants;
	private $_arr_variables;
	private $_arr_databases;
	private $_arr_stylesheets;
	private $_arr_javascripts;
	private $_arr_rules;
	private $_filename;
 
	/**
	 * Constructor
	 **/
	public function __construct($filename){
		$this->_arr_constants    = array();
		$this->_arr_variables    = array();
		$this->_arr_databases    = array(); 
		$this->_arr_stylesheets  = array();
		$this->_arr_javascripts  = array();
		$this->_arr_rules        = array();
		$this->_filename         = $filename;
		// $this->domdoc_xml = simplexml_load_file($filename, 'SimpleXMLElement', LIBXML_NOCDATA);
		// $domdoc_xml = $this->domdoc_xml;
 
		// $domdoc_xml = simplexml_load_file($filename, 'SimpleXMLElement', LIBXML_NOCDATA);
		$domdoc_xml = Toolbox::getSimpleXML($filename);
 
		$this->fillObject($domdoc_xml);
	}
 
	/**
	 *Methode appelée pour sauver les attributs avant la sérialisation
	 **/
	// public function _sleep(){
 
	// }
 
	/**
	 *Methode qui est appelée après la désérialisation, pour nous permettre de relncer la connexion
	 **/
	// public function _wakeup(){
 
	// }
 
	/**
	 * Accessors
	 **/
	public function get_infos()          {return $this->_infos;          } 
	public function get_arr_constants()  {return $this->_arr_constants;  }
	public function get_arr_variables()  {return $this->_arr_variables;  }
	public function get_arr_databases()  {return $this->_arr_databases;  }
	public function get_arr_stylesheets(){return $this->_arr_stylesheets;}
	public function get_arr_javascripts(){return $this->_arr_javascripts;}
	public function get_arr_rules()      {return $this->_arr_rules;      }
	public function get_domdoc_xml()     {return $this->domdoc_xml;      }
 
	public function set_infos($value)          {$this->_infos          = $value;}
	public function set_arr_constants($value)  {$this->_arr_constants  = $value;}
	public function set_arr_variables($value)  {$this->_arr_variables  = $value;}
	public function set_arr_databases($value)  {$this->_arr_databases  = $value;}
	public function set_arr_stylesheets($value){$this->_arr_stylesheets= $value;}
	public function set_arr_javascripts($value){$this->_arr_javascripts= $value;}
	public function set_arr_rules($value)      {$this->_arr_rules      = $value;}
	public function set_domdoc_xml($value)  {$this->domdoc_xml      = $value;}
 
	/**
	 * Calls for the displayer and returns html view
	 **/
	public function display(){
		$displayer = new Displayer($this);
		return $displayer->display();
	}
 
	/**
	 * Saves the new file by replacing it
	 **/
	public function saveFile($arr_infos){
		$doc = new DOMDocument('1.0', 'utf-8');
		$doc->recover = true;
 
		// Version & Encoding format
		$doc->version = '1.0';
		$doc->encoding = 'utf-8';
		// $doc->encoding = 'ISO-8859-1';
 
		// Ajout d'un commentaire a la racine
		$comment_elt = $doc->createComment('Created By '.$name.' v'.$version);
		$doc->appendChild($comment_elt);
 
		$document_elt = $doc->createElement('document');
		$doc->appendChild($document_elt);
 
		$infos_elt       = $this->constructXML($doc,'info',$arr_infos);
		$constants_elt   = $this->constructXML($doc,'constant'  );
		$variables_elt   = $this->constructXML($doc,'variable'  );
		$databases_elt   = $this->constructXML($doc,'database'  );
		$stylesheets_elt = $this->constructXML($doc,'stylesheet');
		$javascripts_elt = $this->constructXML($doc,'javascript');
		$rules_elt       = $this->constructXML($doc,'rule'      );
 
		$document_elt->appendChild($infos_elt      );
		$document_elt->appendChild($constants_elt  );
		$document_elt->appendChild($variables_elt  );
		$document_elt->appendChild($databases_elt  );
		$document_elt->appendChild($stylesheets_elt);
		$document_elt->appendChild($javascripts_elt);
		$document_elt->appendChild($rules_elt      );
 
		$doc->formatOutput = true;
 
		// Saves file
		$doc->save($this->_filename);
	}
 
	private function constructXML($doc,$type,$arr_infos=null){
		if($type=="info"){
			return $this->get_infos()->constructXML($doc,$arr_infos);
		}
		else{
			$counter = 0;
			${$type.'s_elt'} = $doc->createElement($type.'s');
			foreach($this->{'get_arr_'.$type.'s'}() as $obj){
				${'elt_'.$counter} = $obj->constructXML($doc);
				${$type.'s_elt'}->appendChild(${'elt_'.$counter});
				$counter++;
			}
			return ${$type.'s_elt'};
		}
	}
 
	/**
	 * Fills the entire object with extension file's domdoc
	 **/
	private function fillObject($domdoc_xml){
		$this->fillInfos($domdoc_xml);
		$this->fillConstants($domdoc_xml);
		$this->fillVariables($domdoc_xml);
		$this->fillDatabases($domdoc_xml);
		$this->fillStylesheets($domdoc_xml);
		$this->fillJavascripts($domdoc_xml);
		$this->fillRules($domdoc_xml);
	}
 
	/**
	 * Fills Infos
	 **/
	private function fillInfos($domdoc_xml){
		$infos = $domdoc_xml->infos;
		$this->_infos = new Info($infos->version,$infos->type,$infos->date,$infos->author,$infos->company);
		// var_dump($this->_infos); // <= ok
	}
 
	/**
	 * Fills Constants
	 **/
	private function fillConstants($domdoc_xml){
		foreach($domdoc_xml->constants->const as $const){
			array_push($this->_arr_constants,new Constant($const->name,$const->value));
		}
		// var_dump($this->_arr_constants); // <= ok
	}
 
	/**
	 * Fills Variables
	 **/
	private function fillVariables($domdoc_xml){
		foreach($domdoc_xml->variables->variable as $variable){
			array_push($this->_arr_variables,new Variable($variable->mode,$variable->name,$variable->source,$variable->type,$variable->param));
		}
		// var_dump($this->_arr_variables); // <= ok
	}
 
	/**
	 * Fills Databases
	 **/
	private function fillDatabases($domdoc_xml){
		foreach($domdoc_xml->databases->database as $database){
			array_push($this->_arr_databases,new Database($database->name,$database->host,$database->db, $database->login, $database->password, $database->type));
		}
		// var_dump($this->_arr_databases); // <= ok
	}
 
	/**
	 * Fills Css
	 **/
	private function fillStylesheets($domdoc_xml){
		foreach($domdoc_xml->stylesheets->script as $stylesheet){
			switch($stylesheet->mode){
				case 'add':
					$optionnal = $stylesheet->code;
					break;
				case 'include':
					$optionnal = $stylesheet->url;
					break;
				default:
					$optionnal = null;
					break;
			}
			array_push($this->_arr_stylesheets,new Stylesheet($stylesheet->mode,$stylesheet->name,$optionnal));
		}
		// var_dump($this->_arr_stylesheets); // <= ok
	}
 
	/**
	 * Fills Javascripts
	 **/
	private function fillJavascripts($domdoc_xml){
		foreach($domdoc_xml->javascripts->script as $javascript){
			switch($javascript->mode){
				case 'add':
					$optionnal = $javascript->code;
					break;
				case 'include':
					$optionnal = $javascript->url;
					break;
				default:
					$optionnal = null;
					break;
			}
			array_push($this->_arr_javascripts,new Javascript($javascript->mode,$javascript->name,$optionnal));
		}
		// var_dump($this->_arr_javascripts); // <= ok
	}
 
	/**
	 * Fills Rules
	 **/
	private function fillRules($domdoc_xml){
		foreach($domdoc_xml->rules->rule as $rule){
			$arr_args = array();
			$arr_params = array();
			switch($rule->mode){
				case 'add':
					$arr_args['position']          = $rule->position;
					$arr_args['definition_type']   = $rule->definition->type;
					$arr_args['definition_id']     = $rule->definition->id;
					$arr_args['definition_params'] = $rule->definition->params;
					$arr_args['definition_text']   = $rule->definition->text;
					break;
				case 'move':
					$arr_args['destination']       = $rule->destination;
					$arr_args['position']          = $rule->position;
					break;
				case 'edit':
					foreach($rule->definition->params as $params){
						array_push($arr_params,array('rule'=>$params,'mode'=>$params['mode']));
					}
					break;
				default:
					// TODO : Error handling
					break;
			}
			if(isset($arr_params) && sizeof($arr_params)!=0){
				foreach($arr_params as $params){
					$arr_args['definition_params']      = $params['rule'];
					$arr_args['definition_params_mode'] = $params['mode'];
					array_push($this->_arr_rules,new Rule($rule->mode,$rule->source,$arr_args));
				}
			}
			else
				array_push($this->_arr_rules,new Rule($rule->mode,$rule->source,$arr_args));
		}
		// var_dump($this->_arr_rules); // <= ok
	}
}
?>
Code pour sauvegarde en session :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
$envSession->extEngine = $extEngine;