Title: PHP warning
Last modified: July 12, 2018

---

# PHP warning

 *  [sixtyseven](https://wordpress.org/support/users/sixtyseven/)
 * (@sixtyseven)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-warning-164/)
 * Hi,
 * still finding some little flaws. Plugin works good so far, but I get my error
   log filled with this warning:
 * > PHP Warning: count(): Parameter must be an array or an object that implements
   > Countable in … plugins/speakout/includes/class.petition.php on line 321
 * While you are looking after the UTF8 problem, could you look after this warning
   as well? Thanks in advance and greetings from Germany!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [sixtyseven](https://wordpress.org/support/users/sixtyseven/)
 * (@sixtyseven)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-warning-164/#post-10486590)
 * Came up with a litte solution for that: Seems that the warning was added in PHP
   7.2. From PHP 7.3 there will be a native function called is_countable(). To be
   compatible with lower PHP versions as well, you could add a little polyfill like
   function to your plugin, like so:
 *     ```
       if (!function_exists('is_countable')) {
   
           function is_countable($c) {
               return is_array($c) || $c instanceof Countable;
           }
   
       }
       ```
   
 * With that implemented, you could change the lines in class.petition like so:
 *     ```
       if(is_countable($petition)){
       if ( count( $petition ) > 0 ) {
       $this->_populate_from_query( $petition );
       return true;
       } else {
       return false;
       } else {
       return false;
       }
       ```
   
 * or something more clever of course 😉 Can’t wait to get my hands on the next 
   update, thanks again for your nice plugin.
 *  Plugin Author [SpeakOut! Steve](https://wordpress.org/support/users/123host/)
 * (@123host)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-warning-164/#post-10492846)
 * Thanks for your contribution.
 * I have done some research on this and I think that a less complex way to do this
   is instead of `if ( count( $petition ) > 0 )` to use `if ( $petition && $petition
   > 0 )`
 * I have run some tests and it seems to be OK. Can you test it too?
 *  Thread Starter [sixtyseven](https://wordpress.org/support/users/sixtyseven/)
 * (@sixtyseven)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/php-warning-164/#post-10492975)
 * Thanks, will do after my return from Tunisia on Juli 24th.
 *  Plugin Author [SpeakOut! Steve](https://wordpress.org/support/users/123host/)
 * (@123host)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/php-warning-164/#post-10526381)
 * As far as I can tell this is fixed now. Would appreciate if you can confirm that.
   I am about to push version 1.13.0

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP warning’ is closed to new replies.

 * ![](https://ps.w.org/speakout/assets/icon-256x256.png?rev=1649238)
 * [SpeakOut! Email Petitions](https://wordpress.org/plugins/speakout/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/speakout/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/speakout/)
 * [Active Topics](https://wordpress.org/support/plugin/speakout/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/speakout/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/speakout/reviews/)

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [warning](https://wordpress.org/support/topic-tag/warning/)

 * 4 replies
 * 2 participants
 * Last reply from: [SpeakOut! Steve](https://wordpress.org/support/users/123host/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/php-warning-164/#post-10526381)
 * Status: not resolved