Skip to content

Commit

Permalink
Fixed warning of incorrect migrations path on builds (#209) (#210)
Browse files Browse the repository at this point in the history
* Fixed warning of incorrect migrations path on builds

* Fix PHPStan missing contant warning
  • Loading branch information
doekenorg authored Jan 17, 2025
1 parent 55592dd commit 959d390
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
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

0 comments on commit 959d390

Please sign in to comment.