Fatal Error since WP 3.3 upgrade

Plugin SupportForumsConvert Post TypesFatal Error since WP 3.3 upgrade

Tagged: 

This topic has 5 voices, contains 11 replies, and was last updated by  Stephanie 7 days ago.

Viewing 12 posts - 1 through 12 (of 12 total)
Author Posts
Author Posts
January 3, 2012 at 7:57 am #588

markjames

Since upgrading to WordPress 3.3 I am getting a fatal error when I try to convert a a post type.

Fatal error: Cannot redeclare bulk_convert_posts_add_pages() (previously declared in /home/*******/wp-content/plugins/convert-post-types/convert-post-types.php:15) in /home/******/wp-content/plugins/convert-post-types/convert-post-types.php on line 17

Can you assist please – there was a similar error with the plugin Post Type Convertr and the author has fixed that plugin (if that helps – here’s the thread – read more)

January 3, 2012 at 10:12 pm #589

cyberhobo

I’ve created a patch that fixes this problem for me:

Index: convert-post-types.php
===================================================================
--- convert-post-types.php (revision 482452)
+++ convert-post-types.php (working copy)
@@ -12,7 +12,7 @@
add_action('admin_menu', 'bulk_convert_posts_add_pages');

function bulk_convert_posts_add_pages() {
- $css = add_management_page(__('Convert Post Types', 'convert-post-types'), __('Convert Post Types', 'convert-post-types'), 'manage_options', __FILE__, 'bulk_convert_post_type_options');
+ $css = add_submenu_page( 'tools.php', __('Convert Post Types', 'convert-post-types'), __('Convert Post Types', 'convert-post-types'), 'manage_options', 'convert-post-types-admin-page', 'bulk_convert_post_type_options');
add_action("admin_head-$css", 'bulk_convert_post_type_css');
}

@@ -54,7 +54,7 @@
$typeselect .= "";
}
?>
-
+

@@ -75,6 +75,7 @@
name, array('nav_menu', 'link_category', 'podcast_format'))) : ?>
name)) :
// non-hierarchical
$nonhierarchical .= ''.esc_html($tax->label).'';
@@ -121,14 +122,14 @@

function bulk_convert_posts() {
global $wpdb, $wp_taxonomies, $wp_rewrite;
- $q = 'numberposts=-1&post_status=any&post_type='.$_POST['post_type'];
+ $q = 'numberposts=-1&post_status=any&post_type='.$_POST['old_post_type'];
if (!empty($_POST['convert_cat'])) $q .= '&category='.$_POST['convert_cat'];
if (!empty($_POST['page_parent'])) $q .= '&post_parent='.$_POST['page_parent'];

$items = get_posts($q);
foreach ($items as $item) {
// Update the post into the database
- $wpdb->update( $wpdb->posts, array( 'post_type' => $_POST['new_post_type']), array( 'ID' => $item->ID, 'post_type' => $_POST['post_type']), array( '%s' ), array( '%d', '%s' ) );
+ $wpdb->update( $wpdb->posts, array( 'post_type' => $_POST['new_post_type']), array( 'ID' => $item->ID, 'post_type' => $_POST['old_post_type']), array( '%s' ), array( '%d', '%s' ) );
// $wpdb->print_error();
echo ''.__("Converted ", 'convert-post-types').$item->ID.": ".$item->post_title.'.';

@@ -156,4 +157,4 @@
// i18n
$plugin_dir = basename(dirname(__FILE__)). '/languages';
load_plugin_textdomain( 'convert-post-types', WP_PLUGIN_DIR.'/'.$plugin_dir, $plugin_dir );
-?>
\ No newline at end of file
+?>

January 4, 2012 at 7:00 am #590

markjames

How do I get the patch to work

January 5, 2012 at 10:33 am #593

cyberhobo

Some info on how to manually apply a patch here may help.

Hopefully our plugin author will incorporate it in the next release :)

  • This reply was modified 104 days ago by  cyberhobo.
February 23, 2012 at 12:38 pm #608

cliffseal

I believe I’ve patched it up. Change:

Line 124 to:
$q = 'numberposts=-1&post_status=any&post_type='.$_POST['old_post_type'];

And Line 131 to:
$wpdb->update( $wpdb->posts, array( 'post_type' => $_POST['new_post_type']), array( 'ID' => $item->ID, 'post_type' => $_POST['post_type']), array( '%s' ), array( '%d', '%s' ) );

HT to cyberhobo, but my solution is a bit less involved. :)

February 23, 2012 at 12:52 pm #611

cliffseal

I can’t edit the comment for whatever reason. I incorrectly posted. This is the correct Line 131 change:
$wpdb->update( $wpdb->posts, array( 'post_type' => $_POST['new_post_type']), array( 'ID' => $item->ID, 'post_type' => $_POST['old_post_type']), array( '%s' ), array( '%d', '%s' ) );

March 25, 2012 at 3:13 pm #629

mhilland

i’ve applied the patch outlined by cyberhobo manually. however, i’m getting a new error now saying “Cannot load convert-post-types-admin-page.” it looks like the code added by the patch created this error. my knowledge of PHP isn’t sufficient to figure out what’s wrong here. i’m desperate to get this plugin to work, it will save me hours of manual labor!

if someone has gotten this to work, could you point to a link with the .php?

any help is appreciated. thanks!

  • This reply was modified 24 days ago by  mhilland.
March 25, 2012 at 3:45 pm #631

mhilland

just found this plugin that works great for converting both post types as well as categories to custom taxonomies! ->

http://wordpress.org/extend/plugins/post-type-converter/

March 25, 2012 at 4:02 pm #632

cliffseal

mhilland, I didn’t use any of cyberhobo’s patch—I only needed to change those two lines. It sounds like either something is bad on the bulk_convert_posts_add_pages function, or you’re running a different version of WordPress.

Either way, if you don’t need the bulk feature of this plugin, then Post Type Converter or Post Type Switcher are definitely the way to go anyway.

March 25, 2012 at 4:08 pm #633

mhilland

actually, the post type converter works for bulk conversions. perhaps they updated it since the last time you used it.

March 25, 2012 at 4:14 pm #634

cliffseal

Ah, you must mean this one: http://wordpress.org/extend/plugins/post-type-convertr

That’s good looking! The other Post Type Converter plugin (with an ‘e’) only adds a meta box to the post page.

April 11, 2012 at 10:59 pm #637

Stephanie

This bug is fixed in 1.2, which I just posted to Extend. Thanks very much for your patience, everyone!

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.