Support » Plugins and Hacks » [Resolved] [Plugin: Posts 2 Posts] Call to function error

[Resolved] [Plugin: Posts 2 Posts] Call to function error

  • Here is the error that I am getting. This happened upon upgrading from 1.3 to 1.4.

    Fatal error: Call to a member function get_object() on a non-object in /home/perfects/public_html/inewsource.perfectspacedev.com/wp-content/plugins/posts-to-posts/core/directed-type.php on line 132

    This is happening on a custom post called Articles. Let me know if you would like access to our dev environment so you can check it out yourself.


Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author scribu


    Well, access to the dev environment would be good, but I’d like to try reproducing it locally first.

    Please share the p2p_register_connection_type() call that you think is causing the problem.

    I’m guessing it is one of these:

    p2p_register_connection_type( array('name' => 'projects_to_articles', 'from' => 'project', 'to' => 'article', 'reciprocal' => true  ) );
    p2p_register_connection_type( array('name' => 'articles_to_articles', 'from' => 'article', 'to' => 'article', 'reciprocal' => true  ) );
    p2p_register_connection_type( array('name' => 'articles_to_data-sets',  'from' => 'article', 'to' => 'data-set', 'reciprocal' => true  ) );

    Same problem on upgrade.

    Here are my registration function calls:

    p2p_register_connection_type( array(
    		'name' => 'actors_to_tv-shows',
    		'from' => 'actors',
    		'to' => 'tv-shows',
    		'reciprocal' => true,
    		'fields' => array(
    			'character' => array('title' => 'Character', 'type' => 'text')
    	) );
    	p2p_register_connection_type( array(
    		'name' => 'clothing_to_actors',
    		'from' => 'clothing',
    		'to' => 'actors',
    		'reciprocal' => true
    	) );
    	p2p_register_connection_type( array(
    		'name' => 'clothing_to_tv-shows',
    		'from' => 'clothing',
    		'to' => 'tv-shows',
    		'reciprocal' => true
    	) );
    	p2p_register_connection_type( array(
    		'name' => 'clothing_to_clothing',
    		'from' => 'clothing',
    		'to' => 'clothing',
    		'reciprocal' => true
    	) );
    Plugin Author scribu


    I can’t reproduce the error with either connection type sets.

    So, brandonferens, if you can give me access to your dev site, my email is mail AT scribu.net

    Just a thought, it may be the add_action call for the register-connection function you’re using which causes the error. When I tried using anything other than wp_loaded:

    add_action( 'wp_loaded', 'my_connection_types' );

    that’s the error I saw. For instance when I tried

    add_action( 'init', 'my_connection_types' );


    add_action( 'p2p_init', 'my_connection_types' );

    I got that error. I could be totally off-base, just thought I’d mention it in case it’s useful.

    @mmcginnis – I still get the same error when using the different hooks.

    @scribu – If I comment out the clothing-to-actors call then the error is gone on the edit actor page and the edit clothing page (but still on the edit tv shows page). Not sure if that helps.

    Just for the info: Got the same issue here after upgrading. Changing the hooks didn’t work for me either.

    This is the code that I’m using:

    function uprs_connection_types() {
    	// Make sure the Posts 2 Posts plugin is active.
    	if ( !function_exists( 'p2p_register_connection_type' ) )
    	p2p_register_connection_type( array(
    		'name' => 'reviews_to_products',
    		'from' => 'review',
    		'to' => 'product',
    		'reciprocal' => true
    	) );
    add_action( 'p2p_init', 'uprs_connection_types' );

    So, if there’s an outcome, please share 🙂

    Plugin Author scribu


    I was able to reproduce the error locally. Working on a fix.

    Plugin Author scribu


    Should be fixed in the development version (1.4.1-alpha).

    Yup, confirmed. Works here in 1.4.1-alpha.


    Yup, I got the same issue with the 1.4 update (only in the admin interface though, on the public facing pages everything worked fine).

    The 1.4.1-alpha fixed it.

    Perfect! Thanks for the update.

    Great, I got the same problem.. but as I upgraded in same time Event manager plugin, I was so disapointed ..
    All is working now qith the alpha !




    I’m getting a strange error – which seems to be isolated to a single (local) install with a custom theme. I’m fully prepared to fix my code, I’m just not sure where to begin.

    WP 3.4.1
    P2P 1.4.2-alpha2 (also happened with 1.4.1, but not previous versions)

    Upon activation, I get a fatal error:

    Call to undefined function get_current_screen() in [localpath]/wp-content/plugins/posts-to-posts/core/url-query.php on line 27

    I deactivated all other plugins, same error. I did try this with a different install (one that has no P2P connections yet), and there was no problem.

    Temporarily commenting out the following lines seemed to fix the problem (lines 12-13 in posts-to-posts/core/url-query.php):

    if ( is_admin() )
    			add_action( 'pre_user_query', array( __CLASS__, 'user_query' ), 9 );

    But I really would rather ensure the problem won’t crop up again once we upgrade. I know not knowing specifics about my install will make it difficult to diagnose, but I’m crawling line by line through any P2P code and I can’t figure out what would trigger that error – so I’m hoping that it might be caused by something obvious (an action hooked too early?) that changed in the most recent version.


    Plugin Author scribu


    Yes, that’s really strange, since get_current_screen() is a core WordPress function.

    Should have started a new thread, though.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] [Plugin: Posts 2 Posts] Call to function error’ is closed to new replies.