WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Call to function error (17 posts)

  1. brandonferens
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. brandonferens
    Member
    Posted 1 year ago #

    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  ) );
  4. khanman225
    Member
    Posted 1 year ago #

    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
    	) );
  5. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    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

  6. Michelle
    Member
    Posted 1 year ago #

    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' );

    or

    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.

  7. khanman225
    Member
    Posted 1 year ago #

    @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.

  8. acsnaterse
    Member
    Posted 1 year ago #

    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' ) )
    		return;
    
    	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 :-)

  9. scribu
    Member
    Plugin Author

    Posted 1 year ago #

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

  10. scribu
    Member
    Plugin Author

    Posted 1 year ago #

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

  11. acsnaterse
    Member
    Posted 1 year ago #

    Yup, confirmed. Works here in 1.4.1-alpha.

    Thanks!

  12. Manuel Schmalstieg
    Member
    Posted 1 year ago #

    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.

  13. brandonferens
    Member
    Posted 1 year ago #

    Perfect! Thanks for the update.

  14. Christian
    Member
    Posted 1 year ago #

    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 !

    Thanks

  15. dangranata
    Member
    Posted 1 year ago #

    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.

    Thanks!

  16. scribu
    Member
    Plugin Author

    Posted 1 year ago #

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

    Should have started a new thread, though.

  17. dangranata
    Member
    Posted 1 year ago #

    The latest release - (WP 3.4.1, as noted above). I know get_current_screen is a core function and that it's a relatively new one, but I use it myself, and have never had a problem - which is why it is strange that it's throwing an error. It's almost like it's firing before WP functions are loaded, which seems impossible.

    Note taken about the new thread - sorry!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.