Multiple plugins failing on reference to $metadata['sizes']
-
I upgraded a site to 3.2.1 last night. This morning I had matching php errors in both WP-e-commerce and scissors-continued.
The error I got with WP-e-Commerce was:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in/…/wp-content/plugins/wp-e-commerce/wpsc-admin/includes/display-items-functions.php on line 1018
I found an answer at http://getshopped.org/forums/topic.php?id=22342
if ( ! image_get_intermediate_size( $post->ID, $check ) ) { $metadata = wp_get_attachment_metadata( $post->ID ); $file = get_attached_file( $post->ID ); $generated = wp_generate_attachment_metadata( $post->ID, $file ); $metadata['sizes'] = array_merge( $generated['sizes'], $metadata['sizes'] ); wp_update_attachment_metadata( $post->ID, $metadata ); }
Replace it with:
if ( ! image_get_intermediate_size( $post->ID, $check ) ) { $metadata = wp_get_attachment_metadata( $post->ID ); $file = get_attached_file( $post->ID ); $metadata = array_merge( wp_generate_attachment_metadata( $post->ID, $file ), $metadata ); wp_update_attachment_metadata( $post->ID, $metadata ); }
The errors I got with Scissors-continued are:
Warning: Invalid argument supplied for foreach() in /…/wp-content/plugins/scissors-continued/scissors.php on line 454
Warning: Invalid argument supplied for foreach() in /…/wp-content/plugins/scissors-continued/scissors.php on line 1013
Warning: array_keys() [function.array-keys]: The first argument should be an array in /…/wp-content/plugins/scissors-continued/scissors.php on line 1083
The lines of code referenced in Scissors-contined are
line 454: foreach($metadata['sizes'] as $s => $value) line 1013: foreach($metadata['sizes'] as $size => $value) line 1083: $sizes = (is_array($metadata) && isset($metadata['sizes']) && count($metadata['sizes']) > 0) ? array_keys($metadata['sizes']) : array();
which all look eerily like the code in wp-c-commerce:
$metadata['sizes'] = array_merge( $generated['sizes'], $metadata['sizes'] ); wp_update_attachment_metadata( $post->ID, $metadata );
Everything worked fine before my 3.2.1 upgrade, and afterwards two plugins by two different authors both went pear-shaped using the same reference. Hmmmm.
The post at GetShopped.org/forums indicated the problem was 2 weeks old.
I tracked a similar post for scissors-continued at http://wordpress.org/support/topic/can-insert-product-image, which was 5 days ago.
I have not looked thoroughly to see, but there could be a collection of plugin-specific posts indicating a systemic problem.
So…
1. How wide-spread is this?
2. Is there a generalized (i.e. WordPress) patch for this?
3. Does anybody have a working fix for scissors-continued?Thanks
- The topic ‘Multiple plugins failing on reference to $metadata['sizes']’ is closed to new replies.