Title: Fatal error: Uncaught TypeError: count()
Last modified: April 29, 2022

---

# Fatal error: Uncaught TypeError: count()

 *  [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/)
 * I sent one of my blogs a manual ping from another using Webmention. Got errors:
 * <b>Warning</b>: Undefined array key “type” in <b>[snip]wp-content/plugins/semantic-
   linkbacks/includes/class-linkbacks-mf2-handler.php</b> on line <b>454</b><br /
   >
    [snip]Lots of these[/snip] <b>Warning</b>: Undefined array key “type” in <
   b>[snip]wp-content/plugins/semantic-linkbacks/includes/class-linkbacks-mf2-handler.
   php</b> on line <b>454</b><br /> <br /> <b>Fatal error</b>: Uncaught TypeError:
   count(): Argument #1 ($value) must be of type Countable|array, null given in [
   snip]wp-content/plugins/semantic-linkbacks/includes/class-linkbacks-mf2-handler.
   php:399 Stack trace: #0 [snip]wp-content/plugins/semantic-linkbacks/includes/
   class-linkbacks-mf2-handler.php(202): Linkbacks_MF2_Handler::flatten_microformats(
   NULL) #1 [snip]wp-includes/class-wp-hook.php(307): Linkbacks_MF2_Handler::generate_commentdata(
   Array) #2 [snip]wp-includes/plugin.php(189): WP_Hook->apply_filters(Array, Array)#
   3 [snip]wp-content/plugins/semantic-linkbacks/includes/class-linkbacks-handler.
   php(202): apply_filters(‘semantic_linkba…’, Array) #4 [snip]wp-includes/class-
   wp-hook.php(307): Linkbacks_Handler::enhance(Array) #5 [snip]wp-includes/plugin.
   php(189): WP_Hook->apply_filters(Array, Array) #6 [snip]wp-includes/comment.php(
   2234): apply_filters(‘preprocess_comm…’, Array) #7 [snip]wp-content/plugins/webmention/
   includes/class-webmention-receiver.php(362): wp_new_comment(Array, true) #8 [
   snip]wp-includes/rest-api/class-wp-rest-server.php(1141): Webmention_Receiver::
   post(Object(WP_REST_Request)) #9 [snip]wp-includes/rest-api/class-wp-rest-server.
   php(988): WP_REST_Server->respond_to_request(Object(WP_REST_Request), ‘/webmention/
   1.0…’, Array, NULL) #10 [snip]wp-includes/rest-api/class-wp-rest-server.php(414):
   WP_REST_Server->dispatch(Object(WP_REST_Request)) #11 [snip]wp-includes/rest-
   api.php(386): WP_REST_Server->serve_request(‘/webmention/1.0…’) #12 [snip]wp-
   includes/class-wp-hook.php(307): rest_api_loaded(Object(WP)) #13 [snip]wp-includes/
   class-wp-hook.php(331): WP_Hook->apply_filters(”, Array) #14 [snip]wp-includes/
   plugin.php(522): WP_Hook->do_action(Array) #15 [snip]wp-includes/class-wp.php(
   396): do_action_ref_array(‘parse_request’, Array) #16 [snip]wp-includes/class-
   wp.php(758): WP->parse_request(”) #17 [snip]wp-includes/functions.php(1310): 
   WP->main(”) #18 [snip]wp-blog-header.php(16): wp() #19 [snip]index.php(17): require(‘/
   home/sites/22a…’) #20 {main} thrown in <b>[snip]wp-content/plugins/semantic-linkbacks/
   includes/class-linkbacks-mf2-handler.php</b> on line <b>399</b><br />

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

 *  Plugin Author [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15605723)
 * Hey [@lordmatt](https://wordpress.org/support/users/lordmatt/) thanks for the
   report.
 * Can you send me the two URLs you used, so that I can debug it?
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15663601)
 * I could but I’ve disabled the plugin. I’ll set up some test sites and see if 
   the problem persists. If it does, I’ll give you links to examine.
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15663676)
 * Not seeing the bug on newly set up test sites. Am seeing problems on openmentions.
   com with only webmention and this plugin active.
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15663692)
 * The only difference I can find is that the problem site has a single filter that
   targets webmentions.
 *     ```
       function handle_other_webmentions($id, $target) {
         // do nothing if id is set
         if ($id) {
           return $id;
         }
         // return "default" id if plugin can't find a post/page
         return 9;
       }
   
       add_filter("webmention_post_id", "handle_other_webmentions", 10, 2);
       ```
   
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).
      Reason: code formatting aaarh!
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).
      Reason: fffffs
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15663754)
 * Update: Nope, no error there either.
 * IDK, I’ll report back only if I can replicate.
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15665544)
 * And now it is back:
 * On this page: [https://openmentions.com/topics/conversation-starters/](https://openmentions.com/topics/conversation-starters/)
   
   trying to manual ping this URL: [https://matrixdreams.com/blog/games/discussion-what-underrated-game-do-you-wish-got-more-attention/](https://matrixdreams.com/blog/games/discussion-what-underrated-game-do-you-wish-got-more-attention/)
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15665613)
 * Also observed like this
 * Page with error: [https://openmentions.com/topics/world-news/europe/uk/](https://openmentions.com/topics/world-news/europe/uk/)
   
   Manual ping from: [https://lordmatt.co.uk/reflections/politics/partygate-because-they-think-they-are-better-than-us/](https://lordmatt.co.uk/reflections/politics/partygate-because-they-think-they-are-better-than-us/)
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15669156)
 * I’ve had to pull this plugin from use again. People were complaining about the
   error messages.
 *  Thread Starter [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * (@lordmatt)
 * [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15669399)
 * I believe I ha\ve squashed the bug:
 * I added a forced data type to the problem function which threw a new error. This
   
   led me to `public static function generate_commentdata` which calls `public static
   function get_representative_author`.
 * I saw that `public static function get_representative_author` can return null
   but `public static function generate_commentdata`
    does not check for null on
   line 202. Thus null gets sent up the stack to the failure point on 339
 * I made the following edit which seems to have fixed things.
 *     ```
       		// check if h-card has an author
       		if ( isset( $properties['author'] ) ) {
       			$author = $properties['author'];
       		} else {
       			$author = self::get_representative_author( $mf_array, $source );
                               if($author!==null){
                                   $author = self::flatten_microformats( $author );
                               }
       		}
       ```
   
    -  This reply was modified 4 years ago by [lordmatt](https://wordpress.org/support/users/lordmatt/).

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

The topic ‘Fatal error: Uncaught TypeError: count()’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/semantic-linkbacks_93a86a.svg)
 * [Semantic-Linkbacks](https://wordpress.org/plugins/semantic-linkbacks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/semantic-linkbacks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/semantic-linkbacks/)
 * [Active Topics](https://wordpress.org/support/plugin/semantic-linkbacks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/semantic-linkbacks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/semantic-linkbacks/reviews/)

## Tags

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

 * 9 replies
 * 2 participants
 * Last reply from: [lordmatt](https://wordpress.org/support/users/lordmatt/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/fatal-error-uncaught-typeerror-count-2/#post-15669399)
 * Status: not resolved