Checked the queries. Most were fine. Closes #1834.
This commit is contained in:
parent
f578c5fbfd
commit
171730d405
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
global $wpdb, $woocommerce;
|
global $wpdb, $woocommerce;
|
||||||
|
|
||||||
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
|
// 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 ) {
|
if ( $results ) foreach ( $results as $result ) {
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
global $wpdb, $woocommerce;
|
global $wpdb, $woocommerce;
|
||||||
|
|
||||||
// Upgrade old style files paths to support multiple file paths
|
// 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 ) {
|
if ( $existing_file_paths ) {
|
||||||
|
|
||||||
|
@ -26,17 +26,17 @@ if ( $existing_file_paths ) {
|
||||||
else
|
else
|
||||||
$file_paths = '';
|
$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
|
// 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
|
// Setup default permalinks if shop page is defined
|
||||||
$permalinks = get_option( 'woocommerce_permalinks' );
|
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||||
|
|
|
@ -27,10 +27,10 @@ function woocommerce_order_downloads_meta_box() {
|
||||||
<div class="wc-metaboxes">
|
<div class="wc-metaboxes">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$download_permissions = $wpdb->get_results( "
|
$download_permissions = $wpdb->get_results( $wpdb->prepare( "
|
||||||
SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions
|
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;
|
$product = null;
|
||||||
if ( $download_permissions && sizeof( $download_permissions ) > 0 ) foreach ( $download_permissions as $download ) {
|
if ( $download_permissions && sizeof( $download_permissions ) > 0 ) foreach ( $download_permissions as $download ) {
|
||||||
|
|
Loading…
Reference in New Issue