WooCommerce Admin - Version 0.20.1

Version Description

2019-09-24 =

  • Fix: use category lookup id instead of term taxonomy id (#3027)
  • Fix: Update order stats table status index length. (#3022)
Download this release

Release Info

Developer psealock
Plugin Icon 128x128 WooCommerce Admin
Version 0.20.1
Comparing to
See all releases

Code changes from version 0.20.0 to 0.20.1

includes/wc-admin-update-functions.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Admin Updates
4
+ *
5
+ * Functions for updating data, used by the background updater.
6
+ *
7
+ * @package WooCommerce/Admin
8
+ */
9
+
10
+ defined( 'ABSPATH' ) || exit;
11
+
12
+ use \Automattic\WooCommerce\Admin\Install as Installer;
13
+
14
+ /**
15
+ * Update order stats `status` index length.
16
+ * See: https://github.com/woocommerce/woocommerce-admin/issues/2969.
17
+ */
18
+ function wc_admin_update_0201_order_status_index() {
19
+ global $wpdb;
20
+
21
+ // Max DB index length. See wp_get_db_schema().
22
+ $max_index_length = 191;
23
+
24
+ $index = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->prefix}wc_order_stats WHERE key_name = 'status'" );
25
+
26
+ if ( property_exists( $index, 'Sub_part' ) ) {
27
+ // The index was created with the right length. Time to bail.
28
+ if ( $max_index_length === $index->Sub_part ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
29
+ return;
30
+ }
31
+
32
+ // We need to drop the index so it can be recreated.
33
+ $wpdb->query( "DROP INDEX `status` ON {$wpdb->prefix}wc_order_stats" );
34
+ }
35
+
36
+ // Recreate the status index with a max length.
37
+ $wpdb->query( $wpdb->prepare( "ALTER TABLE {$wpdb->prefix}wc_order_stats ADD INDEX status (status(%d))", $max_index_length ) );
38
+ }
39
+
40
+ /**
41
+ * Update DB Version.
42
+ */
43
+ function wc_admin_update_0201_db_version() {
44
+ Installer::update_db_version( '0.20.1' );
45
+ }
languages/woocommerce-admin.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the WooCommerce Admin package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Admin 0.20.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wc-admin\n"
7
- "POT-Creation-Date: 2019-10-10 01:41:33+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the same license as the WooCommerce Admin package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Admin 0.20.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wc-admin\n"
7
+ "POT-Creation-Date: 2019-10-13 21:03:42+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
readme.txt CHANGED
@@ -71,6 +71,11 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
74
  = 0.20.0 2019-09-24 =
75
 
76
  - Dev: Fix issue #2992 (order number in orders panel) #2994
71
 
72
  == Changelog ==
73
 
74
+ = 0.20.1 2019-09-24 =
75
+
76
+ - Fix: use category lookup id instead of term taxonomy id (#3027)
77
+ - Fix: Update order stats table status index length. (#3022)
78
+
79
  = 0.20.0 2019-09-24 =
80
 
81
  - Dev: Fix issue #2992 (order number in orders panel) #2994
src/API/Reports/Products/Stats/Segmenter.php CHANGED
@@ -104,7 +104,7 @@ class Segmenter extends ReportsSegmenter {
104
  $orig_offset = intval( $limit_parts[1] );
105
  $orig_rowcount = intval( $limit_parts[2] );
106
  $segmenting_limit = $wpdb->prepare( 'LIMIT %d, %d', $orig_offset * $segment_count, $orig_rowcount * $segment_count );
107
-
108
  // Can't get all the numbers from one query, so split it into one query for product-level numbers and one for order-level numbers (which first need to have orders uniqued).
109
  // Product-level numbers.
110
  $segments_products = $wpdb->get_results(
@@ -191,8 +191,8 @@ class Segmenter extends ReportsSegmenter {
191
 
192
  // Restrict our search space for category comparisons.
193
  if ( isset( $this->query_args['categories'] ) ) {
194
- $category_ids = implode( ',', $this->get_all_segments() );
195
- $segmenting_where .= " AND wp_term_taxonomy.term_taxonomy_id IN ( $category_ids )";
196
  }
197
 
198
  $segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
104
  $orig_offset = intval( $limit_parts[1] );
105
  $orig_rowcount = intval( $limit_parts[2] );
106
  $segmenting_limit = $wpdb->prepare( 'LIMIT %d, %d', $orig_offset * $segment_count, $orig_rowcount * $segment_count );
107
+
108
  // Can't get all the numbers from one query, so split it into one query for product-level numbers and one for order-level numbers (which first need to have orders uniqued).
109
  // Product-level numbers.
110
  $segments_products = $wpdb->get_results(
191
 
192
  // Restrict our search space for category comparisons.
193
  if ( isset( $this->query_args['categories'] ) ) {
194
+ $category_ids = implode( ',', $this->get_all_segments() );
195
+ $segmenting_where .= " AND {$wpdb->wc_category_lookup}.category_id IN ( $category_ids )";
196
  }
197
 
198
  $segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );
src/FeaturePlugin.php CHANGED
@@ -122,7 +122,7 @@ class FeaturePlugin {
122
  $this->define( 'WC_ADMIN_PLUGIN_FILE', WC_ADMIN_ABSPATH . 'woocommerce-admin.php' );
123
  // WARNING: Do not directly edit this version number constant.
124
  // It is updated as part of the prebuild process from the package.json value.
125
- $this->define( 'WC_ADMIN_VERSION_NUMBER', '0.20.0' );
126
  }
127
 
128
  /**
122
  $this->define( 'WC_ADMIN_PLUGIN_FILE', WC_ADMIN_ABSPATH . 'woocommerce-admin.php' );
123
  // WARNING: Do not directly edit this version number constant.
124
  // It is updated as part of the prebuild process from the package.json value.
125
+ $this->define( 'WC_ADMIN_VERSION_NUMBER', '0.20.1' );
126
  }
127
 
128
  /**
src/Install.php CHANGED
@@ -26,7 +26,12 @@ class Install {
26
  *
27
  * @var array
28
  */
29
- protected static $db_updates = array();
 
 
 
 
 
30
 
31
  /**
32
  * Hook in tabs.
@@ -74,7 +79,7 @@ class Install {
74
  self::create_tables();
75
  self::create_events();
76
  self::create_notes();
77
- self::update_db_version();
78
 
79
  delete_transient( 'wc_admin_installing' );
80
 
@@ -94,6 +99,9 @@ class Install {
94
  $collate = $wpdb->get_charset_collate();
95
  }
96
 
 
 
 
97
  $tables = "
98
  CREATE TABLE {$wpdb->prefix}wc_order_stats (
99
  order_id bigint(20) unsigned NOT NULL,
@@ -111,7 +119,7 @@ class Install {
111
  PRIMARY KEY (order_id),
112
  KEY date_created (date_created),
113
  KEY customer_id (customer_id),
114
- KEY status (status)
115
  ) $collate;
116
  CREATE TABLE {$wpdb->prefix}wc_order_product_lookup (
117
  order_item_id BIGINT UNSIGNED NOT NULL,
@@ -261,12 +269,57 @@ class Install {
261
  return array_merge( $tables, self::get_tables() );
262
  }
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  /**
265
  * Update WC Admin version to current.
 
 
266
  */
267
- protected static function update_db_version() {
268
  delete_option( self::VERSION_OPTION );
269
- add_option( self::VERSION_OPTION, WC_ADMIN_VERSION_NUMBER );
270
  }
271
 
272
  /**
26
  *
27
  * @var array
28
  */
29
+ protected static $db_updates = array(
30
+ '0.20.1' => array(
31
+ 'wc_admin_update_0201_order_status_index',
32
+ 'wc_admin_update_0201_db_version',
33
+ ),
34
+ );
35
 
36
  /**
37
  * Hook in tabs.
79
  self::create_tables();
80
  self::create_events();
81
  self::create_notes();
82
+ self::update_db();
83
 
84
  delete_transient( 'wc_admin_installing' );
85
 
99
  $collate = $wpdb->get_charset_collate();
100
  }
101
 
102
+ // Max DB index length. See wp_get_db_schema().
103
+ $max_index_length = 191;
104
+
105
  $tables = "
106
  CREATE TABLE {$wpdb->prefix}wc_order_stats (
107
  order_id bigint(20) unsigned NOT NULL,
119
  PRIMARY KEY (order_id),
120
  KEY date_created (date_created),
121
  KEY customer_id (customer_id),
122
+ KEY status (status({$max_index_length}))
123
  ) $collate;
124
  CREATE TABLE {$wpdb->prefix}wc_order_product_lookup (
125
  order_item_id BIGINT UNSIGNED NOT NULL,
269
  return array_merge( $tables, self::get_tables() );
270
  }
271
 
272
+ /**
273
+ * Get list of DB update callbacks.
274
+ *
275
+ * @return array
276
+ */
277
+ public static function get_db_update_callbacks() {
278
+ return self::$db_updates;
279
+ }
280
+
281
+ /**
282
+ * Push all needed DB updates to the queue for processing.
283
+ */
284
+ private static function update_db() {
285
+ $current_db_version = get_option( self::VERSION_OPTION );
286
+ $loop = 0;
287
+
288
+ foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
289
+ if ( version_compare( $current_db_version, $version, '<' ) ) {
290
+ foreach ( $update_callbacks as $update_callback ) {
291
+ $pending_jobs = WC()->queue()->search(
292
+ array(
293
+ 'per_page' => 1,
294
+ 'hook' => 'woocommerce_run_update_callback',
295
+ 'search' => json_encode( array( $update_callback ) ),
296
+ 'group' => 'woocommerce-db-updates',
297
+ )
298
+ );
299
+
300
+ if ( empty( $pending_jobs ) ) {
301
+ WC()->queue()->schedule_single(
302
+ time() + $loop,
303
+ 'woocommerce_run_update_callback',
304
+ array( $update_callback ),
305
+ 'woocommerce-db-updates'
306
+ );
307
+ }
308
+
309
+ $loop++;
310
+ }
311
+ }
312
+ }
313
+ }
314
+
315
  /**
316
  * Update WC Admin version to current.
317
+ *
318
+ * @param string|null $version New WooCommerce Admin DB version or null.
319
  */
320
+ public static function update_db_version( $version = null ) {
321
  delete_option( self::VERSION_OPTION );
322
+ add_option( self::VERSION_OPTION, is_null( $version ) ? WC_ADMIN_VERSION_NUMBER : $version );
323
  }
324
 
325
  /**
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit3b6fff729d513985e77401a2459529a8::getLoader();
vendor/composer/autoload_files.php CHANGED
@@ -9,4 +9,5 @@ return array(
9
  'fd9f5df955e5151499fd2f642091d0a0' => $baseDir . '/includes/core-functions.php',
10
  'b907791bfd099af1d822ca201c3f03f0' => $baseDir . '/includes/feature-config.php',
11
  'c440206b9a4cb2ee803d8c41ad1f292a' => $baseDir . '/includes/page-controller-functions.php',
 
12
  );
9
  'fd9f5df955e5151499fd2f642091d0a0' => $baseDir . '/includes/core-functions.php',
10
  'b907791bfd099af1d822ca201c3f03f0' => $baseDir . '/includes/feature-config.php',
11
  'c440206b9a4cb2ee803d8c41ad1f292a' => $baseDir . '/includes/page-controller-functions.php',
12
+ '57b93ef9148e0607a2b45af997e2c1c3' => $baseDir . '/includes/wc-admin-update-functions.php',
13
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitcbb979ef24f28a2445bf4598df7284ce
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequirecbb979ef24f28a2445bf4598df7284ce($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequirecbb979ef24f28a2445bf4598df7284ce($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit3b6fff729d513985e77401a2459529a8
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit3b6fff729d513985e77401a2459529a8', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit3b6fff729d513985e77401a2459529a8', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit3b6fff729d513985e77401a2459529a8::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit3b6fff729d513985e77401a2459529a8::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire3b6fff729d513985e77401a2459529a8($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire3b6fff729d513985e77401a2459529a8($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,12 +4,13 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce
8
  {
9
  public static $files = array (
10
  'fd9f5df955e5151499fd2f642091d0a0' => __DIR__ . '/../..' . '/includes/core-functions.php',
11
  'b907791bfd099af1d822ca201c3f03f0' => __DIR__ . '/../..' . '/includes/feature-config.php',
12
  'c440206b9a4cb2ee803d8c41ad1f292a' => __DIR__ . '/../..' . '/includes/page-controller-functions.php',
 
13
  );
14
 
15
  public static $prefixLengthsPsr4 = array (
@@ -37,8 +38,8 @@ class ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce
37
  public static function getInitializer(ClassLoader $loader)
38
  {
39
  return \Closure::bind(function () use ($loader) {
40
- $loader->prefixLengthsPsr4 = ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce::$prefixLengthsPsr4;
41
- $loader->prefixDirsPsr4 = ComposerStaticInitcbb979ef24f28a2445bf4598df7284ce::$prefixDirsPsr4;
42
 
43
  }, null, ClassLoader::class);
44
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit3b6fff729d513985e77401a2459529a8
8
  {
9
  public static $files = array (
10
  'fd9f5df955e5151499fd2f642091d0a0' => __DIR__ . '/../..' . '/includes/core-functions.php',
11
  'b907791bfd099af1d822ca201c3f03f0' => __DIR__ . '/../..' . '/includes/feature-config.php',
12
  'c440206b9a4cb2ee803d8c41ad1f292a' => __DIR__ . '/../..' . '/includes/page-controller-functions.php',
13
+ '57b93ef9148e0607a2b45af997e2c1c3' => __DIR__ . '/../..' . '/includes/wc-admin-update-functions.php',
14
  );
15
 
16
  public static $prefixLengthsPsr4 = array (
38
  public static function getInitializer(ClassLoader $loader)
39
  {
40
  return \Closure::bind(function () use ($loader) {
41
+ $loader->prefixLengthsPsr4 = ComposerStaticInit3b6fff729d513985e77401a2459529a8::$prefixLengthsPsr4;
42
+ $loader->prefixDirsPsr4 = ComposerStaticInit3b6fff729d513985e77401a2459529a8::$prefixDirsPsr4;
43
 
44
  }, null, ClassLoader::class);
45
  }
woocommerce-admin.php CHANGED
@@ -7,7 +7,7 @@
7
  * Author URI: https://woocommerce.com/
8
  * Text Domain: woocommerce-admin
9
  * Domain Path: /languages
10
- * Version: 0.20.0
11
  * Requires at least: 5.2.0
12
  * Requires PHP: 5.6.20
13
  *
7
  * Author URI: https://woocommerce.com/
8
  * Text Domain: woocommerce-admin
9
  * Domain Path: /languages
10
+ * Version: 0.20.1
11
  * Requires at least: 5.2.0
12
  * Requires PHP: 5.6.20
13
  *