IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

erreur avec foreach


Sujet :

Langage PHP

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 3
    Points : 1
    Points
    1
    Par défaut erreur avec foreach
    Bonjour à tous,
    j'espère être dans la bonne salle pour poser mon problème.
    Je n'y connais absolument rien ou presque en développement,
    et je dois debuguer un blog : qui me donne cet erreur :
    (Warning: Invalid argument supplied for foreach() in /homepages/24/d180269135/htdocs/blog/wp-includes/classes.php on line 92 ) sur tous les post du blog.

    après pas mal d'investigation j'ai tout de même réussi à cibler le problème,
    sans être capable de corriger cette erreur de script :


    voici le 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
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
     
    <?php
     
    class WP {
    	var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
     
    	var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id');
    	var $extra_query_vars = array();
     
    	var $query_vars;
    	var $query_string;
    	var $request;
    	var $matched_rule;
    	var $matched_query;
    	var $did_permalink = false;
     
    	function add_query_var($qv) {
    		$this->public_query_vars[] = $qv;
    	}
     
    	function set_query_var($key, $value) {
    		$this->query_vars[$key] = $value;
    	}
     
    	function parse_request($extra_query_vars = '') {
    		global $wp_rewrite;
     
    		$this->query_vars = array();
     
    		if ( is_array($extra_query_vars) )
    			$this->extra_query_vars = & $extra_query_vars;
    		else if (! empty($extra_query_vars))
    			parse_str($extra_query_vars, $this->extra_query_vars);
     
    		// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
     
    		// Fetch the rewrite rules.
    		$rewrite = $wp_rewrite->wp_rewrite_rules();
     
    		if (! empty($rewrite)) {
    			// If we match a rewrite rule, this will be cleared.
    			$error = '404';
    			$this->did_permalink = true;
     
    			if ( isset($_SERVER['PATH_INFO']) )
    				$pathinfo = $_SERVER['PATH_INFO'];
    			else
    				$pathinfo = '';
    			$pathinfo_array = explode('?', $pathinfo);
    			$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
    			$req_uri = $_SERVER['REQUEST_URI'];
    			$req_uri_array = explode('?', $req_uri);
    			$req_uri = $req_uri_array[0];
    			$self = $_SERVER['PHP_SELF'];
    			$home_path = parse_url(get_option('home'));
    			if ( isset($home_path['path']) )
    				$home_path = $home_path['path'];
    			else
    				$home_path = '';
    			$home_path = trim($home_path, '/');
     
    			// Trim path info from the end and the leading home path from the
    			// front.  For path info requests, this leaves us with the requesting
    			// filename, if any.  For 404 requests, this leaves us with the
    			// requested permalink.
    			$req_uri = str_replace($pathinfo, '', rawurldecode($req_uri));
    			$req_uri = trim($req_uri, '/');
    			$req_uri = preg_replace("|^$home_path|", '', $req_uri);
    			$req_uri = trim($req_uri, '/');
    			$pathinfo = trim($pathinfo, '/');
    			$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
    			$pathinfo = trim($pathinfo, '/');
     
    			$self = trim($self, '/');
    			$self = preg_replace("|^$home_path|", '', $self);
    			$self = str_replace($home_path, '', $self);
    			$self = trim($self, '/');
     
    			// The requested permalink is in $pathinfo for path info requests and
    			//  $req_uri for other requests.
    			if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
    				$request = $pathinfo;
    			} else {
    				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
    				if ( $req_uri == $wp_rewrite->index )
    					$req_uri = '';
    				$request = $req_uri;
    			}
     
    			$this->request = $request;
     
    			// Look for matches.
    			$request_match = $request;
    			foreach ($rewrite as $match => $query) {
    				// If the requesting file is the anchor of the match, prepend it
    				// to the path info.
    				if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
    					$request_match = $req_uri . '/' . $request;
    				}
     
    				if (preg_match("!^$match!", $request_match, $matches) ||
    					preg_match("!^$match!", urldecode($request_match), $matches)) {
    					// Got a match.
    					$this->matched_rule = $match;
     
    					// Trim the query of everything up to the '?'.
    					$query = preg_replace("!^.+\?!", '', $query);
     
    					// Substitute the substring matches into the query.
    					eval("\$query = \"$query\";");
    					$this->matched_query = $query;
     
    					// Parse the query.
    					parse_str($query, $perma_query_vars);
     
    					// If we're processing a 404 request, clear the error var
    					// since we found something.
    					if (isset($_GET['error']))
    						unset($_GET['error']);
     
    					if (isset($error))
    						unset($error);
     
    					break;
    				}
    			}
     
    			// If req_uri is empty or if it is a request for ourself, unset error.
    			if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) {
    				if (isset($_GET['error']))
    					unset($_GET['error']);
     
    				if (isset($error))
    					unset($error);
     
    				if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false)
    					unset($perma_query_vars);
     
    				$this->did_permalink = false;
    			}
    		}
     
    		$this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
     
    		for ($i=0; $i<count($this->public_query_vars); $i += 1) {
    			$wpvar = $this->public_query_vars[$i];
    			if (isset($this->extra_query_vars[$wpvar]))
    				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
    			elseif (isset($GLOBALS[$wpvar]))
    				$this->query_vars[$wpvar] = $GLOBALS[$wpvar];
    			elseif (!empty($_POST[$wpvar]))
    				$this->query_vars[$wpvar] = $_POST[$wpvar];
    			elseif (!empty($_GET[$wpvar]))
    				$this->query_vars[$wpvar] = $_GET[$wpvar];
    			elseif (!empty($perma_query_vars[$wpvar]))
    				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
     
    			if ( !empty( $this->query_vars[$wpvar] ) )
    				$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
    		}
     
    		foreach ($this->private_query_vars as $var) {
    			if (isset($this->extra_query_vars[$var]))
    				$this->query_vars[$var] = $this->extra_query_vars[$var];
    			elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var])
    				$this->query_vars[$var] = $GLOBALS[$var];
    		}
     
    		if ( isset($error) )
    			$this->query_vars['error'] = $error;
     
    		$this->query_vars = apply_filters('request', $this->query_vars);
     
    		do_action_ref_array('parse_request', array(&$this));
    	}
     
    	function send_headers() {
    		@header('X-Pingback: '. get_bloginfo('pingback_url'));
    		if ( is_user_logged_in() )
    			nocache_headers();
    		if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) {
    			status_header( 404 );
    			if ( !is_user_logged_in() )
    				nocache_headers();
    			@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    		} else if ( empty($this->query_vars['feed']) ) {
    			@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    		} else {
    			// We're showing a feed, so WP is indeed the only thing that last changed
    			if ( $this->query_vars['withcomments']
    				|| ( !$this->query_vars['withoutcomments']
    					&& ( $this->query_vars['p']
    						|| $this->query_vars['name']
    						|| $this->query_vars['page_id']
    						|| $this->query_vars['pagename']
    						|| $this->query_vars['attachment']
    						|| $this->query_vars['attachment_id']
    					)
    				)
    			)
    				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
    			else
    				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
    			$wp_etag = '"' . md5($wp_last_modified) . '"';
    			@header("Last-Modified: $wp_last_modified");
    			@header("ETag: $wp_etag");
     
    			// Support for Conditional GET
    			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
    				$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
    			else $client_etag = false;
     
    			$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
    			// If string is empty, return 0. If not, attempt to parse into a timestamp
    			$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
     
    			// Make a timestamp for our most recent modification...
    			$wp_modified_timestamp = strtotime($wp_last_modified);
     
    			if ( ($client_last_modified && $client_etag) ?
    					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
    					 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
    				status_header( 304 );
    				exit;
    			}
    		}
     
    		do_action_ref_array('send_headers', array(&$this));
    	}
     
    	function build_query_string() {
    		$this->query_string = '';
    		foreach (array_keys($this->query_vars) as $wpvar) {
    			if ( '' != $this->query_vars[$wpvar] ) {
    				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
    					continue;
    				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
    			}
    		}
     
    		// query_string filter deprecated.  Use request filter instead.
    		global $wp_filter;
    		if ( isset($wp_filter['query_string']) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
    			$this->query_string = apply_filters('query_string', $this->query_string);
    			parse_str($this->query_string, $this->query_vars);
    		}
    	}
     
    	function register_globals() {
    		global $wp_query;
    		// Extract updated query vars back into global namespace.
    		foreach ($wp_query->query_vars as $key => $value) {
    			$GLOBALS[$key] = $value;
    		}
     
    		$GLOBALS['query_string'] = & $this->query_string;
    		$GLOBALS['posts'] = & $wp_query->posts;
    		$GLOBALS['post'] = & $wp_query->post;
    		$GLOBALS['request'] = & $wp_query->request;
     
    		if ( is_single() || is_page() ) {
    			$GLOBALS['more'] = 1;
    			$GLOBALS['single'] = 1;
    		}
    	}
     
    	function init() {
    		wp_get_current_user();
    	}
     
    	function query_posts() {
    		global $wp_the_query;
    		$this->build_query_string();
    		$wp_the_query->query($this->query_vars);
     	}
     
    	function handle_404() {
    		global $wp_query;
    		// Issue a 404 if a permalink request doesn't match any posts.  Don't
    		// issue a 404 if one was already issued, if the request was a search,
    		// or if the request was a regular query string request rather than a
    		// permalink request.
    		if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    			$wp_query->set_404();
    			status_header( 404 );
    			nocache_headers();
    		}	elseif( is_404() != true ) {
    			status_header( 200 );
    		}
    	}
     
    	function main($query_args = '') {
    		$this->init();
    		$this->parse_request($query_args);
    		$this->send_headers();
    		$this->query_posts();
    		$this->handle_404();
    		$this->register_globals();
    		do_action_ref_array('wp', array(&$this));
    	}
     
    	function WP() {
    		// Empty.
    	}
    }
     
    class WP_Error {
    	var $errors = array();
    	var $error_data = array();
     
    	function WP_Error($code = '', $message = '', $data = '') {
    		if ( empty($code) )
    			return;
     
    		$this->errors[$code][] = $message;
     
    		if ( ! empty($data) )
    			$this->error_data[$code] = $data;
    	}
     
    	function get_error_codes() {
    		if ( empty($this->errors) )
    			return array();
     
    		return array_keys($this->errors);
    	}
     
    	function get_error_code() {
    		$codes = $this->get_error_codes();
     
    		if ( empty($codes) )
    			return '';
     
    		return $codes[0];
    	}
     
    	function get_error_messages($code = '') {
    		// Return all messages if no code specified.
    		if ( empty($code) ) {
    			$all_messages = array();
    			foreach ( $this->errors as $code => $messages )
    				$all_messages = array_merge($all_messages, $messages);
     
    			return $all_messages;
    		}
     
    		if ( isset($this->errors[$code]) )
    			return $this->errors[$code];
    		else
    			return array();
    	}
     
    	function get_error_message($code = '') {
    		if ( empty($code) )
    			$code = $this->get_error_code();
    		$messages = $this->get_error_messages($code);
    		if ( empty($messages) )
    			return '';
    		return $messages[0];
    	}
     
    	function get_error_data($code = '') {
    		if ( empty($code) )
    			$code = $this->get_error_code();
     
    		if ( isset($this->error_data[$code]) )
    			return $this->error_data[$code];
    		return null;
    	}
     
    	function add($code, $message, $data = '') {
    		$this->errors[$code][] = $message;
    		if ( ! empty($data) )
    			$this->error_data[$code] = $data;
    	}
     
    	function add_data($data, $code = '') {
    		if ( empty($code) )
    			$code = $this->get_error_code();
     
    		$this->error_data[$code] = $data;
    	}
    }
     
    function is_wp_error($thing) {
    	if ( is_object($thing) && is_a($thing, 'WP_Error') )
    		return true;
    	return false;
    }
     
     
    // A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
     
    class Walker {
    	var $tree_type;
    	var $db_fields;
     
    	//abstract callbacks
    	function start_lvl($output) { return $output; }
    	function end_lvl($output)   { return $output; }
    	function start_el($output)  { return $output; }
    	function end_el($output)    { return $output; }
     
    	function walk($elements, $to_depth) {
    		$args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
     
    		//padding at the end
    		$last_element->post_parent = 0;
    		$last_element->post_id = 0;
    		$elements[] = $last_element;
     
    		$id_field = $this->db_fields['id'];
    		$parent_field = $this->db_fields['parent'];
     
    		$flat = ($to_depth == -1) ? true : false;
     
    		foreach ( $elements as $element ) {
    			// If flat, start and end the element and skip the level checks.
    			if ( $flat) {
    				// Start the element.
    				if ( isset($element->$id_field) && $element->$id_field != 0 ) {
    					$cb_args = array_merge( array($output, $element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
    				}
     
    				// End the element.
    				if ( isset($element->$id_field) && $element->$id_field != 0 ) {
    					$cb_args = array_merge( array($output, $element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    				}
     
    				continue;
    			}
     
    			// Walk the tree.
    			if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
    				// Previous element is my parent. Descend a level.
    				array_unshift($parents, $previous_element);
    				if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth
    					$cb_args = array_merge( array($output, $depth), $args);
    					$output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
    				} else if ( $to_depth && $depth == $to_depth  ) {  // If we've reached depth, end the previous element.
    					$cb_args = array_merge( array($output, $previous_element, $depth), $args);
    					$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    				}
    				$depth++; //always do this so when we start the element further down, we know where we are
    			} else if ( $element->$parent_field == $previous_element->$parent_field) {
    				// On the same level as previous element.
    				if ( !$to_depth || ($depth <= $to_depth) ) {
    					$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    				}
    			} else if ( $depth > 1 ) {
    				// Ascend one or more levels.
    				if ( !$to_depth || ($depth <= $to_depth) ) {
    					$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    				}
     
    				while ( $parent = array_shift($parents) ) {
    					$depth--;
    					if ( !$to_depth || ($depth < $to_depth) ) {
    						$cb_args = array_merge( array($output, $depth), $args);
    						$output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
    						$cb_args = array_merge( array($output, $parent, $depth - 1), $args);
    						$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    					}
    					if ( $element->$parent_field == $parents[0]->$id_field ) {
    						break;
    					}
    				}
    			} else if ( !empty($previous_element) ) {
    				// Close off previous element.
    				if ( !$to_depth || ($depth <= $to_depth) ) {
    					$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
    				}
    			}
     
    			// Start the element.
    			if ( !$to_depth || ($depth <= $to_depth) ) {
    				if ( $element->$id_field != 0 ) {
    					$cb_args = array_merge( array($output, $element, $depth - 1), $args);
    					$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
    				}
    			}
     
    			$previous_element = $element;
    		}
     
    		return $output;
    	}
    }
     
    class Walker_Page extends Walker {
    	var $tree_type = 'page';
    	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
     
    	function start_lvl($output, $depth) {
    		$indent = str_repeat("\t", $depth);
    		$output .= "\n$indent<ul>\n";
    		return $output;
    	}
     
    	function end_lvl($output, $depth) {
    		$indent = str_repeat("\t", $depth);
    		$output .= "$indent</ul>\n";
    		return $output;
    	}
     
    	function start_el($output, $page, $depth, $current_page, $args) {
    		if ( $depth )
    			$indent = str_repeat("\t", $depth);
    		extract($args, EXTR_SKIP);
    		$css_class = 'page_item page-item-'.$page->ID;
    		$_current_page = get_page( $current_page );
    		if ( $page->ID == $current_page )
    			$css_class .= ' current_page_item ';
    		elseif ( $_current_page && $page->ID == $_current_page->post_parent )
    			$css_class .= ' current_page_parent';
     
    		$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';
     
    		if ( !empty($show_date) ) {
    			if ( 'modified' == $show_date )
    				$time = $page->post_modified;
    			else
    				$time = $page->post_date;
     
    			$output .= " " . mysql2date($date_format, $time);
    		}
     
    		return $output;
    	}
     
    	function end_el($output, $page, $depth) {
    		$output .= "</li>\n";
     
    		return $output;
    	}
     
    }
     
    class Walker_PageDropdown extends Walker {
    	var $tree_type = 'page';
    	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
     
    	function start_el($output, $page, $depth, $args) {
    				$pad = str_repeat('&nbsp;', $depth * 3);
     
    				$output .= "\t<option value=\"$page->ID\"";
    				if ( $page->ID == $args['selected'] )
    								$output .= ' selected="selected"';
    				$output .= '>';
    				$title = wp_specialchars($page->post_title);
    				$output .= "$pad$title";
    				$output .= "</option>\n";
     
    				return $output;
    	}
    }
     
    class Walker_Category extends Walker {
    	var $tree_type = 'category';
    	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
     
    	function start_lvl($output, $depth, $args) {
    		if ( 'list' != $args['style'] )
    			return $output;
     
    		$indent = str_repeat("\t", $depth);
    		$output .= "$indent<ul class='children'>\n";
    		return $output;
    	}
     
    	function end_lvl($output, $depth, $args) {
    		if ( 'list' != $args['style'] )
    			return $output;
     
    		$indent = str_repeat("\t", $depth);
    		$output .= "$indent</ul>\n";
    		return $output;
    	}
     
    	function start_el($output, $category, $depth, $args) {
    		extract($args);
     
    		$cat_name = attribute_escape( $category->name);
    		$cat_name = apply_filters( 'list_cats', $cat_name, $category );
    		$link = '<a href="' . get_category_link( $category->term_id ) . '" ';
    		if ( $use_desc_for_title == 0 || empty($category->description) )
    			$link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"';
    		else
    			$link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->description, $category )) . '"';
    		$link .= '>';
    		$link .= $cat_name . '</a>';
     
    		if ( (! empty($feed_image)) || (! empty($feed)) ) {
    			$link .= ' ';
     
    			if ( empty($feed_image) )
    				$link .= '(';
     
    			$link .= '<a href="' . get_category_rss_link( 0, $category->term_id, $category->slug ) . '"';
     
    			if ( empty($feed) )
    				$alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
    			else {
    				$title = ' title="' . $feed . '"';
    				$alt = ' alt="' . $feed . '"';
    				$name = $feed;
    				$link .= $title;
    			}
     
    			$link .= '>';
     
    			if ( empty($feed_image) )
    				$link .= $name;
    			else
    				$link .= "<img src='$feed_image'$alt$title" . ' />';
    			$link .= '</a>';
    			if ( empty($feed_image) )
    				$link .= ')';
    		}
     
    		if ( isset($show_count) && $show_count )
    			$link .= ' (' . intval($category->count) . ')';
     
    		if ( isset($show_date) && $show_date ) {
    			$link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
    		}
     
    		if ( $current_category )
    			$_current_category = get_category( $current_category );
     
    		if ( 'list' == $args['style'] ) {
    			$output .= "\t<li";
    			$class = 'cat-item cat-item-'.$category->term_id;
    			if ( $current_category && ($category->term_id == $current_category) )
    				$class .=  ' current-cat';
    			elseif ( $_current_category && ($category->term_id == $_current_category->parent) )
    				$class .=  ' current-cat-parent';
    			$output .=  ' class="'.$class.'"';
    			$output .= ">$link\n";
    		} else {
    			$output .= "\t$link<br />\n";
    		}
     
    		return $output;
    	}
     
    	function end_el($output, $page, $depth, $args) {
    		if ( 'list' != $args['style'] )
    			return $output;
     
    		$output .= "</li>\n";
    		return $output;
    	}
     
    }
     
    class Walker_CategoryDropdown extends Walker {
    	var $tree_type = 'category';
    	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
     
    	function start_el($output, $category, $depth, $args) {
    		$pad = str_repeat('&nbsp;', $depth * 3);
     
    		$cat_name = apply_filters('list_cats', $category->name, $category);
    		$output .= "\t<option value=\"".$category->term_id."\"";
    		if ( $category->term_id == $args['selected'] )
    			$output .= ' selected="selected"';
    		$output .= '>';
    		$output .= $pad.$cat_name;
    		if ( $args['show_count'] )
    			$output .= '&nbsp;&nbsp;('. $category->count .')';
    		if ( $args['show_last_update'] ) {
    			$format = 'Y-m-d';
    			$output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
    		}
    		$output .= "</option>\n";
     
    		return $output;
    	}
    }
     
    class WP_Ajax_Response {
    	var $responses = array();
     
    	function WP_Ajax_Response( $args = '' ) {
    		if ( !empty($args) )
    			$this->add($args);
    	}
     
    	// a WP_Error object can be passed in 'id' or 'data'
    	function add( $args = '' ) {
    		$defaults = array(
    			'what' => 'object', 'action' => false,
    			'id' => '0', 'old_id' => false,
    			'data' => '', 'supplemental' => array()
    		);
     
    		$r = wp_parse_args( $args, $defaults );
    		extract( $r, EXTR_SKIP );
     
    		if ( is_wp_error($id) ) {
    			$data = $id;
    			$id = 0;
    		}
     
    		$response = '';
    		if ( is_wp_error($data) )
    			foreach ( $data->get_error_codes() as $code )
    				$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
    		else
    			$response = "<response_data><![CDATA[$data]]></response_data>";
     
    		$s = '';
    		if ( (array) $supplemental )
    			foreach ( $supplemental as $k => $v )
    				$s .= "<$k><![CDATA[$v]]></$k>";
     
    		if ( false === $action )
    			$action = $_POST['action'];
     
    		$x = '';
    		$x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
    		$x .=	"<$what id='$id'" . ( false !== $old_id ? "old_id='$old_id'>" : '>' );
    		$x .=		$response;
    		$x .=		$s;
    		$x .=	"</$what>";
    		$x .= "</response>";
     
    		$this->responses[] = $x;
    		return $x;
    	}
     
    	function send() {
    		header('Content-Type: text/xml');
    		echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
    		foreach ( $this->responses as $response )
    			echo $response;
    		echo '</wp_ajax>';
    		die();
    	}
    }
     
    ?>
    Quelqu'un peut il me rendre service pour corrigé le script ?

    Merci,

    Toto

  2. #2
    Membre confirmé
    Développeur Web
    Inscrit en
    Avril 2005
    Messages
    397
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Avril 2005
    Messages : 397
    Points : 518
    Points
    518
    Par défaut
    Salut,

    Je doute que l'erreur vienne vraiment de là. Vu que tu nous proposes le code d'une classe de wordpress. Je ne dis pas pour autant que leur code son immunisé au erreur ou bug mais bon...

    Je pense que cette erreur est la conséquence d'un autre soucis plus en amont.

  3. #3
    Nouveau Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Citation Envoyé par Gats Voir le message
    Salut,

    Je doute que l'erreur vienne vraiment de là. Vu que tu nous proposes le code d'une classe de wordpress. Je ne dis pas pour autant que leur code son immunisé au erreur ou bug mais bon...

    Je pense que cette erreur est la conséquence d'un autre soucis plus en amont.
    en fait il me donne une erreur 404 aussi.
    Plus en amont c'est à dire ?

  4. #4
    Expert confirmé
    Avatar de Thes32
    Homme Profil pro
    Développeur PHP, .Net, T-SQL
    Inscrit en
    Décembre 2006
    Messages
    2 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Développeur PHP, .Net, T-SQL

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 379
    Points : 4 853
    Points
    4 853
    Par défaut
    Plus en amont c'est à dire ?
    Que l'erreur pourrait provenir des opérations que tu as fait bien avant.

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2007
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 24
    Points : 19
    Points
    19
    Par défaut
    Le warning ne peut-il pas être lancé si, par exemple, l'object ou tableau parsé est vide, vaut false ou null ? Peut-être un test économisé de ce fait et qu'avec un niveau de reporting moins élevé ça pourrait passer (je dis pas que c'est la meilleure solution, mais si l'erreur vient de WP ou d'un plugin, c'est surement le moins impactant). Faudrait essayer de passer à un niveau de reporting E_ERROR dans php.ini.

  6. #6
    Nouveau Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    Citation Envoyé par Kunai Voir le message
    Le warning ne peut-il pas être lancé si, par exemple, l'object ou tableau parsé est vide, vaut false ou null ? Peut-être un test économisé de ce fait et qu'avec un niveau de reporting moins élevé ça pourrait passer (je dis pas que c'est la meilleure solution, mais si l'erreur vient de WP ou d'un plugin, c'est surement le moins impactant). Faudrait essayer de passer à un niveau de reporting E_ERROR dans php.ini.
    ha ok, et comment dois-je m'y prendre pour cela ?
    désolé j'ai un niveau proche de zéro, je comprend à peine votre jargon.


    En fait c'est suite à des post ajouter, et certains supprimer,
    que ce bug est survenu je pense.
    Ce sont les seules choses auxquels nous avons touché.

    Merci à vous.

Discussions similaires

  1. Erreur Avec Interbase
    Par smokemon dans le forum Bases de données
    Réponses: 1
    Dernier message: 29/10/2004, 07h24
  2. Erreur avec procédure LockWorkStation ...
    Par simonseztech dans le forum API, COM et SDKs
    Réponses: 4
    Dernier message: 16/08/2004, 15h33
  3. [Débutant][Conception] Erreur avec une classe interne
    Par Devil Redneck dans le forum Général Java
    Réponses: 5
    Dernier message: 11/06/2004, 15h45
  4. Erreur avec les ADO
    Par megane dans le forum Bases de données
    Réponses: 7
    Dernier message: 08/03/2004, 21h37
  5. Erreur avec WM_COMMAND (BN_CLICKED)
    Par cyberlewis dans le forum Windows
    Réponses: 2
    Dernier message: 09/02/2004, 00h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo