• anonymized-15437957

    (@anonymized-15437957)


    DW Question and Answer is causing this error in my WordPress:

    [28-Jan-2018 18:46:56 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /xxx/xxxxxx/xxxxx/wp-content/plugins/dw-question-answer/inc/Status.php on line 247

    The code that causes this error is in the Status.php file and it is here:

    	$latest = get_transient( 'dwqa_latest_answer_for_' . $question_id );
    	if ( false === $latest ) {
    		$args = array(
    			'post_type' 		=> 'dwqa-answer',
    			'meta_query' 		=> array(
    				array(
    					'key' 		=> '_question',
    					'value' 	=> $question_id,
    					'compare' 	=> '=',
    				),
    			),
    			'post_status'    	=> 'public,private',
    	    	'numberposts' 		=> 1,
    		);
    		$recent_answers = wp_get_recent_posts( $args, OBJECT );
    		if ( count( $recent_answers ) > 0 ) {
    			$latest = $recent_answers[0];
    			// This cache need to be update when new answer is added
    			set_transient( 'dwqa_latest_answer_for_' . $question_id, $latest, 450 );
    		}
    	}
    • This topic was modified 8 years, 3 months ago by anonymized-15437957.
    • This topic was modified 8 years, 3 months ago by anonymized-15437957.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter anonymized-15437957

    (@anonymized-15437957)

    The error does not prevent the site from working, but generates a very large log in the root folder.

    I solved my problem by commenting on these two lines.

    // if ( count( $recent_answers ) > 0 ) {

    //}

    But this can be revised in the next updates of the plugin.

    • This reply was modified 8 years, 3 months ago by anonymized-15437957.
Viewing 1 replies (of 1 total)

The topic ‘DW Q & A Error: count(): Parameter must be an array’ is closed to new replies.