devinsays / options-framework-plugin

An Options Panel Framework to help speed theme development.
https://wptheming.com
835 stars 286 forks source link

optionsframework_update_to_version_1_5() Removing Attachments From Custom Post Types #146

Closed wpexplorer closed 11 years ago

wpexplorer commented 11 years ago

When I updated the plugin the optionsframework_update_to_version_1_5() actually unattached all images that were attached to any custom post type on the site.

Anyone else have this problem?

devinsays commented 11 years ago

It should just be for optionsframework post types:

    // Get all the optionsframework post type
    $query = new WP_Query( array(
        'post_type' => 'optionsframework',
        'numberposts' => -1,
    ) );

I'll test it out and see what is going on.

devinsays commented 11 years ago

I have not been able to find the reason why it would be doing this. I added the update routine back in the latest commit (on GitHub).

A couple things I tried when debugging:

1) var_dump $query on line 40 of upgrade.php (this should only output optionsframework post types) 2) echo something in the while loop, it should only enter this if optionsframework post types were present 3) var_dump $attachments. this should only output attachment posts that are attached to an optionsframework post

wpexplorer commented 11 years ago

When I activate I see something like the image attached update

I'm assuming this is the list of the ID's - not sure why it's on the front-end...

Then I refresh my dashboard and all images are no longer attached to my posts.

It does seem strange.

I have some photography themes that rely on image attachements for the galleries. So anyone that updates the Options Framework will now have a bunch of blank posts ;(

wpexplorer commented 11 years ago

Is it possible the function is running before the post type is registered and causing the issue?

devinsays commented 11 years ago

Just pushed an update to .org that removes the update routine. Not sure why this wasn't working- but definitely don't want to cause issues with people currently using the plugin.