Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed warning of incorrect migrations path on builds (#209) #210

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion gfexcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
define( 'GFEXCEL_MIN_PHP_VERSION', '7.2' );
}

$src_folder = __DIR__ . '/build/vendor_prefixed/gravitykit/gravityexport-lite-src';
if ( ! is_readable( $src_folder ) ) {
$src_folder = __DIR__ . '/src';
}
define( 'GFEXCEL_SRC_FOLDER', $src_folder );

if ( version_compare( phpversion(), GFEXCEL_MIN_PHP_VERSION, '<' ) ) {
$show_minimum_php_version_message = function () {
$message = wpautop( sprintf( esc_html__( 'GravityExport Lite requires PHP %s or newer.', 'gk-gravityexport-lite' ), GFEXCEL_MIN_PHP_VERSION ) );
Expand Down Expand Up @@ -63,7 +69,8 @@
}

$autoload_file = __DIR__ . '/build/vendor/autoload.php';
$is_build = true;

$is_build = true;
if ( ! file_exists( $autoload_file ) ) {
$autoload_file = __DIR__ . '/vendor/autoload.php';
$is_build = false;
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ You can hide a row by adding a hook. Checkout this example:

== Changelog ==

= develop =

* Fixed: A warning would appear when upgrading GravityExport Lite.

= 2.3.6 on December 18, 2024 =

* Fixed: Type errors on fields no longer cause exports to fail. Values become empty, and errors are logged.
Expand Down
2 changes: 2 additions & 0 deletions src/Migration/Manager/MigrationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private function maybe_migrate(): void {
$this->migrate();
} catch ( MigrationException $e ) {
GravityExportAddon::get_instance()->log_error( sprintf( 'Migration error: %s', $e->getMessage() ) );
// Clear running status.
$this->repository->setRunning( false );
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Migration/Repository/FileSystemMigrationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public function shouldMigrate(): bool {
* @since 2.0.0
*/
public function getMigrations(): array {
if ( ! is_readable( $this->migration_path ) ) {
return [];
}

// Change directory for glob. We do this here, so we can better test `getMigrations()`.
chdir( $this->migration_path );

Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider/AddOnProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function register(): void {
$container = $this->getContainer();

$container->add( MigrationRepositoryInterface::class, FileSystemMigrationRepository::class )
->addArgument( dirname( GFEXCEL_PLUGIN_FILE ) . '/src/Migration/Migration/' );
->addArgument( GFEXCEL_SRC_FOLDER . '/Migration/Migration/' );
$container->add( NotificationRepositoryInterface::class, NotificationRepository::class );
$container->add( NotificationManager::class )->addArgument( NotificationRepositoryInterface::class );

Expand Down
Loading