WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Posts 2 Posts] Problem upgrading from 1.1.5 to 1.1.6

[Plugin: Posts 2 Posts] Problem upgrading from 1.1.5 to 1.1.6

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

    @scribu

    None of the custom connected items show up where they used to.

    Please be more descriptive. What connection type do you have? Where were they supposed to show up? etc. etc.

    I have the same issue, but first I’m afraid I have to agree with “Really makes upgrading a huge roll of the dice” – minor version upgrades in P2P regularly break backwards compatibility. I don’t want to complain too much because it’s free and it’s a very useful plugin, but semantic version numbers and more information in the change log would be greatly appreciated!

    The first error I got after upgrading was this:

    Warning: Invalid argument supplied for foreach() in /.../posts-to-posts/core/query.php on line 95

    (Note: I get this error even when I’m not using P2P in the query at all, so I think that’s a separate bug.)

    Then I added this to the query:

    'connected_type' => 'case_studies_to_staff'

    That removed the error message, but now I get no results at all, the same as jtwg.

    I also changed 'connected_from' => get_queried_object_id(); to 'connected_items' => get_queried_object_id() as shown on the wiki, but it didn’t make a difference.

    My functions.php contains this:

    add_action('init', 'init_p2p', 100);
    function init_p2p() {
        p2p_register_connection_type(array(
            'name'  => 'case_studies_to_staff',
            'from'  => 'case-studies',
            'to'    => 'staff',
            'title' => 'Staff',
        ));
    }

    The widget looks like this (I have removed all irrelevant options):

    $query = new WP_Query(array(
        'post_type' => 'staff',
        'connected_type' = 'case_studies_to_staff',
        'connected_items' = get_queried_object_id(),
    ));

    This is what worked correctly in the previous version:

    $query = new WP_Query(array(
        'post_type' => 'staff',
        'connected_from' = get_queried_object_id(),
    ));

    If there’s anything else that would help debug it just let me know. For now I’m going to downgrade back to 1.1.5.

    Thanks
    Dave

    Plugin Author scribu

    @scribu

    Yeah, adding multiple connection type queries in a minor release was a mistake.

    $query = new WP_Query(array(
        'post_type' => 'staff',
        'connected_from' => get_queried_object_id(),
    ));

    Granted, this used to work, but it was intended only for the migration script, which sometimes fails, precisely because queries without a connection type are inexact.

    Let it be known: Queries without a ‘connected_type’ parameter are no longer supported.

    This should work:

    $query = new WP_Query(array(
        'connected_type' => 'case_studies_to_staff',
        'connected_items' => get_queried_object_id(),
    ));

    provided that get_queried_object_id() returns either a case study ID or a staff ID.

    Thanks for the reply, scribu.

    Question for you: I have a table full of already established connections – will your plugin update those rows to add the connected_type if I provide it in my connection registrations? Or will the connections need to be re-created?

    This is a problem I’ve run into a lot, needing to re-establish already present connections to provide missing values in the new fields.

    Please advise, thanks.

    P.S. agree with Dave about that I also don’t want to complain too much, for the same reasons he cites. I love this plugin, and use it on a great many sites. It’s incredibly useful. Semantic versioning and more explicit changelogs would definitely make it even more useful because the broken backwards compatibility really causes a lot of problems on production sites.

    Plugin Author scribu

    @scribu

    You said you were upgrading from 1.1.5 to 1.1.6, so all connections should already have the p2p_type column populated.

    If the connection type has no ‘name’ parameter when it’s defined, the p2p_type column will be filled with a generated hash.

    Here’s more info:

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

    I have similar woes with the 1.1.6 upgrade. In my case, I have nested loops that draw connected information from the $post->ID (as opposed to get_queried_object_id()). I have 3 Custom Post Types to to run an event system for a comedy festival: tscf-troupes, tscf-shows, and venues. Each show can have multiple troupes attached to it, but only one venue. Each troupe can be attached to multiple shows.

    Here’s what my template’s ‘single’ looks like for a particular “Troupe:”

    http://pastebin.com/vVWwYcR4

    The first query seeks to get all ‘tscf-shows’ that the current ‘tscf-troupe’ is attached to and display each.

    The second query is a sub-query that seeks to get the ‘venues’ that is attached to each show that is returned in the first query, and output its address.

    The third query, also a sub-query, seeks to find the name of each ‘tscf-troupe’ that is featured on each show from the first query, and output a link to that troupe’s page. (The current troupe would also output in this list with a link to the current page).

    Now – prior to the 1.1.6 upgrade, these all worked smoothly. Should I downgrade to 1.1.5? If so, I’m committing myself to sticking with that version and I’m not sure that’s the best idea.

    Any ideas here would be very much appreciated.

    Plugin Author scribu

    @scribu

    That looks like correct usage. Will investigate soon.

    For the nested loops, you should try using each_connected():

    https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop

    (added an example for using it multiple times on the same outer query)

    In this case, is ‘actors’ the name of the post_type?

    p2p_type( 'movies_to_actors' )->each_connected( $my_query, array(), 'actors' );

    Plugin Author scribu

    @scribu

    No, it’s the key used to store the list of actors on the $post object: $post->actors.

    Also, I presume that:
    p2p_list_posts( $post->actors );

    simply outputs a list of links to associated posts.

    In the example I am using above, I used to be able to loop over the results and access the post_meta for each to output, for example, a link to a map that is generated using a custom field for the venue’s address.

    Plugin Author scribu

    @scribu

    foreach ( $post->actors as $post ) {
      setup_postdata( $post );
    
      print_r( get_post_meta( $post->ID ) );
      ...
    }
    
    wp_reset_postdata();

    Would you like some fries with that?

    Well… no wonder I wasn’t getting my pages as I had thought they should be. All of my existing connections have been blown out.

    Plugin Author scribu

    @scribu

    Define “blown out”.

    All connected posts previously entered have been disassociated from one another. In my example, an entry for a post_type of ‘tscf-show’ would be connected to a number of ‘tscf-troupes’ entries, and one ‘venues’ entry. This update has resulted in the connections I’d made in the past no longer being present.

    Plugin Author scribu

    @scribu

    I don’t think that’s accurate. They should still be in the wp_p2p table.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Plugin: Posts 2 Posts] Problem upgrading from 1.1.5 to 1.1.6’ is closed to new replies.