0

I'm using two plugins which use the_title, but one (while still completely functional) is showing an error on certain pages.

Missing argument 2 for pfund_handle_title() in ...wp-content/plugins/personal-fundraiser/includes/user.php on line 639

I'm told it's because it doesn't pass the second required parameter of the_title.

Here's my original ? on the WP forums: http://wordpress.org/support/topic/plugin-personal-fundraiser-missing-argument-2-for-pfund_handle_title-in-userphp-on-line-639?replies=4#post-2682690

The second plugin is Blog in Blog. When deactivated, the error goes away, so I'm sure it's that one.

I don't want to set the debugging in wp-config to false because, well, I don't want it to BE false.

Here is the line from the Blog in Blog plugin which references the_title.

$data['post_title'] = apply_filters('the_title', $post->post_title);

Is there something I can do to make this work without also seeing the error?

3 Answers 3

2

I have this issue in some of my own plugins, and it's an easy fix. Basically, I label this a "lazy developer" issue. It's a matter of someone adding a filter but not taking optional parameters into account.

Step 1 - Edit the plugin file

The code that's breaking starts around line 639 (according to your debug info):

function pfund_handle_title( $atitle, $post_id ) {
    global $post;
    if ( ! pfund_is_pfund_post( ) || $post_id != $post->ID ){
        return $atitle;
    }
    return pfund_get_value( $_REQUEST, 'pfund-camp-title', $atitle );
}

What we need to do is change the function just a little bit to accept an omitted $post_id:

function pfund_handle_title( $atitle, $post_id = null ) {
    global $post;
    if ( null == $post_id || ! pfund_is_pfund_post( ) || $post_id != $post->ID ){
        return $atitle;
    }
    return pfund_get_value( $_REQUEST, 'pfund-camp-title', $atitle );
}

If no $post_id is supplied, we just return the title instead. It's essentially a short-circuit to insulate against lazy developers not submitting all of the proper data.

Step 2 - Submit a patch

Please send this code back to the original developer and ask it to be incorporated into future versions. Otherwise, when they release an update, you'll be forced to re-patch your code over and over again.

2
  • 1
    I wish I had a count of how many hours I've lost fixing plugins that were developed with debug mode off...
    – SickHippie
    Commented Mar 12, 2012 at 19:53
  • 3
    @SickHippie ... I can't count that high :-/
    – EAMann
    Commented Mar 12, 2012 at 20:12
1

Aren't both parameters of "the_title" filter required?

http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title

1
  • 1
    No, filter parameters are never “required”. They are offered to callbacks, that doesn’t mean a callback has to use them.
    – fuxia
    Commented Nov 27, 2012 at 4:32
0

If the plugin author doesn’t take the patch or fix the issue, and you want to run with clean logs, you may also be interested in Zack Tollman's Ostrichisize plugin. From the plugin description:

“If you have ever installed a plugin or worked on a site with a plugin that throws numerous of errors and notices, but do not have the time to fix the issue, you can turn off those notices with this plugin. By simply filtering the plugin, you can add to the list of plugins for which no notices will be shown.”

http://wordpress.org/extend/plugins/ostrichcize/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.