Skip to content

Conversation

@kirtangajjar
Copy link
Contributor

No description provided.

Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
don't migrate after put in /tmp

Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
@kirtangajjar kirtangajjar self-assigned this Sep 17, 2018
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>

Utils\delem_log( "ee migration start" );
EE::log( "Migrating EasyEngine data to new version" );
EE::log( "Executing migrations" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be printed in the first execution.


if( empty( $migrations ) ) {
EE::success( "Noting to migrate" );
exit( 0 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return statement here. No need to take execution further if $migrations are empty.

$migrations = self::get_migrations_to_execute();

if( empty( $migrations ) ) {
EE::success( "Noting to migrate" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be printed in the first execution.
Also, take care of the same in this success message:

EE::success( "Successfully migrated EasyEngine" );

// array_slice is used to remove . and .. returned by scandir()
$migrations = array_slice( scandir( self::MIGRATION_PATH ), 2 );
array_walk( $migrations, function( &$migration, $index ) {
$migrations = scandir( self::MIGRATION_PATH );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove first two elements using array_slice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only needed if migrations are executed from outside phar. I've added the condition for that below.

$migrations = scandir( self::MIGRATION_PATH );

if( ! Utils\inside_phar() ) {
$migrations = array_slice( scandir( self::MIGRATION_PATH ), 2 );
Copy link
Member

@mrrobot47 mrrobot47 Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason of having the same scandir call when it is already there above:

$migrations = scandir( self::MIGRATION_PATH );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Fixed.

* Triggers migration if current phar version > version in ee_option table
*/
private function maybe_trigger_migration() {
$db_version = Option::get( 'version' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run phpcbf. Equal to sign should match the lower one.

Copy link
Contributor Author

@kirtangajjar kirtangajjar Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't catch this was because we don't have a rule in PHPCS that checks for alignment of = sign (and marks it as error). The tool that we use to fix phpcs errors is a phpstrom code formatter that also does additional code cleanings as aligning = signs.

If my editor would've flagged this warning, It would've been fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the editor configurations accordingly.

}

$cache = EE::get_cache();
$cache->write( 'migrated', '0' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed now that we are handling it in the options table.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Removed.

Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
@mbtamuli mbtamuli merged commit 425ff14 into EasyEngine:develop-v4 Sep 21, 2018
@kirtangajjar kirtangajjar deleted the fix-migration branch November 23, 2018 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants