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

The --skip-content flag does not create folders inside wp-content #228

Closed
maximejobin opened this issue Mar 8, 2023 · 8 comments · Fixed by #230
Closed

The --skip-content flag does not create folders inside wp-content #228

maximejobin opened this issue Mar 8, 2023 · 8 comments · Fixed by #230

Comments

@maximejobin
Copy link

maximejobin commented Mar 8, 2023

If you run:

wp core download --skip-content

It creates what I would call an unusable installation.

My expectation would be a working installation without themes or plugins... not an installation that does not create needed folders in the wp-content folder.

The probleme is that I installed WordPress from WP CLI. Then, I logged in and tried to install a plugin and it gave an error because the plugins folder does not exist.

That being said, if I would've installed a plugin with WP CLI, the folders would have been created correctly.

I would argue this is a bug even if that was the original intention as it leaves the installation in an unusable status.

@maximejobin
Copy link
Author

This is linked, in some way, to this issue: #190

@maximejobin maximejobin changed the title The --skip-content flag does not create folders inside wp-content The --skip-content flag does not create folders inside wp-content Mar 8, 2023
@maximejobin
Copy link
Author

After investigation, it all happens here:

if ( 0 === stripos( $info['name'], 'wordpress/wp-content/themes/' ) || 0 === stripos( $info['name'], 'wordpress/wp-content/plugins/' ) ) {

My suggestion:

  1. Stop removing the directory itself
  2. Remove every file inside the plugins and themes folder except index.php

@danielbachhuber
Copy link
Member

Here's the original pull request for --skip-content: #37

And the issue that inspired it: wp-cli/ideas#59

Creating empty plugins and themes folders would be a change in behavior. I'm not sure whether to consider it a breaking change, or if the current behavior should be considered a bug.

If we changed the behavior for the --skip-content flag, I think we'd want to do some research on how folks are currently using it (to make sure it doesn't cause unexpected bugs for them).

We could potentially add some other flag instead, but I don't really like that idea.

We could also "fix" this with documentation (call out the fact that folders aren't created and you'll need to do so yourself).

@maximejobin
Copy link
Author

Daniel,

Thank you for your fast answer! I read the issue, the idea and tried to understand what's the reason for all this.

From what I understand, the idea was to get a fully functional WordPress installation without having to delete the Twenty* themes and also get rid of both Akismet and Hello Dolly.

WP offers a ZIP file named no-content where the wp-content is just not there. From what I "understand", the "no-content" ZIP file provided is used for updates to avoid overwriting the themes and plugins folder. It was not created to install WordPress. Note that this is an unverified opinion. It's not a fact.

So if the skip-content is intended to do the same as the ZIP, I do not understand why CLI deletes what is inside wp-content instead of only deleting the whole folder.

My guess is that developers who use this feature also install plugins (or at least one!) from CLI. If/when they do, the folder is created and there is no problem. If, like me, you spin WPs to do testing on vanilla installations all the time, you install WP from CLI and then upload manually your plugins. Doing so will fail as there is no way to install a theme or plugin with the UI if the folders do not exist.

I still believe this should be considered a bug or a conception issue that should be fixed.

But no matter if you agree or not (that's totally fine!), I would strongly suggest to edit the documentation as the flag does not do exactly what is written.

On the other hand, I know this could break scripts that could've been done as a workaround for this issue.

I do not know how we can do that research to find out what should be done. Until we can solve this (if we can!), my vanilla installs will be made by not using --skip-content and manually (well... with CLI) deleting posts, pages, comments, themes, and plugins.

Let me know if I can help in some way!

@swissspidy
Copy link
Member

The probleme is that I installed WordPress from WP CLI. Then, I logged in and tried to install a plugin and it gave an error because the plugins folder does not exist.

Maybe WordPress should just create the folder if it's missing?

@maximejobin
Copy link
Author

Maybe WordPress should just create the folder if it's missing?

Well... the folder was created during the installation but deleted by WP-CLI.

Also, when installing a plugin with CLI, it creates the folder if it does not exist... something that WordPress itself does not do.

I'm just unsure where the problem should be handled. That being said, I could be a good safety for WordPress to check and create the folders if they do not exist.

If it were up to me, I'd say: WP-CLI should not create a situation like this one. The --skip-content really means --remove-plugins-and-themes-folders! It does not skip anything but should only remove the content, in my opinion, and not the folders themselves.

@danielbachhuber danielbachhuber self-assigned this Mar 24, 2023
@danielbachhuber
Copy link
Member

I'll look into this further when I have a moment. It may be a few weeks, however.

@danielbachhuber
Copy link
Member

@maximejobin After reviewing the history of the issues, I'm amenable to creating wp-content/plugins and wp-content/themes by default: #230

We will need to make an evaluation on whether it's a breaking change or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants