WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] All existing connection gone? (36 posts)

  1. Zhen
    Member
    Posted 2 years ago #

    Just upgraded to 1.1.3 and found all the existing connections are gone and I have to click into every post to connect again. Wonder if it is a bug or there are some new features that I missed. PS. Is there a way to batch set up connections? Thanks!

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    If you were updating from P2P 1.0.1 or older, you should have seen a prompt to upgrade your connections as well. Are you on multisite?

  3. Zhen
    Member
    Posted 2 years ago #

    Thanks scribu, it looks like the previous update does work very well. I did seen the upgrade connection button but it said 0 connections were updated. Anyway, I will update those connections manually since there are just few of them. Thanks again for this great plugin!

  4. Florian Mueller
    Member
    Posted 2 years ago #

    Hi scribu, i have the same issue. I am on multisite and updated from 1.1.2. I am not sure if i got the update notice. But now all my connections are not showing in the damin boxes. They are still there and connected posts can be found in frontend. But only the admin boxes are empty. Is it possible to do the connection updates manually somehow?

  5. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Something really strange is going on. Another user reported that they see connections in the admin box, but not in the front-end:

    http://wordpress.org/support/topic/plugin-posts-2-posts-bug-in-113

    You can check the p2p_type column in the wp_p2p table using phpMyAdmin.

  6. Florian Mueller
    Member
    Posted 2 years ago #

    Ok, i see that none of the connections has a p2p_type. What can i do now? I have 1364 connections applied in the database (thats totaly correct :) ). I can not change every connection by hand.

  7. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    If all the p2p_type columns are blank, then you shouldn't see any connections on the front-end either.

    You can try this:

    1. Go to /wp-admin/options.php
    2. Find the p2p_storage option.
    3. Change the value to 3.
    4. Press Update.

    You should then see a notice to upgrade the connections.

  8. matthewcolab
    Member
    Posted 2 years ago #

    Hi. I updated to wordpress 3.3 and upgraded the plugin to 1.1.3 and all my connections have been erased. They are still in the database, but in the admin screens AND on the front end, they are not showing up. I went to options.php and changed the p2p_storage to 3 and was prompted to Proceed with updating the connections. However, when i click on that, it says "Upgraded 0 connections" and still my posts are not connected.

    The p2p table shows all the to and from connections with p2p types.

  9. matthewcolab
    Member
    Posted 2 years ago #

    Also, tried doing a var_dump( post_type_exists( 'posttype' ) ); exit; and it returned bool(false) bool(false) bool(false).

    UPDATE: Sorry, my init priorities between custom post types and the registering p2p relation weren't in the correct order. Now they are, and it's returning true, but the problem still exists. No connections on admin panel or front end, but I can still see them in the database.

  10. matthewcolab
    Member
    Posted 2 years ago #

    Do you know what would cause it to not show the connections on the admin panel and front end, but they still exist in the database?

  11. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    So the p2p_type column is populated properly.

    Do the P2P boxes in the admin not show up at all or do they show up with no connections?

    Did you try adding define( 'WP_DEBUG', true ); in your wp-config.php?

  12. matthewcolab
    Member
    Posted 2 years ago #

    The P2P boxes show up, just without the connections. I'm curious: what is the p2p_type column in the database? Is it a hash and how does it get generated?

    This happened last time i updated, and i went in and manually redid the connections. They keep until updating this plugin, and the problem occurs again.

    Debug mode showed a couple warnings, nothing really related:

    Notice: Undefined index: post in /mnt/target02/349133/606198/www.selectproperties.com/web/content/wp/wp-content/themes/selectproperties/functions/meta-box/meta-box-usage.php on line 449
    
    Notice: Undefined index: post_ID in /mnt/target02/349133/606198/www.selectproperties.com/web/content/wp/wp-content/themes/selectproperties/functions/meta-box/meta-box-usage.php on line 449
    
    Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /mnt/target02/349133/606198/www.selectproperties.com/web/content/wp/wp-includes/functions.php on line 3458
    
    Notice: Use of undefined constant core_mods - assumed 'core_mods' in /mnt/target02/349133/606198/www.selectproperties.com/web/content/wp/wp-content/themes/selectproperties/functions.php on line 42
    
    Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /mnt/target02/349133/606198/www.selectproperties.com/web/content/wp/wp-includes/functions.php on line 3578
  13. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    what is the p2p_type column in the database? Is it a hash and how does it get generated?

    It's the name of the connection type. If you don't set the 'name' parameter when calling p2p_register_connection_type(), it generates a hash based on the other arguments.

  14. matthewcolab
    Member
    Posted 2 years ago #

    Firstly, thanks scribu you got me going in the right direction.

    The issue ended up being that I wasn't setting the name of the connection type, one of the paramaters that makes up the hash must have changed on update. This resulted in a different hash after the update, and the apparent "loss" of data that I was experiencing.

    To fix without reentering data:
    I changed the name of my connection in the p2p_register_connection_type to whatever it was going to be, then looked in my wp_p2p table to find what the hash types hook up to using a query like this one:

    SELECT DISTINCT p2p_type,  fromtype.post_type AS fromtype,  totype.post_type AS totype
    from wp_p2p
    inner join wp_posts as fromtype ON wp_p2p.p2p_from = fromtype.ID
    inner join wp_posts as totype ON wp_p2p.p2p_to = totype.ID

    Then after determining which hash type relates to which connection name, run this on each one to update

    UPDATE wp_p2p SET
    p2p_type = "nameofconnection"
    WHERE p2p_type="f79b8d19b8b7dc1b5b357bd518c8d620";

    Let me know if this ends up helping anyone having the same problem

  15. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Note that you can find the current hash without doing a query:

    $my_connection_type = p2p_register_connection_type( array(
      ...
    ) );
    
    var_dump( $my_connection_type->name );
  16. matthewcolab
    Member
    Posted 2 years ago #

    the problem wasn't that we couldn't figure out the current hash, the problem I was experiencing was that the hash was changing - I needed to find a listing of orphaned hashes so that I could recover my relations without re-entering them.

    Which I guess brings me to my next question: what paramaters get combined to make the hash? I still don't know for sure what paramater it was that changed to result in a different hash.

  17. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    The relevant code is in core/type-factory.php (line 48).

    I think the cause was that in 1.1.3 'some_post_type' is converted to array( 'some_post_type' ), which is enough to generate a different hash.

    That's why it's better to always give an explicit name to your connection types.

  18. djhsecondnature
    Member
    Posted 2 years ago #

    I'm still having this issue. I have update my p2p_type column so it has a defined name (and the code in functions.php to go with it, but I still can't see any connections in the metabox.

    Their connections are being stored correctly in the database, and their effects are working on the front end, so it's just the population in the metabox in WordPress.

  19. 10sexyapples
    Member
    Posted 2 years ago #

    @matthewcolab
    Thank you a million times over ... I'm so tight on a launch deadline, and I upgraded only to lose the hundreds of connections my client made ... *whew* ... sooooooo happy you were thoughtful enough to post your solution ... saved me much needed time and a very big headache ;-)

  20. reneelung
    Member
    Posted 2 years ago #

    Hi Scribu,

    So far I've followed the instructions you've given here, but I am hesitant to fill in the empty p2p_type column with my own hash. I've updated WordPress and the plugin to the lastest versions, tried setting p2p_storage to 3 and also explicitly naming each connection. However, all my connections are gone from both the front end and the backend. Is there anything else I can try? Also, it seems like p2p_storage doesn't stay set to 3, it goes back to 4 when I check, and when I click "Update Connections," it says "0 connections updated."

    Thanks!

  21. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    You shouldn't fill the p2p_type column with a hash. You should fill it with whatever you set as the 'name' parameter when you registered the connection type.

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

  22. reneelung
    Member
    Posted 2 years ago #

    Thanks for the speedy reply!

    I guess the problem is, I have a LOT of connections (in the 100s) that all disappeared after the upgrade and the p2p_type column is empty. In order to fill the column using SQL directly, I would have to cross-reference the id of every post/page that used to be connected to another...is there any way to reinitialize the plugin so that it registers the connections and uses the 'name' parameter I specified? (Oh yes, I forgot to mention that I did try explicitly naming the connection as well.)

    Thanks!

  23. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    is there any way to reinitialize the plugin so that it registers the connections and uses the 'name' parameter I specified?

    Well, assuming you've named all your connection types, here's what you do:

    1. Upgrade to the development version (1.2-alpha2) - it fixes a bug in the update script.
    2. Empty the p2p_type column: UPDATE wp_p2p SET p2p_type = ''
    3. Set p2p_storage to 3, like you did previously.
    4. Run "Update Connections".

  24. reneelung
    Member
    Posted 2 years ago #

    All right, so far so good. I followed your instructions and now the wp_p2p table has been populated with the names of the connections that I specified. The last piece of the puzzle: the connections are not showing up in the post-editing screens. To double checked, I cross-referenced a pair of connected posts according to their IDs from the table and the connection makes sense. However, neither of their editing screens show the connection.

  25. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    So you see the P2P admin boxes and can create new connections using them, right?

    Do the connections show up on the front-end?

  26. reneelung
    Member
    Posted 2 years ago #

    Well, the connections show up in the front-end, but they are the wrong ones and are the same ones for all posts of the same type. I haven't had the chance to update my function calls yet though.

    Just tried making new connections in the admin boxes--no luck. The spinner shows up when I search, but it can't find the custom post types I am trying to connect, and won't connect anything.

    Thanks again for your time, I really appreciate your help with this.

  27. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Yeah, the admin box search should be fixed in 1.2-alpha3.

  28. reneelung
    Member
    Posted 2 years ago #

    Hey Scribu, I installed 1.2-alpha3 as you suggested, but still no luck with the connection boxes in the admin area. The previous problem of incorrect connections on the front end is still persisting.

    Thanks.

  29. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Please share your p2p_register_connection_type() call in a http://pastebin.com/

  30. reneelung
    Member
    Posted 2 years ago #

    Is this what you need? http://pastebin.com/iFf4YQ80

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic