Checked the queries. Most were fine. Closes #1834.

This commit is contained in:
Mike Jolley 2012-11-28 16:56:00 +00:00
parent f578c5fbfd
commit 171730d405
3 changed files with 9 additions and 9 deletions

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wpdb, $woocommerce;
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
$results = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
if ( $results ) foreach ( $results as $result ) {

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wpdb, $woocommerce;
// Upgrade old style files paths to support multiple file paths
$existing_file_paths = $wpdb->get_results( "SELECT * FROM ". $wpdb->postmeta . " WHERE meta_key = '_file_path'" );
$existing_file_paths = $wpdb->get_results( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_file_path'" );
if ( $existing_file_paths ) {
@ -26,17 +26,17 @@ if ( $existing_file_paths ) {
else
$file_paths = '';
$wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_file_paths', meta_value = %s WHERE meta_id = %d", $file_paths, $existing_file_path->meta_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_file_paths', meta_value = %s WHERE meta_id = %d", $file_paths, $existing_file_path->meta_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "woocommerce_downloadable_product_permissions SET download_id = %s WHERE product_id = %d", md5( $existing_file_path->meta_value ), $existing_file_path->post_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions SET download_id = %s WHERE product_id = %d", md5( $existing_file_path->meta_value ), $existing_file_path->post_id ) );
}
}
// Update table primary keys
$wpdb->query( "ALTER TABLE ". $wpdb->prefix . "woocommerce_downloadable_product_permissions DROP PRIMARY KEY" );
$wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions DROP PRIMARY KEY" );
$wpdb->query( "ALTER TABLE ". $wpdb->prefix . "woocommerce_downloadable_product_permissions ADD PRIMARY KEY ( `product_id` , `order_id` , `order_key` , `download_id` )" );
$wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions ADD PRIMARY KEY ( `product_id` , `order_id` , `order_key` , `download_id` )" );
// Setup default permalinks if shop page is defined
$permalinks = get_option( 'woocommerce_permalinks' );

View File

@ -27,10 +27,10 @@ function woocommerce_order_downloads_meta_box() {
<div class="wc-metaboxes">
<?php
$download_permissions = $wpdb->get_results( "
$download_permissions = $wpdb->get_results( $wpdb->prepare( "
SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions
WHERE order_id = $post->ID ORDER BY product_id
" );
WHERE order_id = %d ORDER BY product_id
", $post->ID ) );
$product = null;
if ( $download_permissions && sizeof( $download_permissions ) > 0 ) foreach ( $download_permissions as $download ) {