Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed May 22, 2023
1 parent dff8d8a commit ba3fec1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ protected function init() {
add_filter( 'current_theme_supports-block-templates', array( $this, 'remove_block_template_support_for_shop_page' ) );
add_filter( 'taxonomy_template_hierarchy', array( $this, 'add_archive_product_to_eligible_for_fallback_templates' ), 10, 1 );
add_filter( 'post_type_archive_title', array( $this, 'update_product_archive_title' ), 10, 2 );

if ( $this->package->is_experimental_build() ) {
add_action( 'after_switch_theme', array( $this, 'check_should_use_blockified_product_grid_templates' ), 10, 2 );
}
add_action( 'after_switch_theme', array( $this, 'check_should_use_blockified_product_grid_templates' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -173,6 +170,7 @@ public function check_should_use_blockified_product_grid_templates( $old_name, $
}

if ( ! $old_theme->is_block_theme() && wc_current_theme_is_fse_theme() ) {

update_option( Options::WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE, wc_bool_to_string( true ) );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function init() {
$this->register_dependencies();
$this->register_payment_methods();

if ( $this->package->is_experimental_build() && is_admin() ) {
if ( is_admin() ) {
if ( $this->package->get_version() !== $this->package->get_version_stored_on_db() ) {
$this->migration->run_migrations();
$this->package->set_version_stored_on_db();
Expand Down
12 changes: 11 additions & 1 deletion src/Migration.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php
namespace Automattic\WooCommerce\Blocks;

use Automattic\WooCommerce\Blocks\Registry\Container;


/**
* Takes care of the migrations.
*
* @since 2.5.0
*/
class Migration {

/**
* DB updates and callbacks that need to be run per version.
*
Expand All @@ -31,7 +33,15 @@ class Migration {
public function run_migrations() {
$current_db_version = get_option( Options::WC_BLOCK_VERSION, '' );

// This check is necessary because the version was not being set in the database until 10.3.0.
// In the next version, we can remove this check.
if ( str_contains(Package::get_version(), '10.3') ) {
$this->wc_blocks_update_1020_blockified_product_grid_block();
return;
}

if ( empty( $current_db_version ) ) {
// This is a fresh install, so we don't need to run any migrations.
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static function container( $reset = false ) {
NewPackage::class,
function ( $container ) {
// leave for automated version bumping.
$version = '10.3.0-dev';
$version = '10.3.0';
return new NewPackage(
$version,
dirname( __DIR__ ),
Expand Down

0 comments on commit ba3fec1

Please sign in to comment.