get rid of old term meta table
This commit is contained in:
parent
d8fe798825
commit
8823559880
|
@ -49,7 +49,6 @@ class WC_Admin_Taxonomies {
|
||||||
|
|
||||||
// Category/term ordering.
|
// Category/term ordering.
|
||||||
add_action( 'create_term', array( $this, 'create_term' ), 5, 3 );
|
add_action( 'create_term', array( $this, 'create_term' ), 5, 3 );
|
||||||
add_action( 'delete_term', array( $this, 'delete_term' ), 5 );
|
|
||||||
|
|
||||||
// Add form.
|
// Add form.
|
||||||
add_action( 'product_cat_add_form_fields', array( $this, 'add_category_fields' ) );
|
add_action( 'product_cat_add_form_fields', array( $this, 'add_category_fields' ) );
|
||||||
|
@ -107,13 +106,7 @@ class WC_Admin_Taxonomies {
|
||||||
* @param mixed $term_id Term ID.
|
* @param mixed $term_id Term ID.
|
||||||
*/
|
*/
|
||||||
public function delete_term( $term_id ) {
|
public function delete_term( $term_id ) {
|
||||||
global $wpdb;
|
wc_deprecated_function( 'delete_term', '3.6' );
|
||||||
|
|
||||||
$term_id = absint( $term_id );
|
|
||||||
|
|
||||||
if ( $term_id && get_option( 'db_version' ) < 34370 ) {
|
|
||||||
$wpdb->delete( $wpdb->woocommerce_termmeta, array( 'woocommerce_term_id' => $term_id ), array( '%d' ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -861,11 +861,6 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_category', __( 'Could not delete the category', 'woocommerce' ), 401 );
|
throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_category', __( 'Could not delete the category', 'woocommerce' ), 401 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a term is deleted, delete its meta.
|
|
||||||
if ( get_option( 'db_version' ) < 34370 ) {
|
|
||||||
$wpdb->delete( $wpdb->woocommerce_termmeta, array( 'woocommerce_term_id' => $id ), array( '%d' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
do_action( 'woocommerce_api_delete_product_category', $id, $this );
|
do_action( 'woocommerce_api_delete_product_category', $id, $this );
|
||||||
|
|
||||||
return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_category' ) );
|
return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_category' ) );
|
||||||
|
|
|
@ -698,10 +698,6 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( get_option( 'db_version' ) < 34370 ) {
|
|
||||||
$core_tables[] = 'woocommerce_termmeta';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adding the prefix to the tables array, for backwards compatibility.
|
* Adding the prefix to the tables array, for backwards compatibility.
|
||||||
*
|
*
|
||||||
|
|
|
@ -540,7 +540,6 @@ class WC_Install {
|
||||||
*
|
*
|
||||||
* Tables:
|
* Tables:
|
||||||
* woocommerce_attribute_taxonomies - Table for storing attribute taxonomies - these are user defined
|
* woocommerce_attribute_taxonomies - Table for storing attribute taxonomies - these are user defined
|
||||||
* woocommerce_termmeta - Term meta table - sadly WordPress does not have termmeta so we need our own
|
|
||||||
* woocommerce_downloadable_product_permissions - Table for storing user and guest download permissions.
|
* woocommerce_downloadable_product_permissions - Table for storing user and guest download permissions.
|
||||||
* KEY(order_id, product_id, download_id) used for organizing downloads on the My Account page
|
* KEY(order_id, product_id, download_id) used for organizing downloads on the My Account page
|
||||||
* woocommerce_order_items - Order line items are stored in a table to make them easily queryable for reports
|
* woocommerce_order_items - Order line items are stored in a table to make them easily queryable for reports
|
||||||
|
@ -822,22 +821,6 @@ CREATE TABLE {$wpdb->prefix}wc_download_log (
|
||||||
PRIMARY KEY (download_log_id),
|
PRIMARY KEY (download_log_id),
|
||||||
KEY permission_id (permission_id),
|
KEY permission_id (permission_id),
|
||||||
KEY timestamp (timestamp)
|
KEY timestamp (timestamp)
|
||||||
) $collate;
|
|
||||||
";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Term meta is only needed for old installs and is now @deprecated by WordPress term meta.
|
|
||||||
*/
|
|
||||||
if ( ! function_exists( 'get_term_meta' ) ) {
|
|
||||||
$tables .= "
|
|
||||||
CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
|
|
||||||
meta_id BIGINT UNSIGNED NOT NULL auto_increment,
|
|
||||||
woocommerce_term_id BIGINT UNSIGNED NOT NULL,
|
|
||||||
meta_key varchar(255) default NULL,
|
|
||||||
meta_value longtext NULL,
|
|
||||||
PRIMARY KEY (meta_id),
|
|
||||||
KEY woocommerce_term_id (woocommerce_term_id),
|
|
||||||
KEY meta_key (meta_key(32))
|
|
||||||
) $collate;
|
) $collate;
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
@ -873,11 +856,6 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta (
|
||||||
"{$wpdb->prefix}woocommerce_tax_rates",
|
"{$wpdb->prefix}woocommerce_tax_rates",
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! function_exists( 'get_term_meta' ) ) {
|
|
||||||
// This table is only needed for old installs and is now @deprecated by WordPress term meta.
|
|
||||||
$tables[] = "{$wpdb->prefix}woocommerce_termmeta";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the list of known WooCommerce tables.
|
* Filter the list of known WooCommerce tables.
|
||||||
*
|
*
|
||||||
|
|
|
@ -656,11 +656,6 @@ final class WooCommerce {
|
||||||
$wpdb->order_itemmeta = $wpdb->prefix . 'woocommerce_order_itemmeta';
|
$wpdb->order_itemmeta = $wpdb->prefix . 'woocommerce_order_itemmeta';
|
||||||
$wpdb->tables[] = 'woocommerce_payment_tokenmeta';
|
$wpdb->tables[] = 'woocommerce_payment_tokenmeta';
|
||||||
$wpdb->tables[] = 'woocommerce_order_itemmeta';
|
$wpdb->tables[] = 'woocommerce_order_itemmeta';
|
||||||
|
|
||||||
if ( get_option( 'db_version' ) < 34370 ) {
|
|
||||||
$wpdb->woocommerce_termmeta = $wpdb->prefix . 'woocommerce_termmeta';
|
|
||||||
$wpdb->tables[] = 'woocommerce_termmeta';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -531,9 +531,8 @@ function wc_create_attribute( $args ) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update taxonomy ordering term meta.
|
// Update taxonomy ordering term meta.
|
||||||
$table_name = get_option( 'db_version' ) < 34370 ? $wpdb->prefix . 'woocommerce_termmeta' : $wpdb->termmeta;
|
|
||||||
$wpdb->update(
|
$wpdb->update(
|
||||||
$table_name,
|
$wpdb->termmeta,
|
||||||
array( 'meta_key' => 'order_pa_' . sanitize_title( $data['attribute_name'] ) ), // WPCS: slow query ok.
|
array( 'meta_key' => 'order_pa_' . sanitize_title( $data['attribute_name'] ) ), // WPCS: slow query ok.
|
||||||
array( 'meta_key' => 'order_pa_' . sanitize_title( $old_slug ) ) // WPCS: slow query ok.
|
array( 'meta_key' => 'order_pa_' . sanitize_title( $old_slug ) ) // WPCS: slow query ok.
|
||||||
);
|
);
|
||||||
|
|
|
@ -1012,3 +1012,15 @@ function wc_get_core_supported_themes() {
|
||||||
wc_deprecated_function( 'wc_get_core_supported_themes()', '3.3' );
|
wc_deprecated_function( 'wc_get_core_supported_themes()', '3.3' );
|
||||||
return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' );
|
return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When a term is split, ensure meta data maintained.
|
||||||
|
*
|
||||||
|
* @param int $old_term_id Old term ID.
|
||||||
|
* @param int $new_term_id New term ID.
|
||||||
|
* @param string $term_taxonomy_id Term taxonomy ID.
|
||||||
|
* @param string $taxonomy Taxonomy.
|
||||||
|
*/
|
||||||
|
function wc_taxonomy_metadata_update_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
|
||||||
|
wc_deprecated_function( 'wc_taxonomy_metadata_update_content_for_split_terms', '3.6' );
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue