• lordmatt

    (@lordmatt)


    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

    (@pfefferle)

    Hey @lordmatt thanks for the report.

    Can you send me the two URLs you used, so that I can debug it?

    Thread Starter lordmatt

    (@lordmatt)

    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

    (@lordmatt)

    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.
    Thread Starter lordmatt

    (@lordmatt)

    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.
    • This reply was modified 4 years ago by lordmatt.
    • This reply was modified 4 years ago by lordmatt. Reason: code formatting aaarh!
    • This reply was modified 4 years ago by lordmatt. Reason: fffffs
    Thread Starter lordmatt

    (@lordmatt)

    Update: Nope, no error there either.

    IDK, I’ll report back only if I can replicate.

    Thread Starter lordmatt

    (@lordmatt)

    Thread Starter lordmatt

    (@lordmatt)

    Thread Starter lordmatt

    (@lordmatt)

    I’ve had to pull this plugin from use again. People were complaining about the error messages.

    Thread Starter lordmatt

    (@lordmatt)

    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.
Viewing 9 replies - 1 through 9 (of 9 total)

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