Skip to content

Fix deleting paths before the import to support directories - #657

Merged
wojtekn merged 2 commits into
trunkfrom
fix/deleting-paths-before-import
Nov 15, 2024
Merged

Fix deleting paths before the import to support directories#657
wojtekn merged 2 commits into
trunkfrom
fix/deleting-paths-before-import

Conversation

@wojtekn

@wojtekn wojtekn commented Nov 13, 2024

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

I propose fixing deleting paths before the import to ensure default plugins and themes are deleted before we import the site content.

Testing Instructions

  1. Import sites from different formats (Jetpack Backup, Playground ZIP file, .wpress file, Local export)
  2. Confirm that default set of plugins themes that are included in clean WordPress are not visible on imported site if they were not included in the site being imported

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wojtekn
wojtekn requested a review from a team November 13, 2024 11:44
@wojtekn wojtekn self-assigned this Nov 13, 2024
}

protected async safelyDeleteFile( filePath: string ): Promise< void > {
protected async safelyDeletePath( path: string ): Promise< void > {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I renamed the method and parameter to show better what it does.

protected async safelyDeletePath( path: string ): Promise< void > {
try {
await fsPromises.unlink( filePath );
await fsPromises.rm( path, { recursive: true, force: true } );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It supports deleting file and directory recursively.

@nightnei

Copy link
Copy Markdown
Contributor

Import sites from different formats
Could you please add more details of what means different formats? It would be handy to understand how I can create different types that are necessary for tests.

Confirm that core plugins like Hello Dolly or Akismet and themes like 2020 are not installed if they are not included in the site being imported

Should I install the 2020 theme and then assert that it's reverted to some default theme and two default plugins were removed? Also I tried to install it and can't find 2020 theme, hm.

Sorry, I didn't work with exporting/importing before, and actually I worked with plugins just a little bit. So such short testing steps are very difficult for me to understand.

@wojtekn

wojtekn commented Nov 14, 2024

Copy link
Copy Markdown
Contributor Author

Import sites from different formats
Could you please add more details of what means different formats? It would be handy to understand how I can create different types that are necessary for tests.

It seems we haven't documented all formats in docs yet. We support:

Should I install the 2020 theme and then assert that it's reverted to some default theme and two default plugins were removed? Also I tried to install it and can't find 2020 theme, hm.

Create a vanilla WordPress site in Studio and see what plugins and themes are included by default. Then, when you add a new site by importing it from the file, confirm that those default plugins and themes are not included in that site, if they were not a part of export file.

Also see related issue for more context on use case reported by user.

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It works as expected for me and the default plugins get deleted 👍

Please note that I tested only with the wpress file and the Jetpack backup so perhaps we can wait for another review.

@nightnei

nightnei commented Nov 15, 2024

Copy link
Copy Markdown
Contributor

@wojtekn

Jetpack Backup:

wordpress.com (8 plugins) trunk (9 plugins - additionally I see "Hello Dolly") this branch (8 plugins)
Screenshot 2024-11-15 at 12 36 36 Screenshot 2024-11-15 at 12 36 59 Screenshot 2024-11-15 at 12 37 25

So the difference is only "Hello Dolly", is it what we expect, that "Hello Dolly" is ignored during importing of "Jetpack Backup"? So actually we are ignoring not all default plagins, but only those which are extra for wordpress.com?

I will proceed to test other 3 types of imports.

@wojtekn

wojtekn commented Nov 15, 2024

Copy link
Copy Markdown
Contributor Author

So actually we are ignoring not all default plagins, but only those which are extra for wordpress.com?

@nightnei in most straightforward words:

  • before the fix, import added plugins from the backup file to the Site in Studio
  • after the fix, import replaces plugins in the Studio site with those from the backup file
@nightnei

nightnei commented Nov 15, 2024

Copy link
Copy Markdown
Contributor

@nightnei in most straightforward words:
before the fix, import added plugins from the backup file to the Site in Studio
after the fix, import replaces plugins in the Studio site with those from the backup file

@wojtekn got it, thanks you. It's really much more straightforward and clear to understand what we are actually doing.
Tested with:

  1. created website, added a few plugins
  2. Importad Jetpack Backup site
  3. Confirmed that all plugins were replaced by plugins from imported "Jetpack Backup":
BEFORE IMPORT (12 items) AFTER IMPORT (8 items)
Screenshot 2024-11-15 at 13 02 27 Screenshot 2024-11-15 at 13 07 11

All-in-One WP Migration and Backup

Tested All-in-One WP Migration and Backup - all good, the same result as with "Jetpack Backup".

Local

Local export - all good, the same result what I have in local - no plugins installed at all:

Screenshot 2024-11-15 at 14 02 32

Playground

Playground .zip file - the same result as for Local - no plugins installed

It's really good PR/fix - if we are importing a site, we should replace all plugins too 👍

@nightnei nightnei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good and test well (look previous comment ^) 👍

@wojtekn

wojtekn commented Nov 15, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for detailed testing @nightnei and @katinthehatsite !

@wojtekn
wojtekn merged commit fa4be28 into trunk Nov 15, 2024
@wojtekn
wojtekn deleted the fix/deleting-paths-before-import branch November 15, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants