Merge pull request woocommerce/woocommerce-admin#1461 from woocommerce/fix/1460
Fixed database prefixes for admin notes tables
This commit is contained in:
commit
b7c40c2c29
|
@ -781,8 +781,8 @@ class WC_Admin_Api_Init {
|
||||||
"{$wpdb->prefix}wc_order_product_lookup",
|
"{$wpdb->prefix}wc_order_product_lookup",
|
||||||
"{$wpdb->prefix}wc_order_tax_lookup",
|
"{$wpdb->prefix}wc_order_tax_lookup",
|
||||||
"{$wpdb->prefix}wc_order_coupon_lookup",
|
"{$wpdb->prefix}wc_order_coupon_lookup",
|
||||||
"{$wpdb->prefix}woocommerce_admin_notes",
|
"{$wpdb->prefix}wc_admin_notes",
|
||||||
"{$wpdb->prefix}woocommerce_admin_note_actions",
|
"{$wpdb->prefix}wc_admin_note_actions",
|
||||||
"{$wpdb->prefix}wc_customer_lookup",
|
"{$wpdb->prefix}wc_customer_lookup",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -860,7 +860,7 @@ class WC_Admin_Api_Init {
|
||||||
KEY coupon_id (coupon_id),
|
KEY coupon_id (coupon_id),
|
||||||
KEY date_created (date_created)
|
KEY date_created (date_created)
|
||||||
) $collate;
|
) $collate;
|
||||||
CREATE TABLE {$wpdb->prefix}woocommerce_admin_notes (
|
CREATE TABLE {$wpdb->prefix}wc_admin_notes (
|
||||||
note_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
note_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
name varchar(255) NOT NULL,
|
name varchar(255) NOT NULL,
|
||||||
type varchar(20) NOT NULL,
|
type varchar(20) NOT NULL,
|
||||||
|
@ -875,7 +875,7 @@ class WC_Admin_Api_Init {
|
||||||
date_reminder datetime NULL default null,
|
date_reminder datetime NULL default null,
|
||||||
PRIMARY KEY (note_id)
|
PRIMARY KEY (note_id)
|
||||||
) $collate;
|
) $collate;
|
||||||
CREATE TABLE {$wpdb->prefix}woocommerce_admin_note_actions (
|
CREATE TABLE {$wpdb->prefix}wc_admin_note_actions (
|
||||||
action_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
action_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
note_id BIGINT UNSIGNED NOT NULL,
|
note_id BIGINT UNSIGNED NOT NULL,
|
||||||
name varchar(255) NOT NULL,
|
name varchar(255) NOT NULL,
|
||||||
|
|
|
@ -37,7 +37,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
$note_to_be_inserted['date_created'] = gmdate( 'Y-m-d H:i:s', $date_created );
|
$note_to_be_inserted['date_created'] = gmdate( 'Y-m-d H:i:s', $date_created );
|
||||||
$note_to_be_inserted['date_reminder'] = null;
|
$note_to_be_inserted['date_reminder'] = null;
|
||||||
|
|
||||||
$wpdb->insert( $wpdb->prefix . 'woocommerce_admin_notes', $note_to_be_inserted );
|
$wpdb->insert( $wpdb->prefix . 'wc_admin_notes', $note_to_be_inserted );
|
||||||
$note_id = $wpdb->insert_id;
|
$note_id = $wpdb->insert_id;
|
||||||
$note->set_id( $note_id );
|
$note->set_id( $note_id );
|
||||||
$note->save_meta_data();
|
$note->save_meta_data();
|
||||||
|
@ -68,7 +68,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
if ( 0 !== $note_id || '0' !== $note_id ) {
|
if ( 0 !== $note_id || '0' !== $note_id ) {
|
||||||
$note_row = $wpdb->get_row(
|
$note_row = $wpdb->get_row(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"SELECT name, type, locale, title, content, icon, content_data, status, source, date_created, date_reminder FROM {$wpdb->prefix}woocommerce_admin_notes WHERE note_id = %d LIMIT 1",
|
"SELECT name, type, locale, title, content, icon, content_data, status, source, date_created, date_reminder FROM {$wpdb->prefix}wc_admin_notes WHERE note_id = %d LIMIT 1",
|
||||||
$note->get_id()
|
$note->get_id()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -134,7 +134,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
}
|
}
|
||||||
|
|
||||||
$wpdb->update(
|
$wpdb->update(
|
||||||
$wpdb->prefix . 'woocommerce_admin_notes',
|
$wpdb->prefix . 'wc_admin_notes',
|
||||||
array(
|
array(
|
||||||
'name' => $note->get_name(),
|
'name' => $note->get_name(),
|
||||||
'type' => $note->get_type(),
|
'type' => $note->get_type(),
|
||||||
|
@ -174,8 +174,8 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
$note_id = $note->get_id();
|
$note_id = $note->get_id();
|
||||||
if ( $note_id ) {
|
if ( $note_id ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$wpdb->delete( $wpdb->prefix . 'woocommerce_admin_notes', array( 'note_id' => $note_id ) );
|
$wpdb->delete( $wpdb->prefix . 'wc_admin_notes', array( 'note_id' => $note_id ) );
|
||||||
$wpdb->delete( $wpdb->prefix . 'woocommerce_admin_note_actions', array( 'note_id' => $note_id ) );
|
$wpdb->delete( $wpdb->prefix . 'wc_admin_note_actions', array( 'note_id' => $note_id ) );
|
||||||
$note->set_id( null );
|
$note->set_id( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
|
|
||||||
$actions = $wpdb->get_results(
|
$actions = $wpdb->get_results(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"SELECT name, label, query FROM {$wpdb->prefix}woocommerce_admin_note_actions WHERE note_id = %d",
|
"SELECT name, label, query FROM {$wpdb->prefix}wc_admin_note_actions WHERE note_id = %d",
|
||||||
$note->get_id()
|
$note->get_id()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -223,10 +223,10 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
}
|
}
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$wpdb->delete( $wpdb->prefix . 'woocommerce_admin_note_actions', array( 'note_id' => $note->get_id() ) );
|
$wpdb->delete( $wpdb->prefix . 'wc_admin_note_actions', array( 'note_id' => $note->get_id() ) );
|
||||||
foreach ( $note->get_actions( 'edit' ) as $action ) {
|
foreach ( $note->get_actions( 'edit' ) as $action ) {
|
||||||
$wpdb->insert(
|
$wpdb->insert(
|
||||||
$wpdb->prefix . 'woocommerce_admin_note_actions',
|
$wpdb->prefix . 'wc_admin_note_actions',
|
||||||
array(
|
array(
|
||||||
'note_id' => $note->get_id(),
|
'note_id' => $note->get_id(),
|
||||||
'name' => $action->name,
|
'name' => $action->name,
|
||||||
|
@ -273,14 +273,14 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
|
|
||||||
if ( empty( $escaped_where_types ) ) {
|
if ( empty( $escaped_where_types ) ) {
|
||||||
$query = $wpdb->prepare(
|
$query = $wpdb->prepare(
|
||||||
"SELECT note_id, title, content FROM {$wpdb->prefix}woocommerce_admin_notes ORDER BY note_id DESC LIMIT %d, %d",
|
"SELECT note_id, title, content FROM {$wpdb->prefix}wc_admin_notes ORDER BY note_id DESC LIMIT %d, %d",
|
||||||
$offset,
|
$offset,
|
||||||
$per_page
|
$per_page
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$query = $wpdb->prepare(
|
$query = $wpdb->prepare(
|
||||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||||
"SELECT note_id, title, content FROM {$wpdb->prefix}woocommerce_admin_notes WHERE type IN ($escaped_where_types) ORDER BY note_id DESC LIMIT %d, %d",
|
"SELECT note_id, title, content FROM {$wpdb->prefix}wc_admin_notes WHERE type IN ($escaped_where_types) ORDER BY note_id DESC LIMIT %d, %d",
|
||||||
$offset,
|
$offset,
|
||||||
$per_page
|
$per_page
|
||||||
);
|
);
|
||||||
|
@ -296,7 +296,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
*/
|
*/
|
||||||
public function get_notes_count() {
|
public function get_notes_count() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
return $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_admin_notes" );
|
return $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}wc_admin_notes" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,7 +309,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
return $wpdb->get_col(
|
return $wpdb->get_col(
|
||||||
$wpdb->prepare(
|
$wpdb->prepare(
|
||||||
"SELECT note_id FROM {$wpdb->prefix}woocommerce_admin_notes WHERE name = %s ORDER BY note_id ASC",
|
"SELECT note_id FROM {$wpdb->prefix}wc_admin_notes WHERE name = %s ORDER BY note_id ASC",
|
||||||
$name
|
$name
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin notes helper for wc-admin unit tests.
|
||||||
|
*
|
||||||
|
* @package WooCommerce\Tests\Framework\Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class WC_Helper_Admin_Notes.
|
* Class WC_Helper_Admin_Notes.
|
||||||
|
@ -12,8 +17,8 @@ class WC_Helper_Admin_Notes {
|
||||||
*/
|
*/
|
||||||
public static function reset_notes_dbs() {
|
public static function reset_notes_dbs() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_admin_notes" ); // @codingStandardsIgnoreLine.
|
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wc_admin_notes" ); // @codingStandardsIgnoreLine.
|
||||||
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_admin_note_actions" ); // @codingStandardsIgnoreLine.
|
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wc_admin_note_actions" ); // @codingStandardsIgnoreLine.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue