Support » Plugin: Comment Popularity » foreach() on non-array warning, needs if( is_array() ) check

  • When I allow the plugin to be used by non-logged-in users, I get an “Invalid argument supplied for foreach” PHP warning pointing to line 383 of /inc/class-comment-popularity.php.

    Rest of the plugin seems to work fine, so the following on 383 should fix (and does on my install):

    if( is_array( $votes ) ) {
    	foreach ( $votes as $key => $vote ) {
    		$comment_ids_voted_on[ str_replace( 'comment_id_', '', $key ) ] = $vote['last_action'];
    	}
    }
    • This topic was modified 1 year, 7 months ago by  pressupinc.
    • This topic was modified 1 year, 7 months ago by  pressupinc.
  • The topic ‘foreach() on non-array warning, needs if( is_array() ) check’ is closed to new replies.