probleme "Warning: Invalid argument supplied for foreach" WP

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : probleme "Warning: Invalid argument supplied for foreach" WP

Re: probleme "Warning: Invalid argument supplied for foreach" WP

par vgkeeper » 30 déc. 2009, 19:28

Merci d'avoir répondu

Si je rajoute ta ligne je me retrouve avec ça à la place d'un album sur deux:
array(98) { [0]=> array(8) { ["id"]=> string(10) "4177164440" ["secret"]=> string(10) "3ec5105823" ["server"]=> string(4) "2665" ["farm"]=> float(3) ["title"]=> string(8) "IMG_7419" ["isprimary"]=> string(1) "1" ["originalsecret"]=> string(10) "296abe4cb9" ["originalformat"]=> string(3) "jpg" } [1]=> array(8) { ["id"]=> string(10) "4177164660" ["secret"]=> string(10) "5f0c740029" ["server"]=> string(4) "2632" ["farm"]=> float(3) ["title"]=> string(8) "IMG_7421" ["isprimary"]=> string(1) "0" ["originalsecret"]=> string(10) "0cfc0a9c4c" ["originalformat"]=> string(3) "jpg" } [2]=> array(8) { ["id"]=> string(10) "4176405731" ["secret"]=> string(10) "ce1387ba7b" ["server"]=> string(4) "2577" ["farm"]=> float(3) ["title"]=> string(8) "IMG_7422" ["isprimary"]=> string(1) "0" ["originalsecret"]=> string(10) "fa7314c104" ["originalformat"]=> string(3) "jpg" } [3]=> array(8) { ["id"]=> string(10) "4177165018" ["secret"]=> string(10) "f62dbfdd3d" ["server"]=> string(4) "2500" ["farm"]=> float(3) ["title"]=> string(8) "IMG_7423" 
un album s'affiche correctement et un album s'affiche avec ca (c'est qu'un extrait car en réalité j'en ai des centaines de lignes).

Re: probleme "Warning: Invalid argument supplied for foreach" WP

par stealth35 » 29 déc. 2009, 01:52

si avant le foreach tu fais un :

Code : Tout sélectionner

var_dump($photoset['photoset']['photo']); 
ca donne quoi ?

probleme "Warning: Invalid argument supplied for foreach" WP

par vgkeeper » 28 déc. 2009, 20:39

Bonjour à tous,

Je possède un blog perso Wordpress sur lequel je partage mes photos.

J'utilise un plugin (flickr-manager) qui va chercher mes photos sur mon compte flickr et qui me les rapatrie par album sous forme de miniatures.

de temps à autres, j'ai cette erreur:
Warning: Invalid argument supplied for foreach() in /mnt/142/sda/7/3/gaetan.besson/wp-content/plugins/wordpress-flickr-manager/FlickrManager.php on line 832
et l'album ne s'affiche pas.

Je suis a peu près sûr que c'est dû à une erreur de connection avec flickr puisque l'erreur en question est aléatoire, peut concerner n'importe quel album, et disparait généralement lorsque j'actualise ma page avec F5...

cependant, je ne connait absolument rien en langage de programmation et encore moins en php. J'aimerais donc votre aide pour arriver à créer une sorte de boucle pour que tant que l'erreur a lieu, la fonction soit relancée (j'espère être clair).

Voici la fonction en question sur le Flickrmanager.php: (la ligne 832 est celle où il y a "foreach ($photoset['photoset']['photo'] as $photo) {" )
function set_shortcode($attr) {
		global $flickr_settings;
		
		$token = $flickr_settings->getSetting('token');
		$params = array('photoset_id' => $attr['id'], 'auth_token' => $token, 'extras' => 'original_format');
		
		if($flickr_settings->getSetting('privacy_filter') == 'true') $params = array_merge($params, array('privacy_filter' => 1));
		
		$photoset = $this->call('flickr.photosets.getPhotos',$params, true);
		
		$html = '';
		foreach ($photoset['photoset']['photo'] as $photo) {
			$html .= $flickr_settings->getSetting('before_wrap') . "<a href=\"http://www.flickr.com/photos/{$photoset['photoset']['owner']}/{$photo['id']}/\" title=\"{$photo['title']}\" ";
			if($attr['overlay'] == 'true') $html .= "rel=\"flickr-mgr[{$attr['id']}]\" ";
			$html .= "class=\"flickr-image\" >\n";
			$html .= '	<img src="' . $this->getPhotoUrl($photo, $attr['thumbnail']) . "\" alt=\"{$photo['title']}\" ";
			if($attr['overlay'] == 'true') $html .= "class=\"flickr-{$attr['size']}\" ";
			if($attr['size'] == 'original') $html .= 'longdesc="' . $this->getPhotoUrl($photo, 'original') . '" ';
			$html .= "/>\n</a>\n" . $flickr_settings->getSetting('after_wrap');;
		}
		
		return $html;
	}


Merci d'avance