WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
1.1.6 update p2p_type value in DB are wrong. (13 posts)

  1. nikasama83
    Member
    Posted 2 years ago #

    hi scribu

    I have been using your plugin for a long time now and I never had any big problem with it. However i upgraded from 1.1.5 to 1.1.6 and now my OLD connections wont show neither in the admin when editing my CPT nor in my templates when trying to call connections.

    My DB wp_p2p table, p2p_type field shows a wrong value 'be5621a6d82960cdeb69d7b5338aa2d4' instead of 'sets2model'. Only the one connection i created after the 1.1.6 update is shown correctly. BTW all other fields are correct.

    this is the code i am using

    $connected = new WP_Query( array(
       'connected_type' => 'sets2model',
       'connected_items' => $post->ID,
    ) );
    
    if ( $connected->have_posts() ) : while( $connected->have_posts() ) : $connected->the_post();
    the_title();
    endwhile; endif;

    which gives me this: Warning: Invalid argument supplied for foreach() in /home/...../wp-content/plugins/posts-to-posts/core/query.php on line 95

    I also tried this with the same result.

    All connections were register as in here

    I noticed some other people were having this issue as well, I hope this info helps to figure out the problem.

    I know i can fix this manually in my DB, but i rather wait for you to say what will be the future of this issue for later releases.

    Thanks in Advance.

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Please post the exact call you make to p2p_register_connection_type().

  3. nikasama83
    Member
    Posted 2 years ago #

    before the update it was using init:

    function my_connection_types() {
        if ( !function_exists('p2p_register_connection_type') )
            return;
    
        p2p_register_connection_type(
    	array(
    		'id' => 'sets2model',
    		'from' => 'sets',
    		'to' => 'modelsprofile'
    	) );
    
    	p2p_register_connection_type(
    	array(
    		'id' => 'wall2model',
    		'from' => 'wallpapersextras',
    		'to' => 'modelsprofile'
    	) );
    }
    add_action('init', 'my_connection_types');

    after update i also tried this, wp_loaded:

    function my_connection_types() {
        if ( !function_exists('p2p_register_connection_type') )
            return;
    
        p2p_register_connection_type(
    	array(
    		'id' => 'sets2model',
    		'from' => 'sets',
    		'to' => 'modelsprofile'
    	) );
    
    	p2p_register_connection_type(
    	array(
    		'id' => 'wall2model',
    		'from' => 'wallpapersextras',
    		'to' => 'modelsprofile'
    	) );
    }
    add_action('wp_loaded', 'my_connection_types');

    Deactivated and activated plugin after this change.

  4. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    I'm not sure what exactly happened here but I added something to the development version (1.2-alpha) that should make it easier to fix these sorts of problems.

    After installing it, go to WP Admin -> Tools -> Connection Types and you should be able to fix the faulty connections.

  5. salocined
    Member
    Posted 2 years ago #

    Mmmm.
    Tried the update and also had the connection broken..
    Tried the alpha version, and Admin panel page is not really clear .

    All my connection are messed up.
    Having to roll back to 1.1.5 and DB backup.

    sorry Scribu

  6. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Tried the update and also had the connection broken..

    As in what exactly happened? Was the p2p_type column modified in any way? Did you get the "upgrade connections" notice?

    Admin panel page is not really clear.

    Would be useful to get a screenshot of it.

  7. salocined
    Member
    Posted 2 years ago #

    Ok,

    1/ I didnt get the Upgrade connection notice
    2/ I rolled back, but when I said not clear, I meant it was not 100% clear what existing connection should I select to update.

    I looked at my code, and one of the problem i think, is that the p2p_register_connection was not updated to reflect unique names.

    My current code is

    p2p_register_connection_type( array(
    	     'from' => 'post',
    	     'to' => 'expert',
                 'fields' => array(
          		'tptype' => 'TP Type'
          	),
          	'context' => 'advanced',
            'reciprocal' => true,
            'prevent_duplicates' => false
          ) );

    So, do you think I should
    1/ Update my p2p_register_connection_type to the most updated example
    2/ and then apply update 1.1.6?

    thx for your help

  8. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Yes, you should definitely add a 'name' parameter to your connection type.

    I thought you already did that, since you mentioned consultant_to_pages previously: http://wordpress.org/support/topic/plugin-posts-2-posts-connection-lost-after-upgrade?replies=2#post-2710718

  9. salocined
    Member
    Posted 2 years ago #

    different website....

    If adding a name, will it mean I will also need to update all the Connected query on the site?

    At the moment, on that site, I am only using
    'connected' => $post->ID in my qp_query args to find different connection depending on custom post types...

    If i could get away with that without having to specify the name of the connection, that will be great!

    Will try adding name anyway, to be compliant.

    thx

  10. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    If adding a name, will it mean I will also need to update all the Connected query on the site?

    Yes, and you'll also have to update the p2p_type column. The admin page should help with that (after you set the name).

    If i could get away with that without having to specify the name of the connection, that will be great!

    You can specify multiple connection types:

    'connected_type' => array( 'posts_to_pages', 'experts_to_articles' )

    etc.

  11. salocined
    Member
    Posted 2 years ago #

    nikasama83, sorry for hijacking your thread....

    What I did....

    1/ Added my names to p2p_register, and updated action to use wp_loaded
    2/ Tried to update plugin, WP sql error on page
    3/ Tried your Dev version to link connections, but the screen doesnt make sense, I dont get how to properly know which connection should be linked to, for example
    029b320d00eb783e4574bbc2cae0830a Convert to registered connection type:
    I have my 5 connections types, but how do I know what 029b320d00eb783e4574bbc2cae0830a should be equal to?
    also I have 7X 029b320d00eb783e4574bbc2cae0830a values, but only 5 connections type....

  12. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    This should help:

    http://wordpress.org/support/topic/plugin-posts-2-posts-all-existing-connection-gone?replies=15#post-2517920

    What would also probably help is setting one connection type name at a time.

  13. salocined
    Member
    Posted 2 years ago #

    yes back to original thread!

    Thx for your help...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic